| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Determine OS and various other system properties. | 6 """Determine OS and various other system properties. |
| 7 | 7 |
| 8 Determine the name of the platform used and other system properties such as | 8 Determine the name of the platform used and other system properties such as |
| 9 the location of Chrome. This is used, for example, to determine the correct | 9 the location of Chrome. This is used, for example, to determine the correct |
| 10 Toolchain to invoke. | 10 Toolchain to invoke. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 version = version.split('.') | 184 version = version.split('.') |
| 185 else: | 185 else: |
| 186 version = (version, '0') | 186 version = (version, '0') |
| 187 | 187 |
| 188 try: | 188 try: |
| 189 return tuple(int(x) for x in version) | 189 return tuple(int(x) for x in version) |
| 190 except ValueError: | 190 except ValueError: |
| 191 raise Error('error parsing SDK version: %s' % version) | 191 raise Error('error parsing SDK version: %s' % version) |
| 192 | 192 |
| 193 | 193 |
| 194 def CheckVersion(required_version): |
| 195 version = GetSDKVersion() |
| 196 # We currently ignore the revision and just check the major version number. |
| 197 # Currently, version[1] is just a Git hash, which cannot be compared. |
| 198 # TODO(mgiuca): Compare the minor revision numbers (which should be |
| 199 # Cr-Commit-Position values), when http://crbug.com/406783 is fixed. |
| 200 # Then Cr-Commit-Position should be available: see http://crbug.com/406993. |
| 201 if version[0] < required_version[0]: |
| 202 raise Error("SDK version too old (current: %s, required: %s)" |
| 203 % (version[0], required_version[0])) |
| 204 |
| 205 |
| 194 def main(args): | 206 def main(args): |
| 195 parser = optparse.OptionParser() | 207 parser = optparse.OptionParser() |
| 196 parser.add_option('--arch', action='store_true', | 208 parser.add_option('--arch', action='store_true', |
| 197 help='Print architecture of current machine (x86_32, x86_64 or arm).') | 209 help='Print architecture of current machine (x86_32, x86_64 or arm).') |
| 198 parser.add_option('--chrome', action='store_true', | 210 parser.add_option('--chrome', action='store_true', |
| 199 help='Print the path chrome (by first looking in $CHROME_PATH and ' | 211 help='Print the path chrome (by first looking in $CHROME_PATH and ' |
| 200 'then $PATH).') | 212 'then $PATH).') |
| 201 parser.add_option('--nacl-arch', action='store_true', | 213 parser.add_option('--nacl-arch', action='store_true', |
| 202 help='Print architecture used by NaCl on the current machine.') | 214 help='Print architecture used by NaCl on the current machine.') |
| 203 parser.add_option('--sdk-version', action='store_true', | 215 parser.add_option('--sdk-version', action='store_true', |
| (...skipping 20 matching lines...) Expand all Loading... |
| 224 elif options.nacl_arch: | 236 elif options.nacl_arch: |
| 225 out = GetNaClArch(platform) | 237 out = GetNaClArch(platform) |
| 226 elif options.chrome: | 238 elif options.chrome: |
| 227 out = GetChromePath(platform) | 239 out = GetChromePath(platform) |
| 228 elif options.sdk_version: | 240 elif options.sdk_version: |
| 229 out = GetSDKVersion()[0] | 241 out = GetSDKVersion()[0] |
| 230 elif options.sdk_revision: | 242 elif options.sdk_revision: |
| 231 out = GetSDKVersion()[1] | 243 out = GetSDKVersion()[1] |
| 232 elif options.check_version: | 244 elif options.check_version: |
| 233 required_version = ParseVersion(options.check_version) | 245 required_version = ParseVersion(options.check_version) |
| 234 version = GetSDKVersion() | 246 CheckVersion(required_version) |
| 235 # We currently ignore the revision and just check the major version number. | |
| 236 # Currently, version[1] is just a Git hash, which cannot be compared. | |
| 237 # TODO(mgiuca): Compare the minor revision numbers (which should be | |
| 238 # Cr-Commit-Position values), when http://crbug.com/406783 is fixed. | |
| 239 # Then Cr-Commit-Position should be available: see http://crbug.com/406993. | |
| 240 if version[0] < required_version[0]: | |
| 241 raise Error("SDK version too old (current: %s, required: %s)" | |
| 242 % (version[0], required_version[0])) | |
| 243 out = None | 247 out = None |
| 244 | 248 |
| 245 if out: | 249 if out: |
| 246 print out | 250 print out |
| 247 return 0 | 251 return 0 |
| 248 | 252 |
| 249 | 253 |
| 250 if __name__ == '__main__': | 254 if __name__ == '__main__': |
| 251 try: | 255 try: |
| 252 sys.exit(main(sys.argv[1:])) | 256 sys.exit(main(sys.argv[1:])) |
| 253 except Error as e: | 257 except Error as e: |
| 254 sys.stderr.write(str(e) + '\n') | 258 sys.stderr.write(str(e) + '\n') |
| 255 sys.exit(1) | 259 sys.exit(1) |
| OLD | NEW |