| Index: dart/tools/utils.py
|
| diff --git a/dart/tools/utils.py b/dart/tools/utils.py
|
| index de2425c281815fab9b653be03d607c26a8ac50b3..89da10fc490ae35decea341732bf41004e3a91bc 100644
|
| --- a/dart/tools/utils.py
|
| +++ b/dart/tools/utils.py
|
| @@ -14,15 +14,6 @@ import subprocess
|
| import sys
|
| import tempfile
|
|
|
| -class Version(object):
|
| - def __init__(self, channel, major, minor, patch, prerelease,
|
| - prerelease_patch):
|
| - self.channel = channel
|
| - self.major = major
|
| - self.minor = minor
|
| - self.patch = patch
|
| - self.prerelease = prerelease
|
| - self.prerelease_patch = prerelease_patch
|
|
|
| # Try to guess the host operating system.
|
| def GuessOS():
|
| @@ -240,47 +231,40 @@ def GetBuildRoot(host_os, mode=None, arch=None, target_os=None):
|
| def GetBaseDir():
|
| return BASE_DIR
|
|
|
| +# Return the base part of the version, Major.Minor.Build.Patch,
|
| +# without the _revision addition
|
| def GetShortVersion():
|
| - version = ReadVersionFile()
|
| - return ('%s.%s.%s.%s.%s' % (
|
| - version.major, version.minor, version.patch, version.prerelease,
|
| - version.prerelease_patch))
|
| -
|
| -def GetSemanticSDKVersion():
|
| - version = ReadVersionFile()
|
| - if not version:
|
| - return None
|
| + (channel, major, minor, build, patch) = ReadVersionFile()
|
| + # TODO(kustermann/ricow): Add the channel to the version string.
|
| + return '%s.%s.%s.%s' % (major, minor, build, patch)
|
|
|
| - if version.channel == 'be':
|
| - postfix = '-edge.%s' % GetSVNRevision()
|
| - elif version.channel == 'dev':
|
| - postfix = '-dev.%s.%s' % (version.prerelease, version.prerelease_patch)
|
| - else:
|
| - assert version.channel == 'stable'
|
| - postfix = ''
|
| -
|
| - return '%s.%s.%s%s' % (version.major, version.minor, version.patch, postfix)
|
| -
|
| -def GetEclipseVersionQualifier():
|
| - def pad(number, num_digits):
|
| - number_str = str(number)
|
| - return '0' * max(0, num_digits - len(number_str)) + number_str
|
| -
|
| - version = ReadVersionFile()
|
| - if version.channel == 'be':
|
| - return 'edge_%s' % pad(GetSVNRevision(), 6)
|
| - elif version.channel == 'dev':
|
| - return 'dev_%s_%s' % (pad(version.prerelease, 2),
|
| - pad(version.prerelease_patch, 2))
|
| - else:
|
| - return 'release'
|
|
|
| def GetVersion():
|
| - return GetSemanticSDKVersion()
|
| + version_tuple = ReadVersionFile()
|
| + if not version_tuple:
|
| + return None
|
| +
|
| + (channel, major, minor, build, patch) = version_tuple
|
| + revision = GetSVNRevision()
|
| + user = GetUserName()
|
| + # We don't add username to release builds (or any builds on the bots)
|
| + if user == 'chrome-bot':
|
| + user = ''
|
| +
|
| + user_string = ''
|
| + revision_string = ''
|
| + if user:
|
| + user_string = '_%s' % user
|
| + if revision:
|
| + revision_string = '_r%s' % revision
|
| +
|
| + # TODO(kustermann/ricow): Add the channel to the version string.
|
| + return ("%s.%s.%s.%s%s%s" %
|
| + (major, minor, build, patch, revision_string, user_string))
|
|
|
| def GetChannel():
|
| - version = ReadVersionFile()
|
| - return version.channel
|
| + (channel, _, _, _, _) = ReadVersionFile()
|
| + return channel
|
|
|
| def GetUserName():
|
| key = 'USER'
|
| @@ -289,12 +273,6 @@ def GetUserName():
|
| return os.environ.get(key, '')
|
|
|
| def ReadVersionFile():
|
| - def match_against(pattern, content):
|
| - match = re.search(pattern, content, flags=re.MULTILINE)
|
| - if match:
|
| - return match.group(1)
|
| - return None
|
| -
|
| version_file = os.path.join(DART_DIR, 'tools', 'VERSION')
|
| try:
|
| fd = open(version_file)
|
| @@ -303,17 +281,19 @@ def ReadVersionFile():
|
| except:
|
| print "Warning: Couldn't read VERSION file (%s)" % version_file
|
| return None
|
| -
|
| - channel = match_against('^CHANNEL ([A-Za-z0-9]+)$', content)
|
| - major = match_against('^MAJOR (\d+)$', content)
|
| - minor = match_against('^MINOR (\d+)$', content)
|
| - patch = match_against('^PATCH (\d+)$', content)
|
| - prerelease = match_against('^PRERELEASE (\d+)$', content)
|
| - prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content)
|
| -
|
| - if channel and major and minor and prerelease and prerelease_patch:
|
| - return Version(
|
| - channel, major, minor, patch, prerelease, prerelease_patch)
|
| + channel_match = re.search(
|
| + '^CHANNEL ([A-Za-z0-9]+)$', content, flags=re.MULTILINE)
|
| + major_match = re.search('^MAJOR (\d+)$', content, flags=re.MULTILINE)
|
| + minor_match = re.search('^MINOR (\d+)$', content, flags=re.MULTILINE)
|
| + build_match = re.search('^BUILD (\d+)$', content, flags=re.MULTILINE)
|
| + patch_match = re.search('^PATCH (\d+)$', content, flags=re.MULTILINE)
|
| + if (channel_match and
|
| + major_match and
|
| + minor_match and
|
| + build_match and
|
| + patch_match):
|
| + return (channel_match.group(1), major_match.group(1), minor_match.group(1),
|
| + build_match.group(1), patch_match.group(1))
|
| else:
|
| print "Warning: VERSION file (%s) has wrong format" % version_file
|
| return None
|
|
|