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

Side by Side Diff: tools/make_version.py

Issue 850053005: Disables printing a version string to the console for GN build. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file. 3 # BSD-style license that can be found in the LICENSE file.
4 # 4 #
5 # This python script creates a version string in a C++ file. 5 # This python script creates a version string in a C++ file.
6 6
7 import hashlib 7 import hashlib
8 import os 8 import os
9 import sys 9 import sys
10 import time 10 import time
(...skipping 17 matching lines...) Expand all
28 # Source files. 28 # Source files.
29 'dart.cc', 29 'dart.cc',
30 'dart_api_impl.cc', 30 'dart_api_impl.cc',
31 'object.cc', 31 'object.cc',
32 'raw_object.cc', 32 'raw_object.cc',
33 'raw_object_snapshot.cc', 33 'raw_object_snapshot.cc',
34 'snapshot.cc', 34 'snapshot.cc',
35 'symbols.cc', 35 'symbols.cc',
36 ] 36 ]
37 37
38 def makeVersionString(): 38 def makeVersionString(quiet):
39 version_string = utils.GetVersion() 39 version_string = utils.GetVersion()
40 debugLog("Returning version string: %s " % version_string) 40 if not quiet:
41 debugLog("Returning version string: %s " % version_string)
41 return version_string 42 return version_string
42 43
43 44
44 def makeSnapshotHashString(): 45 def makeSnapshotHashString():
45 vmhash = hashlib.md5() 46 vmhash = hashlib.md5()
46 for vmfilename in VM_SNAPSHOT_FILES: 47 for vmfilename in VM_SNAPSHOT_FILES:
47 vmfilepath = os.path.join(utils.DART_DIR, 'runtime', 'vm', vmfilename) 48 vmfilepath = os.path.join(utils.DART_DIR, 'runtime', 'vm', vmfilename)
48 with open(vmfilepath) as vmfile: 49 with open(vmfilepath) as vmfile:
49 vmhash.update(vmfile.read()) 50 vmhash.update(vmfile.read())
50 return vmhash.hexdigest() 51 return vmhash.hexdigest()
51 52
52 53
53 def makeFile(output_file, input_file): 54 def makeFile(quiet, output_file, input_file):
54 version_cc_text = open(input_file).read() 55 version_cc_text = open(input_file).read()
55 version_string = makeVersionString() 56 version_string = makeVersionString(quiet)
56 version_cc_text = version_cc_text.replace("{{VERSION_STR}}", 57 version_cc_text = version_cc_text.replace("{{VERSION_STR}}",
57 version_string) 58 version_string)
58 version_time = time.ctime(time.time()) 59 version_time = time.ctime(time.time())
59 version_cc_text = version_cc_text.replace("{{BUILD_TIME}}", 60 version_cc_text = version_cc_text.replace("{{BUILD_TIME}}",
60 version_time) 61 version_time)
61 snapshot_hash = makeSnapshotHashString() 62 snapshot_hash = makeSnapshotHashString()
62 version_cc_text = version_cc_text.replace("{{SNAPSHOT_HASH}}", 63 version_cc_text = version_cc_text.replace("{{SNAPSHOT_HASH}}",
63 snapshot_hash) 64 snapshot_hash)
64 open(output_file, 'w').write(version_cc_text) 65 open(output_file, 'w').write(version_cc_text)
65 return True 66 return True
66 67
67 68
68 def main(args): 69 def main(args):
69 try: 70 try:
70 # Parse input. 71 # Parse input.
71 parser = OptionParser() 72 parser = OptionParser()
73 parser.add_option("-q", "--quiet",
74 action="store_true", default=False,
75 help="disable console output")
72 parser.add_option("--output", 76 parser.add_option("--output",
73 action="store", type="string", 77 action="store", type="string",
74 help="output file name") 78 help="output file name")
75 parser.add_option("--input", 79 parser.add_option("--input",
76 action="store", type="string", 80 action="store", type="string",
77 help="input template file") 81 help="input template file")
78 82
79 (options, args) = parser.parse_args() 83 (options, args) = parser.parse_args()
80 if not options.output: 84 if not options.output:
81 sys.stderr.write('--output not specified\n') 85 sys.stderr.write('--output not specified\n')
82 return -1 86 return -1
83 if not len(options.input): 87 if not len(options.input):
84 sys.stderr.write('--input not specified\n') 88 sys.stderr.write('--input not specified\n')
85 return -1 89 return -1
86 90
87 files = [] 91 files = []
88 for arg in args: 92 for arg in args:
89 files.append(arg) 93 files.append(arg)
90 94
91 if not makeFile(options.output, options.input): 95 if not makeFile(options.quiet, options.output, options.input):
92 return -1 96 return -1
93 97
94 return 0 98 return 0
95 except Exception, inst: 99 except Exception, inst:
96 sys.stderr.write('make_version.py exception\n') 100 sys.stderr.write('make_version.py exception\n')
97 sys.stderr.write(str(inst)) 101 sys.stderr.write(str(inst))
98 sys.stderr.write('\n') 102 sys.stderr.write('\n')
99 return -1 103 return -1
100 104
101 if __name__ == '__main__': 105 if __name__ == '__main__':
102 exit_code = main(sys.argv) 106 exit_code = main(sys.argv)
103 sys.exit(exit_code) 107 sys.exit(exit_code)
OLDNEW
« no previous file with comments | « runtime/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698