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

Side by Side Diff: tools/make_version.py

Issue 11440010: Move runtime/tools/make_version.py to tools/ and use GetVersion from utils.py (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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/tools/make_version.py ('k') | tools/release/version.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # BSD-style license that can be found in the LICENSE file.
4 #
5 # This python script creates a version string in a C++ file.
6
7 import sys
8 import time
9 from optparse import OptionParser
10 import utils
11
12 def debugLog(message):
13 print >> sys.stderr, message
14 sys.stderr.flush()
15
16 def makeVersionString():
17 version_string = utils.GetVersion()
18 debugLog("Returning version string: %s " % version_string)
19 return version_string
20
21
22 def makeFile(output_file, input_file):
23 version_cc_text = open(input_file).read()
24 version_string = makeVersionString()
25 version_cc_text = version_cc_text.replace("{{VERSION_STR}}",
26 version_string)
27 version_time = time.ctime(time.time())
28 version_cc_text = version_cc_text.replace("{{BUILD_TIME}}",
29 version_time)
30 open(output_file, 'w').write(version_cc_text)
31 return True
32
33
34 def main(args):
35 try:
36 # Parse input.
37 parser = OptionParser()
38 parser.add_option("--output",
39 action="store", type="string",
40 help="output file name")
41 parser.add_option("--input",
42 action="store", type="string",
43 help="input template file")
44
45 (options, args) = parser.parse_args()
46 if not options.output:
47 sys.stderr.write('--output not specified\n')
48 return -1
49 if not len(options.input):
50 sys.stderr.write('--input not specified\n')
51 return -1
52
53 files = [ ]
54 for arg in args:
55 files.append(arg)
56
57 if not makeFile(options.output, options.input):
58 return -1
59
60 return 0
61 except Exception, inst:
62 sys.stderr.write('make_version.py exception\n')
63 sys.stderr.write(str(inst))
64 sys.stderr.write('\n')
65 return -1
66
67 if __name__ == '__main__':
68 exit_code = main(sys.argv)
69 sys.exit(exit_code)
OLDNEW
« no previous file with comments | « runtime/tools/make_version.py ('k') | tools/release/version.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698