| Index: native_client_sdk/src/tools/getos.py
|
| diff --git a/native_client_sdk/src/tools/getos.py b/native_client_sdk/src/tools/getos.py
|
| index f14e02e0630494da2158a9bbacab2275fda9a9d1..8416b56f07648389db79b9e3c40e7fe95891c454 100755
|
| --- a/native_client_sdk/src/tools/getos.py
|
| +++ b/native_client_sdk/src/tools/getos.py
|
| @@ -84,6 +84,7 @@ def GetSDKVersion():
|
|
|
| try:
|
| version = int(version)
|
| + revision = int(revision)
|
| except ValueError:
|
| raise Error("error parsing SDK README: %s" % readme)
|
|
|
| @@ -183,6 +184,10 @@ def GetNaClArch(platform):
|
|
|
|
|
| def ParseVersion(version):
|
| + """Parses a version number of the form '<major>.<position>'.
|
| +
|
| + <position> is the Cr-Commit-Position number.
|
| + """
|
| if '.' in version:
|
| version = version.split('.')
|
| else:
|
| @@ -194,6 +199,22 @@ def ParseVersion(version):
|
| raise Error('error parsing SDK version: %s' % version)
|
|
|
|
|
| +def CheckVersion(required_version):
|
| + """Determines whether the current SDK version meets the required version.
|
| +
|
| + Args:
|
| + required_version: (major, position) pair, where position is the
|
| + Cr-Commit-Position number.
|
| +
|
| + Raises:
|
| + Error: The SDK version is older than required_version.
|
| + """
|
| + version = GetSDKVersion()[:2]
|
| + if version < required_version:
|
| + raise Error("SDK version too old (current: %d.%d, required: %d.%d)"
|
| + % (version[0], version[1], required_version[0], required_version[1]))
|
| +
|
| +
|
| def main(args):
|
| parser = optparse.OptionParser()
|
| parser.add_option('--arch', action='store_true',
|
| @@ -210,8 +231,10 @@ def main(args):
|
| parser.add_option('--sdk-commit-position', action='store_true',
|
| help='Print commit position of the NaCl SDK.')
|
| parser.add_option('--check-version',
|
| + metavar='MAJOR.POSITION',
|
| help='Check that the SDK version is at least as great as the '
|
| - 'version passed in.')
|
| + 'version passed in. MAJOR is the major version number and POSITION '
|
| + 'is the Cr-Commit-Position number.')
|
|
|
| options, _ = parser.parse_args(args)
|
|
|
| @@ -238,15 +261,7 @@ def main(args):
|
| out = GetSDKVersion()[2]
|
| elif options.check_version:
|
| required_version = ParseVersion(options.check_version)
|
| - version = GetSDKVersion()
|
| - # We currently ignore the revision and just check the major version number.
|
| - # Currently, version[1] is just a Git hash, which cannot be compared.
|
| - # TODO(mgiuca): Compare the minor revision numbers (which should be
|
| - # Cr-Commit-Position values), when http://crbug.com/406783 is fixed.
|
| - # Then Cr-Commit-Position should be available: see http://crbug.com/406993.
|
| - if version[0] < required_version[0]:
|
| - raise Error("SDK version too old (current: %s, required: %s)"
|
| - % (version[0], required_version[0]))
|
| + CheckVersion(required_version)
|
| out = None
|
|
|
| if out:
|
|
|