Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: build/toolchain/gcc_ar_wrapper.py

Issue 2175413004: Enable whitelist generation for all builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + change output dir Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/toolchain/gcc_compile_wrapper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs the 'ar' command after removing its output file first. 6 """Runs the 'ar' command after removing its output file first.
7 7
8 This script is invoked like: 8 This script is invoked like:
9 python gcc_ar_wrapper.py --ar=$AR --output=$OUT $OP $INPUTS 9 python gcc_ar_wrapper.py --ar=$AR --output=$OUT $OP $INPUTS
10 to do the equivalent of: 10 to do the equivalent of:
11 rm -f $OUT && $AR $OP $OUT $INPUTS 11 rm -f $OUT && $AR $OP $OUT $INPUTS
12 """ 12 """
13 13
14 import argparse 14 import argparse
15 import os 15 import os
16 import subprocess 16 import subprocess
17 import sys 17 import sys
18 18
19 19 import wrapper_utils
20 # When running on a Windows host and using a toolchain whose tools are
21 # actually wrapper scripts (i.e. .bat files on Windows) rather than binary
22 # executables, the "command" to run has to be prefixed with this magic.
23 # The GN toolchain definitions take care of that for when GN/Ninja is
24 # running the tool directly. When that command is passed in to this
25 # script, it appears as a unitary string but needs to be split up so that
26 # just 'cmd' is the actual command given to Python's subprocess module.
27 BAT_PREFIX = 'cmd /c call '
28
29 def CommandToRun(command):
30 if command[0].startswith(BAT_PREFIX):
31 command = command[0].split(None, 3) + command[1:]
32 return command
33 20
34 21
35 def main(): 22 def main():
36 parser = argparse.ArgumentParser(description=__doc__) 23 parser = argparse.ArgumentParser(description=__doc__)
37 parser.add_argument('--ar', 24 parser.add_argument('--ar',
38 required=True, 25 required=True,
39 help='The ar binary to run', 26 help='The ar binary to run',
40 metavar='PATH') 27 metavar='PATH')
41 parser.add_argument('--output', 28 parser.add_argument('--output',
42 required=True, 29 required=True,
43 help='Output archive file', 30 help='Output archive file',
44 metavar='ARCHIVE') 31 metavar='ARCHIVE')
45 parser.add_argument('--plugin', 32 parser.add_argument('--plugin',
46 help='Load plugin') 33 help='Load plugin')
34 parser.add_argument('--resource-whitelist',
35 help='Merge all resource whitelists into a single file.',
36 metavar='PATH')
47 parser.add_argument('operation', 37 parser.add_argument('operation',
48 help='Operation on the archive') 38 help='Operation on the archive')
49 parser.add_argument('inputs', nargs='+', 39 parser.add_argument('inputs', nargs='+',
50 help='Input files') 40 help='Input files')
51 args = parser.parse_args() 41 args = parser.parse_args()
52 42
43 if args.resource_whitelist:
44 whitelist_candidates = wrapper_utils.ResolveRspLinks(args.inputs)
45 wrapper_utils.CombineResourceWhitelists(
46 whitelist_candidates, args.resource_whitelist)
47
53 command = [args.ar, args.operation] 48 command = [args.ar, args.operation]
54 if args.plugin is not None: 49 if args.plugin is not None:
55 command += ['--plugin', args.plugin] 50 command += ['--plugin', args.plugin]
56 command.append(args.output) 51 command.append(args.output)
57 command += args.inputs 52 command += args.inputs
58 53
59 # Remove the output file first. 54 # Remove the output file first.
60 try: 55 try:
61 os.remove(args.output) 56 os.remove(args.output)
62 except OSError as e: 57 except OSError as e:
63 if e.errno != os.errno.ENOENT: 58 if e.errno != os.errno.ENOENT:
64 raise 59 raise
65 60
66 # Now just run the ar command. 61 # Now just run the ar command.
67 return subprocess.call(CommandToRun(command)) 62 return subprocess.call(wrapper_utils.CommandToRun(command))
68 63
69 64
70 if __name__ == "__main__": 65 if __name__ == "__main__":
71 sys.exit(main()) 66 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/toolchain/gcc_compile_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698