Index: build/toolchain/win/setup_toolchain.py |
diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py |
index a91043710d58befb140d0aa12437e331c46e9adf..0d0975dfe3a6444719fea252becfd87b37448069 100644 |
--- a/build/toolchain/win/setup_toolchain.py |
+++ b/build/toolchain/win/setup_toolchain.py |
@@ -46,7 +46,7 @@ |
if re.match(envvar + '=', line.lower()): |
var, setting = line.split('=', 1) |
if envvar == 'path': |
- # Our own rules (for running tool_wrapper.py) and other actions in |
+ # Our own rules (for running gyp-win-tool) and other actions in |
# Chromium rely on python being in the path. Add the path to this |
# python here so that if it's not in the path when ninja is run |
# later, python will still be found. |
@@ -147,16 +147,45 @@ |
return block |
+def _CopyTool(source_path): |
+ """Copies the given tool to the current directory, including a warning not |
+ to edit it.""" |
+ with open(source_path) as source_file: |
+ tool_source = source_file.readlines() |
+ |
+ # Add header and write it out to the current directory (which should be the |
+ # root build dir). Don't write the file if a matching file already exists |
+ # because that causes a cascade of unnecessary rebuilds. |
+ match = False |
+ contents = ''.join([tool_source[0], |
+ '# Generated by setup_toolchain.py do not edit.\n'] |
+ + tool_source[1:]) |
+ out_path = 'gyp-win-tool' |
+ try: |
+ with open(out_path, 'rb') as read_tool_file: |
+ existing_contents = read_tool_file.read() |
+ if existing_contents == contents: |
+ match = True |
+ except: |
+ pass |
+ if not match: |
+ with open(out_path, 'wb') as write_tool_file: |
+ write_tool_file.write(contents) |
+ |
+ |
def main(): |
- if len(sys.argv) != 6: |
+ if len(sys.argv) != 7: |
print('Usage setup_toolchain.py ' |
- '<visual studio path> <win sdk path> ' |
+ '<visual studio path> <win tool path> <win sdk path> ' |
'<runtime dirs> <target_cpu> <include prefix>') |
sys.exit(2) |
- win_sdk_path = sys.argv[2] |
- runtime_dirs = sys.argv[3] |
- target_cpu = sys.argv[4] |
- include_prefix = sys.argv[5] |
+ tool_source = sys.argv[2] |
+ win_sdk_path = sys.argv[3] |
+ runtime_dirs = sys.argv[4] |
+ target_cpu = sys.argv[5] |
+ include_prefix = sys.argv[6] |
+ |
+ _CopyTool(tool_source) |
cpus = ('x86', 'x64') |
assert target_cpu in cpus |