1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# Copyright 2014 The Chromium Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6""" 7Archives a set of files. 8""" 9 10import ast 11import optparse 12import sys 13from scripts.util import build_utils 14 15 16def main(): 17 parser = optparse.OptionParser() 18 build_utils.add_depfile_option(parser) 19 20 parser.add_option('--inputs', help='List of files to archive.') 21 parser.add_option('--output', help='Path to output archive.') 22 parser.add_option('--base-dir', 23 help='If provided, the paths in the archive will be ' 24 'relative to this directory', 25 default='.') 26 27 options, _ = parser.parse_args() 28 29 inputs = ast.literal_eval(options.inputs) 30 output = options.output 31 base_dir = options.base_dir 32 33 with build_utils.atomic_output(output) as f: 34 build_utils.do_zip(inputs, f, base_dir) 35 36 if options.depfile: 37 build_utils.write_depfile(options.depfile, output) 38 39 40if __name__ == '__main__': 41 sys.exit(main()) 42