Chromium Code Reviews| Index: build/toolchain/gcc_compile_wrapper.py |
| diff --git a/build/toolchain/gcc_compile_wrapper.py b/build/toolchain/gcc_compile_wrapper.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..cea1af73af6e63f10526e2e5ac7ad3044d0f6c1b |
| --- /dev/null |
| +++ b/build/toolchain/gcc_compile_wrapper.py |
| @@ -0,0 +1,48 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Runs a compilation command. |
| + |
| +This script exists to avoid using complex shell commands in |
| +gcc_toolchain.gni's tool("cxx") and tool("cc") in case the host running the |
| +compiler does not have a POSIX-like shell (e.g. Windows). |
| +""" |
| + |
| +import argparse |
| +import sys |
| + |
| +import wrapper_utils |
| + |
| + |
| +def main(): |
| + parser = argparse.ArgumentParser(description=__doc__) |
| + parser.add_argument('--whitelist-file', |
| + help='File containing whitelisted resources for target.', |
| + metavar='FILE') |
| + parser.add_argument('--whitelist', action='store_true', |
| + help='Indicates that whitelisting should be performed.') |
| + parser.add_argument('command', nargs=argparse.REMAINDER, |
| + help='Compilation command') |
| + args = parser.parse_args() |
| + |
| + returncode, _, stderr = wrapper_utils.GetCommandOutput( |
| + wrapper_utils.CommandToRun(args.command)) |
| + if returncode != 0 or not args.whitelist: |
|
agrieve
2016/07/27 01:42:27
Need to write stderr before returning.
estevenson
2016/07/28 21:56:45
Done.
|
| + return returncode |
| + |
| + used_resources = wrapper_utils.GetResourceIdsInPragmaWarnings(stderr) |
| + stderr = wrapper_utils.FilterUnknownPragmas(stderr) |
| + if stderr: |
| + sys.stderr.write(stderr) |
| + |
| + if used_resources: |
|
agrieve
2016/07/27 01:42:27
If a file used to have a resource, and is changed
estevenson
2016/07/28 21:56:45
Done.
|
| + with open(args.whitelist_file, 'w') as f: |
| + f.write('\n'.join(str(resource) for resource in used_resources)) |
| + f.write('\n') |
| + |
| + return returncode |
| + |
| +if __name__ == "__main__": |
| + sys.exit(main()) |