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

Side by Side Diff: runtime/tools/make_version.py

Issue 11103029: - Windows' not Unix. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « no previous file | 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 os 7 import os
8 import pwd 8 import pwd
ricow1 2012/10/11 08:45:30 You are still importing it
9 import sys 9 import sys
10 import subprocess 10 import subprocess
11 import getpass
11 from os.path import join 12 from os.path import join
12 import time 13 import time
13 from optparse import OptionParser 14 from optparse import OptionParser
14 15
15 def getVersionPart(version_file, part): 16 def getVersionPart(version_file, part):
16 proc = subprocess.Popen(['awk', 17 proc = subprocess.Popen(['awk',
17 '$1 == "%s" {print $2}' % (part), 18 '$1 == "%s" {print $2}' % (part),
ricow1 2012/10/11 08:45:30 I don't think this will work either
18 version_file], 19 version_file],
19 stdout=subprocess.PIPE, 20 stdout=subprocess.PIPE,
20 stderr=subprocess.STDOUT) 21 stderr=subprocess.STDOUT)
21 return proc.communicate()[0].split('\n')[0] 22 return proc.communicate()[0].split('\n')[0]
22 23
23 def getRevision(): 24 def getRevision():
24 is_svn = True 25 is_svn = True
25 if os.path.exists('.svn'): 26 if os.path.exists('.svn'):
26 cmd = ['svn', 'info'] 27 cmd = ['svn', 'info']
27 else: 28 else:
28 cmd = ['git', 'svn', 'info'] 29 cmd = ['git', 'svn', 'info']
29 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 30 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
30 return proc.communicate()[0].split('\n')[4].split(' ')[1] 31 return proc.communicate()[0].split('\n')[4].split(' ')[1]
31 32
32 def makeVersionString(version_file): 33 def makeVersionString(version_file):
33 major = getVersionPart(version_file, 'MAJOR') 34 major = getVersionPart(version_file, 'MAJOR')
34 minor = getVersionPart(version_file, 'MINOR') 35 minor = getVersionPart(version_file, 'MINOR')
35 build = getVersionPart(version_file, 'BUILD') 36 build = getVersionPart(version_file, 'BUILD')
36 patch = getVersionPart(version_file, 'PATCH') 37 patch = getVersionPart(version_file, 'PATCH')
37 revision = getRevision() 38 revision = getRevision()
38 user = pwd.getpwuid(os.getuid())[0] 39 user = getpass.getuser()
39 return '%s.%s.%s.%s_%s_%s' % (major, minor, build, patch, revision, user) 40 return '%s.%s.%s.%s_%s_%s' % (major, minor, build, patch, revision, user)
40 41
41 def makeFile(output_file, input_file, version_file): 42 def makeFile(output_file, input_file, version_file):
42 version_cc_text = open(input_file).read() 43 version_cc_text = open(input_file).read()
43 version_cc_text = version_cc_text.replace("{{VERSION_STR}}", 44 version_cc_text = version_cc_text.replace("{{VERSION_STR}}",
44 makeVersionString(version_file)) 45 makeVersionString(version_file))
45 version_cc_text = version_cc_text.replace("{{BUILD_TIME}}", 46 version_cc_text = version_cc_text.replace("{{BUILD_TIME}}",
46 time.ctime(time.time())) 47 time.ctime(time.time()))
47 open(output_file, 'w').write(version_cc_text) 48 open(output_file, 'w').write(version_cc_text)
48 return True 49 return True
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 return 0 83 return 0
83 except Exception, inst: 84 except Exception, inst:
84 sys.stderr.write('make_version.py exception\n') 85 sys.stderr.write('make_version.py exception\n')
85 sys.stderr.write(str(inst)) 86 sys.stderr.write(str(inst))
86 sys.stderr.write('\n') 87 sys.stderr.write('\n')
87 return -1 88 return -1
88 89
89 if __name__ == '__main__': 90 if __name__ == '__main__':
90 sys.exit(main(sys.argv)) 91 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698