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 os 13import sys 14 15sys.path.append(os.path.join(os.path.dirname(__file__), 'scripts')) 16from util import build_utils 17 18 19def main(): 20 parser = optparse.OptionParser() 21 build_utils.add_depfile_option(parser) 22 23 parser.add_option('--inputs', help='List of files to archive.') 24 parser.add_option('--output', help='Path to output archive.') 25 parser.add_option('--base-dir', 26 help='If provided, the paths in the archive will be ' 27 'relative to this directory', 28 default='.') 29 30 options, _ = parser.parse_args() 31 32 inputs = ast.literal_eval(options.inputs) 33 output = options.output 34 base_dir = options.base_dir 35 36 with build_utils.atomic_output(output) as f: 37 build_utils.do_zip(inputs, f, base_dir) 38 39 if options.depfile: 40 build_utils.write_depfile(options.depfile, output) 41 42 43if __name__ == '__main__': 44 sys.exit(main()) 45