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

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: 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..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():
« 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