OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
| 5 import os |
5 import subprocess | 6 import subprocess |
6 import sys | 7 import sys |
7 | 8 |
8 # This script returns the path to the SDK of the given type. Pass the type of | 9 # This script prints information about the build system, the operating |
9 # SDK you want, which is typically "iphone" or "iphonesimulator". | 10 # system and the iOS SDK (depending on the platform "iphonesimulator" |
| 11 # or "iphoneos" generally). |
10 # | 12 # |
11 # In the GYP build, this is done inside GYP itself based on the SDKROOT | 13 # In the GYP build, this is done inside GYP itself based on the SDKROOT |
12 # variable. | 14 # variable. |
13 | 15 |
14 if len(sys.argv) != 2: | 16 def FormatVersion(version): |
15 print "Takes one arg (SDK to find)" | 17 """Converts Xcode version to a format required for Info.plist.""" |
16 sys.exit(1) | 18 version = version.replace('.', '') |
| 19 version = version + '0' * (3 - len(version)) |
| 20 return version.zfill(4) |
17 | 21 |
18 print subprocess.check_output(['xcodebuild', '-version', '-sdk', | 22 |
19 sys.argv[1], 'Path']).strip() | 23 def FillXcodeVersion(settings): |
| 24 """Fills the Xcode version and build number into |settings|.""" |
| 25 lines = subprocess.check_output(['xcodebuild', '-version']).splitlines() |
| 26 settings['xcode_version'] = FormatVersion(lines[0].split()[-1]) |
| 27 settings['xcode_build'] = lines[-1].split()[-1] |
| 28 |
| 29 |
| 30 def FillMachineOSBuild(settings): |
| 31 """Fills OS build number into |settings|.""" |
| 32 settings['machine_os_build'] = subprocess.check_output( |
| 33 ['sw_vers', '-buildVersion']).strip() |
| 34 |
| 35 |
| 36 def FillSDKPathAndVersion(settings, platform): |
| 37 """Fills the SDK path and version for |platform| into |settings|.""" |
| 38 lines = subprocess.check_output(['xcodebuild', '-version', '-sdk', |
| 39 platform, 'Path', 'SDKVersion', 'ProductBuildVersion']).splitlines() |
| 40 settings['ios_sdk_path'] = lines[0] |
| 41 settings['ios_sdk_version'] = lines[1] |
| 42 settings['ios_sdk_build'] = lines[2] |
| 43 |
| 44 |
| 45 if __name__ == '__main__': |
| 46 if len(sys.argv) != 2: |
| 47 sys.stderr.write( |
| 48 'usage: %s [iphoneos|iphonesimulator]\n' % |
| 49 os.path.basename(sys.argv[0])) |
| 50 sys.exit(1) |
| 51 |
| 52 settings = {} |
| 53 FillSDKPathAndVersion(settings, sys.argv[1]) |
| 54 FillMachineOSBuild(settings) |
| 55 FillXcodeVersion(settings) |
| 56 |
| 57 for key in sorted(settings): |
| 58 print '%s="%s"' % (key, settings[key]) |
OLD | NEW |