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

Unified Diff: tools/gypv8sh.py

Issue 1129893004: Avoid clobbering generated files if the content hasn't changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « chrome/browser/resources/chromeos/chromevox/tools/generate_deps.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gypv8sh.py
diff --git a/tools/gypv8sh.py b/tools/gypv8sh.py
index 9724ed4b1a6ed12b2b68a91748e049f231ba0e6f..2a1fada8a5729fd033a26e368ae2546f5d3a5b28 100755
--- a/tools/gypv8sh.py
+++ b/tools/gypv8sh.py
@@ -15,6 +15,16 @@ import sys
import shutil
+def HasSameContent(filename, content):
+ '''Returns true if the given file is readable and has the given content.'''
+ try:
+ with open(filename) as file:
+ return file.read() == content
+ except:
+ # Ignore all errors and fall back on a safe bet.
+ return False
+
+
def main ():
parser = optparse.OptionParser()
parser.set_usage(
@@ -55,8 +65,9 @@ def main ():
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0)
out, err = p.communicate()
- with open(cxxoutfile, 'wb') as f:
- f.write(out)
+ if not HasSameContent(cxxoutfile, out):
+ with open(cxxoutfile, 'wb') as f:
+ f.write(out)
shutil.copyfile(inputfile, jsoutfile)
except Exception, ex:
if os.path.exists(cxxoutfile):
@@ -67,4 +78,4 @@ def main ():
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main())
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/tools/generate_deps.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698