OLD | NEW |
---|---|
1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, 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 file contains a set of utilities functions used by other Python-based | 5 # This file contains a set of utilities functions used by other Python-based |
6 # scripts. | 6 # scripts. |
7 | 7 |
8 import commands | 8 import commands |
9 import os | 9 import os |
10 import platform | 10 import platform |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 if mode: | 227 if mode: |
228 build_root = os.path.join(build_root, GetBuildConf(mode, arch)) | 228 build_root = os.path.join(build_root, GetBuildConf(mode, arch)) |
229 return build_root | 229 return build_root |
230 | 230 |
231 def GetBaseDir(): | 231 def GetBaseDir(): |
232 return BASE_DIR | 232 return BASE_DIR |
233 | 233 |
234 # Return the base part of the version, Major.Minor.Build.Patch, | 234 # Return the base part of the version, Major.Minor.Build.Patch, |
235 # without the _revision addition | 235 # without the _revision addition |
236 def GetShortVersion(): | 236 def GetShortVersion(): |
237 (major, minor, build, patch) = ReadVersionFile() | 237 (channel, major, minor, build, patch) = ReadVersionFile() |
238 # TODO(kustermann/ricow): Add the channel to the version string. | |
Bob Nystrom
2013/11/25 17:41:59
What would having the channel in the version name
kustermann
2013/11/26 14:17:32
We haven't decided anything, I just put in this TO
| |
238 return '%s.%s.%s.%s' % (major, minor, build, patch) | 239 return '%s.%s.%s.%s' % (major, minor, build, patch) |
239 | 240 |
240 | 241 |
241 def GetVersion(): | 242 def GetVersion(): |
242 version_tuple = ReadVersionFile() | 243 version_tuple = ReadVersionFile() |
243 if not version_tuple: | 244 if not version_tuple: |
244 return None | 245 return None |
245 | 246 |
246 (major, minor, build, patch) = version_tuple | 247 (channel, major, minor, build, patch) = version_tuple |
247 revision = GetSVNRevision() | 248 revision = GetSVNRevision() |
248 user = GetUserName() | 249 user = GetUserName() |
249 # We don't add username to release builds (or any builds on the bots) | 250 # We don't add username to release builds (or any builds on the bots) |
250 if user == 'chrome-bot': | 251 if user == 'chrome-bot': |
251 user = '' | 252 user = '' |
252 | 253 |
253 user_string = '' | 254 user_string = '' |
254 revision_string = '' | 255 revision_string = '' |
255 if user: | 256 if user: |
256 user_string = '_%s' % user | 257 user_string = '_%s' % user |
257 if revision: | 258 if revision: |
258 revision_string = '_r%s' % revision | 259 revision_string = '_r%s' % revision |
259 | 260 |
261 # TODO(kustermann/ricow): Add the channel to the version string. | |
260 return ("%s.%s.%s.%s%s%s" % | 262 return ("%s.%s.%s.%s%s%s" % |
261 (major, minor, build, patch, revision_string, user_string)) | 263 (major, minor, build, patch, revision_string, user_string)) |
262 | 264 |
263 def GetUserName(): | 265 def GetUserName(): |
264 key = 'USER' | 266 key = 'USER' |
265 if sys.platform == 'win32': | 267 if sys.platform == 'win32': |
266 key = 'USERNAME' | 268 key = 'USERNAME' |
267 return os.environ.get(key, '') | 269 return os.environ.get(key, '') |
268 | 270 |
269 def ReadVersionFile(): | 271 def ReadVersionFile(): |
270 version_file = os.path.join(DART_DIR, 'tools', 'VERSION') | 272 version_file = os.path.join(DART_DIR, 'tools', 'VERSION') |
271 try: | 273 try: |
272 fd = open(version_file) | 274 fd = open(version_file) |
273 content = fd.read() | 275 content = fd.read() |
274 fd.close() | 276 fd.close() |
275 except: | 277 except: |
276 print "Warning: Couldn't read VERSION file (%s)" % version_file | 278 print "Warning: Couldn't read VERSION file (%s)" % version_file |
277 return None | 279 return None |
278 major_match = re.search('MAJOR (\d+)', content) | 280 channel_match = re.search( |
279 minor_match = re.search('MINOR (\d+)', content) | 281 '^CHANNEL ([A-Za-z0-9]+)$', content, flags=re.MULTILINE) |
280 build_match = re.search('BUILD (\d+)', content) | 282 major_match = re.search('^MAJOR (\d+)$', content, flags=re.MULTILINE) |
281 patch_match = re.search('PATCH (\d+)', content) | 283 minor_match = re.search('^MINOR (\d+)$', content, flags=re.MULTILINE) |
282 if major_match and minor_match and build_match and patch_match: | 284 build_match = re.search('^BUILD (\d+)$', content, flags=re.MULTILINE) |
283 return (major_match.group(1), minor_match.group(1), build_match.group(1), | 285 patch_match = re.search('^PATCH (\d+)$', content, flags=re.MULTILINE) |
284 patch_match.group(1)) | 286 if (channel_match and |
287 major_match and | |
288 minor_match and | |
289 build_match and | |
290 patch_match): | |
291 return (channel_match.group(1), major_match.group(1), minor_match.group(1), | |
292 build_match.group(1), patch_match.group(1)) | |
285 else: | 293 else: |
286 print "Warning: VERSION file (%s) has wrong format" % version_file | 294 print "Warning: VERSION file (%s) has wrong format" % version_file |
287 return None | 295 return None |
288 | 296 |
289 def GetSVNRevision(): | 297 def GetSVNRevision(): |
290 # FIXME(kustermann): Make this work for newer SVN versions as well (where | 298 # FIXME(kustermann): Make this work for newer SVN versions as well (where |
291 # we've got only one '.svn' directory) | 299 # we've got only one '.svn' directory) |
292 custom_env = dict(os.environ) | 300 custom_env = dict(os.environ) |
293 custom_env['LC_MESSAGES'] = 'en_GB' | 301 custom_env['LC_MESSAGES'] = 'en_GB' |
294 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, | 302 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 os.chdir(self._working_directory) | 492 os.chdir(self._working_directory) |
485 | 493 |
486 def __exit__(self, *_): | 494 def __exit__(self, *_): |
487 print "Enter directory = ", self._old_cwd | 495 print "Enter directory = ", self._old_cwd |
488 os.chdir(self._old_cwd) | 496 os.chdir(self._old_cwd) |
489 | 497 |
490 | 498 |
491 if __name__ == "__main__": | 499 if __name__ == "__main__": |
492 import sys | 500 import sys |
493 Main(sys.argv) | 501 Main(sys.argv) |
OLD | NEW |