Checks snapshot validity using a hash of source file instead of a version string.

R=asiva@google.com, iposva@google.com

Review URL: https://codereview.chromium.org//558503002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40009 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
zra@google.com
2014-09-09 01:44:48 +00:00
parent 6559d6ee37
commit 3dfb90f59f
3 changed files with 37 additions and 2 deletions
+1
View File
@@ -16,6 +16,7 @@ class Version : public AllStatic {
private:
static const char* str_;
static const char* snapshot_hash_;
};
} // namespace dart
+2 -2
View File
@@ -28,10 +28,10 @@ const char* Version::String() {
const char* Version::SnapshotString() {
return str_;
return snapshot_hash_;
}
const char* Version::snapshot_hash_ = "{{SNAPSHOT_HASH}}";
const char* Version::str_ = "{{VERSION_STR}} ({{BUILD_TIME}})";
} // namespace dart
+34
View File
@@ -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 @@ def debugLog(message):
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 @@ def makeFile(output_file, input_file):
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