Chromium Code Reviews| Index: build/toolchain/win/setup_toolchain.py |
| diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py |
| index a766cc1541573c8527e4c6c2efd6b72e0012177e..df674a8248af189c518fdce2e9ff8d945be77d1b 100644 |
| --- a/build/toolchain/win/setup_toolchain.py |
| +++ b/build/toolchain/win/setup_toolchain.py |
| @@ -147,11 +147,22 @@ def _CopyTool(source_path): |
| tool_source = source_file.readlines() |
| # Add header and write it out to the current directory (which should be the |
| - # root build dir). |
| - with open("gyp-win-tool", 'w') as tool_file: |
| - tool_file.write(''.join([tool_source[0], |
| - '# Generated by setup_toolchain.py do not edit.\n'] |
| - + tool_source[1:])) |
| + # 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:]) |
| + try: |
|
scottmg
2016/04/29 02:11:40
filename = 'gyp-win-tool'
and use in both places.
brucedawson
2016/04/29 17:25:28
Done.
|
| + with open("gyp-win-tool", 'r') as tool_file: |
|
scottmg
2016/04/29 02:11:40
" -> ' while you're here (and below).
scottmg
2016/04/29 02:11:40
'rb' here, and 'wb' below since we're sort of doin
scottmg
2016/04/29 02:11:40
Maybe call this read_tool_file and the one below w
brucedawson
2016/04/29 17:25:28
Yeah, I noticed that and wondered if there was som
brucedawson
2016/04/29 17:25:28
Done.
brucedawson
2016/04/29 17:25:28
Done.
|
| + existing_contents = tool_file.read() |
| + if existing_contents == contents: |
| + match = True |
| + except: |
| + pass |
| + if not match: |
| + with open("gyp-win-tool", 'w') as tool_file: |
| + tool_file.write(contents) |
| def main(): |