4
4
#
5
5
# This python script creates a version string in a C++ file.
6
6
7
+ import hashlib
8
+ import os
7
9
import sys
8
10
import time
9
11
from optparse import OptionParser
@@ -13,12 +15,41 @@ def debugLog(message):
13
15
print >> sys .stderr , message
14
16
sys .stderr .flush ()
15
17
18
+ # When these files change, snapshots created by the VM are potentially no longer
19
+ # backwards-compatible.
20
+ VM_SNAPSHOT_FILES = [
21
+ # Header files.
22
+ 'datastream.h' ,
23
+ 'object.h' ,
24
+ 'raw_object.h' ,
25
+ 'snapshot.h' ,
26
+ 'snapshot_ids.h' ,
27
+ 'symbols.h' ,
28
+ # Source files.
29
+ 'dart.cc' ,
30
+ 'dart_api_impl.cc' ,
31
+ 'object.cc' ,
32
+ 'raw_object.cc' ,
33
+ 'raw_object_snapshot.cc' ,
34
+ 'snapshot.cc' ,
35
+ 'symbols.cc' ,
36
+ ]
37
+
16
38
def makeVersionString ():
17
39
version_string = utils .GetVersion ()
18
40
debugLog ("Returning version string: %s " % version_string )
19
41
return version_string
20
42
21
43
44
+ def makeSnapshotHashString ():
45
+ vmhash = hashlib .md5 ()
46
+ for vmfilename in VM_SNAPSHOT_FILES :
47
+ vmfilepath = os .path .join (utils .DART_DIR , 'runtime' , 'vm' , vmfilename )
48
+ with open (vmfilepath ) as vmfile :
49
+ vmhash .update (vmfile .read ())
50
+ return vmhash .hexdigest ()
51
+
52
+
22
53
def makeFile (output_file , input_file ):
23
54
version_cc_text = open (input_file ).read ()
24
55
version_string = makeVersionString ()
@@ -27,6 +58,9 @@ def makeFile(output_file, input_file):
27
58
version_time = time .ctime (time .time ())
28
59
version_cc_text = version_cc_text .replace ("{{BUILD_TIME}}" ,
29
60
version_time )
61
+ snapshot_hash = makeSnapshotHashString ()
62
+ version_cc_text = version_cc_text .replace ("{{SNAPSHOT_HASH}}" ,
63
+ snapshot_hash )
30
64
open (output_file , 'w' ).write (version_cc_text )
31
65
return True
32
66
0 commit comments