OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 a compilation command. | 6 """Runs a compilation command. |
7 | 7 |
8 This script exists to avoid using complex shell commands in | 8 This script exists to avoid using complex shell commands in |
9 gcc_toolchain.gni's tool("cxx") and tool("cc") in case the host running the | 9 gcc_toolchain.gni's tool("cxx") and tool("cc") in case the host running the |
10 compiler does not have a POSIX-like shell (e.g. Windows). | 10 compiler does not have a POSIX-like shell (e.g. Windows). |
11 """ | 11 """ |
12 | 12 |
13 import argparse | 13 import argparse |
14 import sys | 14 import sys |
15 | 15 |
16 import wrapper_utils | 16 import wrapper_utils |
17 | 17 |
18 | 18 |
19 def main(): | 19 def main(): |
20 parser = argparse.ArgumentParser(description=__doc__) | 20 parser = argparse.ArgumentParser(description=__doc__) |
21 parser.add_argument('--resource-whitelist', | 21 parser.add_argument('--resource-whitelist', |
22 help='Generate a resource whitelist for this target.', | 22 help='Generate a resource whitelist for this target.', |
23 metavar='PATH') | 23 metavar='PATH') |
24 parser.add_argument('command', nargs=argparse.REMAINDER, | 24 parser.add_argument('command', nargs=argparse.REMAINDER, |
25 help='Compilation command') | 25 help='Compilation command') |
26 args = parser.parse_args() | 26 args = parser.parse_args() |
27 | 27 |
28 returncode, stderr = wrapper_utils.CaptureCommandStderr( | 28 returncode = wrapper_utils.RunCommand( |
29 wrapper_utils.CommandToRun(args.command)) | 29 wrapper_utils.CommandToRun(args.command)) |
30 | 30 |
31 used_resources = wrapper_utils.ExtractResourceIdsFromPragmaWarnings(stderr) | 31 used_resources = wrapper_utils.ExtractResourceIdsFromPragmaWarnings(stderr) |
Nico
2017/01/24 21:41:33
isn't this broken now? this needs stderr?
Kevin M
2017/01/24 21:46:18
Done.
| |
32 sys.stderr.write(stderr) | |
33 | 32 |
34 if args.resource_whitelist: | 33 if args.resource_whitelist: |
35 with open(args.resource_whitelist, 'w') as f: | 34 with open(args.resource_whitelist, 'w') as f: |
36 if used_resources: | 35 if used_resources: |
37 f.write('\n'.join(str(resource) for resource in used_resources)) | 36 f.write('\n'.join(str(resource) for resource in used_resources)) |
38 f.write('\n') | 37 f.write('\n') |
39 | 38 |
40 return returncode | 39 return returncode |
41 | 40 |
42 if __name__ == "__main__": | 41 if __name__ == "__main__": |
43 sys.exit(main()) | 42 sys.exit(main()) |
OLD | NEW |