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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/tools/make_version.py ('k') | tools/release/version.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/make_version.py
diff --git a/tools/make_version.py b/tools/make_version.py
new file mode 100644
index 0000000000000000000000000000000000000000..476ecdf037e7320a7046bce41c225c5e4f2b8cd3
--- /dev/null
+++ b/tools/make_version.py
@@ -0,0 +1,69 @@
+# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+#
+# This python script creates a version string in a C++ file.
+
+import sys
+import time
+from optparse import OptionParser
+import utils
+
+def debugLog(message):
+ print >> sys.stderr, message
+ sys.stderr.flush()
+
+def makeVersionString():
+ version_string = utils.GetVersion()
+ debugLog("Returning version string: %s " % version_string)
+ return version_string
+
+
+def makeFile(output_file, input_file):
+ version_cc_text = open(input_file).read()
+ version_string = makeVersionString()
+ version_cc_text = version_cc_text.replace("{{VERSION_STR}}",
+ version_string)
+ version_time = time.ctime(time.time())
+ version_cc_text = version_cc_text.replace("{{BUILD_TIME}}",
+ version_time)
+ open(output_file, 'w').write(version_cc_text)
+ return True
+
+
+def main(args):
+ try:
+ # Parse input.
+ parser = OptionParser()
+ parser.add_option("--output",
+ action="store", type="string",
+ help="output file name")
+ parser.add_option("--input",
+ action="store", type="string",
+ help="input template file")
+
+ (options, args) = parser.parse_args()
+ if not options.output:
+ sys.stderr.write('--output not specified\n')
+ return -1
+ if not len(options.input):
+ sys.stderr.write('--input not specified\n')
+ return -1
+
+ files = [ ]
+ for arg in args:
+ files.append(arg)
+
+ if not makeFile(options.output, options.input):
+ return -1
+
+ return 0
+ except Exception, inst:
+ sys.stderr.write('make_version.py exception\n')
+ sys.stderr.write(str(inst))
+ sys.stderr.write('\n')
+ return -1
+
+if __name__ == '__main__':
+ exit_code = main(sys.argv)
+ sys.exit(exit_code)
« 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