| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Runs a compilation command. | |
| 7 | |
| 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 | |
| 10 compiler does not have a POSIX-like shell (e.g. Windows). | |
| 11 """ | |
| 12 | |
| 13 import argparse | |
| 14 import sys | |
| 15 | |
| 16 import wrapper_utils | |
| 17 | |
| 18 | |
| 19 def main(): | |
| 20 parser = argparse.ArgumentParser(description=__doc__) | |
| 21 parser.add_argument('--resource-whitelist', | |
| 22 help='Generate a resource whitelist for this target.', | |
| 23 metavar='PATH') | |
| 24 parser.add_argument('command', nargs=argparse.REMAINDER, | |
| 25 help='Compilation command') | |
| 26 args = parser.parse_args() | |
| 27 | |
| 28 returncode, stderr = wrapper_utils.CaptureCommandStderr( | |
| 29 wrapper_utils.CommandToRun(args.command)) | |
| 30 | |
| 31 used_resources = wrapper_utils.ExtractResourceIdsFromPragmaWarnings(stderr) | |
| 32 sys.stderr.write(stderr) | |
| 33 | |
| 34 if args.resource_whitelist: | |
| 35 with open(args.resource_whitelist, 'w') as f: | |
| 36 if used_resources: | |
| 37 f.write('\n'.join(str(resource) for resource in used_resources)) | |
| 38 f.write('\n') | |
| 39 | |
| 40 | |
| 41 return returncode | |
| 42 | |
| 43 if __name__ == "__main__": | |
| 44 sys.exit(main()) | |
| OLD | NEW |