Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
|
Michael Achenbach
2017/04/18 13:46:04
nit: 2017
| |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Runs the 'ar' command after removing its output file first. | |
| 7 | |
| 8 This script is invoked like: | |
| 9 python gcc_ar_wrapper.py --ar=$AR --output=$OUT $OP $INPUTS | |
| 10 to do the equivalent of: | |
| 11 rm -f $OUT && $AR $OP $OUT $INPUTS | |
| 12 """ | |
| 13 | |
| 14 import argparse | |
| 15 import os | |
| 16 import subprocess | |
| 17 import sys | |
| 18 | |
| 19 import wrapper_utils | |
| 20 | |
| 21 | |
| 22 def main(): | |
| 23 parser = argparse.ArgumentParser(description=__doc__) | |
| 24 parser.add_argument('--ar', | |
| 25 required=True, | |
| 26 help='The ar binary to run', | |
| 27 metavar='PATH') | |
| 28 parser.add_argument('--output', | |
| 29 required=True, | |
| 30 help='Output archive file', | |
| 31 metavar='ARCHIVE') | |
| 32 parser.add_argument('--plugin', | |
| 33 help='Load plugin') | |
| 34 parser.add_argument('--resource-whitelist', | |
|
Michael Achenbach
2017/04/18 13:46:04
nit: This is unused. Not sure if relevant. The ori
| |
| 35 help='Merge all resource whitelists into a single file.', | |
| 36 metavar='PATH') | |
| 37 parser.add_argument('operation', | |
| 38 help='Operation on the archive') | |
| 39 parser.add_argument('inputs', nargs='+', | |
| 40 help='Input files') | |
| 41 args = parser.parse_args() | |
| 42 | |
| 43 # The @file feature is not avaliable on ar for AIX. For linux (and other posix | |
| 44 # like systems), the @file_name option reads the contents of file_name as | |
| 45 # command line arguments. For AIX we must parse these (rsp files) manually. | |
| 46 # read rspfile. | |
| 47 parsed_as_command_line_inputs = wrapper_utils.ResolveRspLinks(args.inputs) | |
| 48 command = [args.ar, '-X64', args.operation] | |
| 49 | |
| 50 if args.plugin is not None: | |
| 51 command += ['--plugin', args.plugin] | |
| 52 command.append(args.output) | |
| 53 command += parsed_as_command_line_inputs | |
| 54 | |
| 55 # Remove the output file first. | |
| 56 try: | |
| 57 os.remove(args.output) | |
| 58 except OSError as e: | |
| 59 if e.errno != os.errno.ENOENT: | |
| 60 raise | |
| 61 | |
| 62 # Now just run the ar command. | |
| 63 return subprocess.call(wrapper_utils.CommandToRun(command)) | |
| 64 | |
| 65 | |
| 66 if __name__ == "__main__": | |
| 67 sys.exit(main()) | |
| OLD | NEW |