Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4274)

Unified Diff: build/toolchain/win/setup_toolchain.py

Issue 1932133002: Only write gyp-win-tool when needed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better compatibility with mac version Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e13940964bbad6bd6484ca3488477221590a9183 100644
--- a/build/toolchain/win/setup_toolchain.py
+++ b/build/toolchain/win/setup_toolchain.py
@@ -147,11 +147,23 @@ 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:])
+ 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():
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698