Chromium Code Reviews| 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..dfb78fd457a2672e2b49211d25b008fa3b2d7e75 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. |
|
Sam Clegg
2014/09/22 17:34:46
I think docstrings use 2-space indentation like th
Matt Giuca
2014/09/23 01:07:36
Yeah you're right. (I was looking at the style gui
Sam Clegg
2014/09/23 01:11:24
Yes, the internal and external style guides differ
|
| + |
| + 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: |