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

Unified Diff: tools/make_version.py

Issue 558503002: Checks snapshot validity using a hash of source file instead of a version string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 | « runtime/vm/version_in.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/make_version.py
===================================================================
--- tools/make_version.py (revision 39997)
+++ tools/make_version.py (working copy)
@@ -4,6 +4,8 @@
#
# This python script creates a version string in a C++ file.
+import hashlib
+import os
import sys
import time
from optparse import OptionParser
@@ -13,12 +15,41 @@
print >> sys.stderr, message
sys.stderr.flush()
+# When these files change, snapshots created by the VM are potentially no longer
+# backwards-compatible.
+VM_SNAPSHOT_FILES=[
+ # Header files.
+ 'datastream.h',
+ 'object.h',
+ 'raw_object.h',
+ 'snapshot.h',
+ 'snapshot_ids.h',
+ 'symbols.h',
+ # Source files.
+ 'dart.cc',
+ 'dart_api_impl.cc',
+ 'object.cc',
+ 'raw_object.cc',
+ 'raw_object_snapshot.cc',
+ 'snapshot.cc',
+ 'symbols.cc',
+]
+
def makeVersionString():
version_string = utils.GetVersion()
debugLog("Returning version string: %s " % version_string)
return version_string
+def makeSnapshotHashString():
+ vmhash = hashlib.md5()
+ for vmfilename in VM_SNAPSHOT_FILES:
+ vmfilepath = os.path.join(utils.DART_DIR, 'runtime', 'vm', vmfilename)
+ with open(vmfilepath) as vmfile:
+ vmhash.update(vmfile.read())
+ return vmhash.hexdigest()
+
+
def makeFile(output_file, input_file):
version_cc_text = open(input_file).read()
version_string = makeVersionString()
@@ -27,6 +58,9 @@
version_time = time.ctime(time.time())
version_cc_text = version_cc_text.replace("{{BUILD_TIME}}",
version_time)
+ snapshot_hash = makeSnapshotHashString()
+ version_cc_text = version_cc_text.replace("{{SNAPSHOT_HASH}}",
+ snapshot_hash)
open(output_file, 'w').write(version_cc_text)
return True
« no previous file with comments | « runtime/vm/version_in.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698