15f9996aaSopenharmony_ci#!/usr/bin/env python 25f9996aaSopenharmony_ci# -*- coding: utf-8 -*- 35f9996aaSopenharmony_ci# Copyright 2014 The Chromium Authors. All rights reserved. 45f9996aaSopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 55f9996aaSopenharmony_ci# found in the LICENSE file. 65f9996aaSopenharmony_ci""" 75f9996aaSopenharmony_ciArchives a set of files. 85f9996aaSopenharmony_ci""" 95f9996aaSopenharmony_ci 105f9996aaSopenharmony_ciimport ast 115f9996aaSopenharmony_ciimport optparse 125f9996aaSopenharmony_ciimport sys 135f9996aaSopenharmony_cifrom scripts.util import build_utils 145f9996aaSopenharmony_ci 155f9996aaSopenharmony_ci 165f9996aaSopenharmony_cidef main(): 175f9996aaSopenharmony_ci parser = optparse.OptionParser() 185f9996aaSopenharmony_ci build_utils.add_depfile_option(parser) 195f9996aaSopenharmony_ci 205f9996aaSopenharmony_ci parser.add_option('--inputs', help='List of files to archive.') 215f9996aaSopenharmony_ci parser.add_option('--output', help='Path to output archive.') 225f9996aaSopenharmony_ci parser.add_option('--base-dir', 235f9996aaSopenharmony_ci help='If provided, the paths in the archive will be ' 245f9996aaSopenharmony_ci 'relative to this directory', 255f9996aaSopenharmony_ci default='.') 265f9996aaSopenharmony_ci 275f9996aaSopenharmony_ci options, _ = parser.parse_args() 285f9996aaSopenharmony_ci 295f9996aaSopenharmony_ci inputs = ast.literal_eval(options.inputs) 305f9996aaSopenharmony_ci output = options.output 315f9996aaSopenharmony_ci base_dir = options.base_dir 325f9996aaSopenharmony_ci 335f9996aaSopenharmony_ci with build_utils.atomic_output(output) as f: 345f9996aaSopenharmony_ci build_utils.do_zip(inputs, f, base_dir) 355f9996aaSopenharmony_ci 365f9996aaSopenharmony_ci if options.depfile: 375f9996aaSopenharmony_ci build_utils.write_depfile(options.depfile, output) 385f9996aaSopenharmony_ci 395f9996aaSopenharmony_ci 405f9996aaSopenharmony_ciif __name__ == '__main__': 415f9996aaSopenharmony_ci sys.exit(main()) 42