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

Side by Side Diff: tools/utils.py

Issue 1359293002: Move VERSION file location into top level variable (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« 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) 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 datetime 9 import datetime
10 import json 10 import json
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 'mips': 'mips', 233 'mips': 'mips',
234 'simarm': 'ia32', 234 'simarm': 'ia32',
235 'simarmv5te': 'ia32', 235 'simarmv5te': 'ia32',
236 'simmips': 'ia32', 236 'simmips': 'ia32',
237 'simarm64': 'ia32', 237 'simarm64': 'ia32',
238 } 238 }
239 239
240 ARCH_GUESS = GuessArchitecture() 240 ARCH_GUESS = GuessArchitecture()
241 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..')) 241 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..'))
242 DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..')) 242 DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..'))
243 VERSION_FILE = os.path.join(DART_DIR, 'tools', 'VERSION')
243 244
244 def GetBuildbotGSUtilPath(): 245 def GetBuildbotGSUtilPath():
245 gsutil = '/b/build/scripts/slave/gsutil' 246 gsutil = '/b/build/scripts/slave/gsutil'
246 if platform.system() == 'Windows': 247 if platform.system() == 'Windows':
247 gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil' 248 gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil'
248 return gsutil 249 return gsutil
249 250
250 def GetBuildMode(mode): 251 def GetBuildMode(mode):
251 return BUILD_MODES[mode] 252 return BUILD_MODES[mode]
252 253
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 key = 'USERNAME' 335 key = 'USERNAME'
335 return os.environ.get(key, '') 336 return os.environ.get(key, '')
336 337
337 def ReadVersionFile(): 338 def ReadVersionFile():
338 def match_against(pattern, file_content): 339 def match_against(pattern, file_content):
339 match = re.search(pattern, file_content, flags=re.MULTILINE) 340 match = re.search(pattern, file_content, flags=re.MULTILINE)
340 if match: 341 if match:
341 return match.group(1) 342 return match.group(1)
342 return None 343 return None
343 344
344 version_file = os.path.join(DART_DIR, 'tools', 'VERSION')
345 try: 345 try:
346 fd = open(version_file) 346 fd = open(VERSION_FILE)
347 content = fd.read() 347 content = fd.read()
348 fd.close() 348 fd.close()
349 except: 349 except:
350 print "Warning: Couldn't read VERSION file (%s)" % version_file 350 print "Warning: Couldn't read VERSION file (%s)" % VERSION_FILE
351 return None 351 return None
352 352
353 channel = match_against('^CHANNEL ([A-Za-z0-9]+)$', content) 353 channel = match_against('^CHANNEL ([A-Za-z0-9]+)$', content)
354 major = match_against('^MAJOR (\d+)$', content) 354 major = match_against('^MAJOR (\d+)$', content)
355 minor = match_against('^MINOR (\d+)$', content) 355 minor = match_against('^MINOR (\d+)$', content)
356 patch = match_against('^PATCH (\d+)$', content) 356 patch = match_against('^PATCH (\d+)$', content)
357 prerelease = match_against('^PRERELEASE (\d+)$', content) 357 prerelease = match_against('^PRERELEASE (\d+)$', content)
358 prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content) 358 prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content)
359 359
360 if channel and major and minor and prerelease and prerelease_patch: 360 if channel and major and minor and prerelease and prerelease_patch:
361 return Version( 361 return Version(
362 channel, major, minor, patch, prerelease, prerelease_patch) 362 channel, major, minor, patch, prerelease, prerelease_patch)
363 else: 363 else:
364 print "Warning: VERSION file (%s) has wrong format" % version_file 364 print "Warning: VERSION file (%s) has wrong format" % VERSION_FILE
365 return None 365 return None
366 366
367 367
368 # Our schema for releases and archiving is based on an increasing 368 # Our schema for releases and archiving is based on an increasing
369 # sequence of numbers. In the svn world this was simply the revision of a 369 # sequence of numbers. In the svn world this was simply the revision of a
370 # commit, which would always give us a one to one mapping between the number 370 # commit, which would always give us a one to one mapping between the number
371 # and the commit. This was true across branches as well, so a number used 371 # and the commit. This was true across branches as well, so a number used
372 # to archive a build was always unique and unambiguous. 372 # to archive a build was always unique and unambiguous.
373 # In git there is no such global number, so we loosen the requirement a bit. 373 # In git there is no such global number, so we loosen the requirement a bit.
374 # We only use numbers on the master branch (bleeding edge). On branches 374 # We only use numbers on the master branch (bleeding edge). On branches
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 os.chdir(self._working_directory) 663 os.chdir(self._working_directory)
664 664
665 def __exit__(self, *_): 665 def __exit__(self, *_):
666 print "Enter directory = ", self._old_cwd 666 print "Enter directory = ", self._old_cwd
667 os.chdir(self._old_cwd) 667 os.chdir(self._old_cwd)
668 668
669 669
670 if __name__ == "__main__": 670 if __name__ == "__main__":
671 import sys 671 import sys
672 Main() 672 Main()
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