| OLD | NEW |
| 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. 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 """ | 5 """ |
| 6 This module contains classes that help to emulate xcodebuild behavior on top of | 6 This module contains classes that help to emulate xcodebuild behavior on top of |
| 7 other build systems, such as make and ninja. | 7 other build systems, such as make and ninja. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import copy | 10 import copy |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 config_settings.get('ARCHS'), | 426 config_settings.get('ARCHS'), |
| 427 config_settings.get('VALID_ARCHS'), | 427 config_settings.get('VALID_ARCHS'), |
| 428 config_settings.get('SDKROOT')) | 428 config_settings.get('SDKROOT')) |
| 429 | 429 |
| 430 def _GetSdkVersionInfoItem(self, sdk, infoitem): | 430 def _GetSdkVersionInfoItem(self, sdk, infoitem): |
| 431 # xcodebuild requires Xcode and can't run on Command Line Tools-only | 431 # xcodebuild requires Xcode and can't run on Command Line Tools-only |
| 432 # systems from 10.7 onward. | 432 # systems from 10.7 onward. |
| 433 # Since the CLT has no SDK paths anyway, returning None is the | 433 # Since the CLT has no SDK paths anyway, returning None is the |
| 434 # most sensible route and should still do the right thing. | 434 # most sensible route and should still do the right thing. |
| 435 try: | 435 try: |
| 436 return GetStdout(['xcodebuild', '-version', '-sdk', sdk, infoitem]) | 436 return GetStdout(['xcrun', '--sdk', sdk, infoitem]) |
| 437 except: | 437 except: |
| 438 pass | 438 pass |
| 439 | 439 |
| 440 def _SdkRoot(self, configname): | 440 def _SdkRoot(self, configname): |
| 441 if configname is None: | 441 if configname is None: |
| 442 configname = self.configname | 442 configname = self.configname |
| 443 return self.GetPerConfigSetting('SDKROOT', configname, default='') | 443 return self.GetPerConfigSetting('SDKROOT', configname, default='') |
| 444 | 444 |
| 445 def _XcodePlatformPath(self, configname=None): | 445 def _XcodePlatformPath(self, configname=None): |
| 446 sdk_root = self._SdkRoot(configname) | 446 sdk_root = self._SdkRoot(configname) |
| 447 if sdk_root not in XcodeSettings._platform_path_cache: | 447 if sdk_root not in XcodeSettings._platform_path_cache: |
| 448 platform_path = self._GetSdkVersionInfoItem(sdk_root, 'PlatformPath') | 448 platform_path = self._GetSdkVersionInfoItem(sdk_root, |
| 449 '--show-sdk-platform-path') |
| 449 XcodeSettings._platform_path_cache[sdk_root] = platform_path | 450 XcodeSettings._platform_path_cache[sdk_root] = platform_path |
| 450 return XcodeSettings._platform_path_cache[sdk_root] | 451 return XcodeSettings._platform_path_cache[sdk_root] |
| 451 | 452 |
| 452 def _SdkPath(self, configname=None): | 453 def _SdkPath(self, configname=None): |
| 453 sdk_root = self._SdkRoot(configname) | 454 sdk_root = self._SdkRoot(configname) |
| 454 if sdk_root.startswith('/'): | 455 if sdk_root.startswith('/'): |
| 455 return sdk_root | 456 return sdk_root |
| 456 return self._XcodeSdkPath(sdk_root) | 457 return self._XcodeSdkPath(sdk_root) |
| 457 | 458 |
| 458 def _XcodeSdkPath(self, sdk_root): | 459 def _XcodeSdkPath(self, sdk_root): |
| 459 if sdk_root not in XcodeSettings._sdk_path_cache: | 460 if sdk_root not in XcodeSettings._sdk_path_cache: |
| 460 sdk_path = self._GetSdkVersionInfoItem(sdk_root, 'Path') | 461 sdk_path = self._GetSdkVersionInfoItem(sdk_root, '--show-sdk-path') |
| 461 XcodeSettings._sdk_path_cache[sdk_root] = sdk_path | 462 XcodeSettings._sdk_path_cache[sdk_root] = sdk_path |
| 462 if sdk_root: | 463 if sdk_root: |
| 463 XcodeSettings._sdk_root_cache[sdk_path] = sdk_root | 464 XcodeSettings._sdk_root_cache[sdk_path] = sdk_root |
| 464 return XcodeSettings._sdk_path_cache[sdk_root] | 465 return XcodeSettings._sdk_path_cache[sdk_root] |
| 465 | 466 |
| 466 def _AppendPlatformVersionMinFlags(self, lst): | 467 def _AppendPlatformVersionMinFlags(self, lst): |
| 467 self._Appendf(lst, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s') | 468 self._Appendf(lst, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s') |
| 468 if 'IPHONEOS_DEPLOYMENT_TARGET' in self._Settings(): | 469 if 'IPHONEOS_DEPLOYMENT_TARGET' in self._Settings(): |
| 469 # TODO: Implement this better? | 470 # TODO: Implement this better? |
| 470 sdk_path_basename = os.path.basename(self._SdkPath()) | 471 sdk_path_basename = os.path.basename(self._SdkPath()) |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 xcode, xcode_build = XcodeVersion() | 1096 xcode, xcode_build = XcodeVersion() |
| 1096 cache['DTXcode'] = xcode | 1097 cache['DTXcode'] = xcode |
| 1097 cache['DTXcodeBuild'] = xcode_build | 1098 cache['DTXcodeBuild'] = xcode_build |
| 1098 | 1099 |
| 1099 sdk_root = self._SdkRoot(configname) | 1100 sdk_root = self._SdkRoot(configname) |
| 1100 if not sdk_root: | 1101 if not sdk_root: |
| 1101 sdk_root = self._DefaultSdkRoot() | 1102 sdk_root = self._DefaultSdkRoot() |
| 1102 cache['DTSDKName'] = sdk_root | 1103 cache['DTSDKName'] = sdk_root |
| 1103 if xcode >= '0430': | 1104 if xcode >= '0430': |
| 1104 cache['DTSDKBuild'] = self._GetSdkVersionInfoItem( | 1105 cache['DTSDKBuild'] = self._GetSdkVersionInfoItem( |
| 1105 sdk_root, 'ProductBuildVersion') | 1106 sdk_root, '--show-sdk-version') |
| 1106 else: | 1107 else: |
| 1107 cache['DTSDKBuild'] = cache['BuildMachineOSBuild'] | 1108 cache['DTSDKBuild'] = cache['BuildMachineOSBuild'] |
| 1108 | 1109 |
| 1109 if self.isIOS: | 1110 if self.isIOS: |
| 1110 cache['DTPlatformName'] = cache['DTSDKName'] | 1111 cache['DTPlatformName'] = cache['DTSDKName'] |
| 1111 if configname.endswith("iphoneos"): | 1112 if configname.endswith("iphoneos"): |
| 1112 cache['DTPlatformVersion'] = self._GetSdkVersionInfoItem( | 1113 cache['DTPlatformVersion'] = self._GetSdkVersionInfoItem( |
| 1113 sdk_root, 'ProductVersion') | 1114 sdk_root, '--show-sdk-version') |
| 1114 cache['CFBundleSupportedPlatforms'] = ['iPhoneOS'] | 1115 cache['CFBundleSupportedPlatforms'] = ['iPhoneOS'] |
| 1115 else: | 1116 else: |
| 1116 cache['CFBundleSupportedPlatforms'] = ['iPhoneSimulator'] | 1117 cache['CFBundleSupportedPlatforms'] = ['iPhoneSimulator'] |
| 1117 XcodeSettings._plist_cache[configname] = cache | 1118 XcodeSettings._plist_cache[configname] = cache |
| 1118 | 1119 |
| 1119 # Include extra plist items that are per-target, not per global | 1120 # Include extra plist items that are per-target, not per global |
| 1120 # XcodeSettings. | 1121 # XcodeSettings. |
| 1121 items = dict(XcodeSettings._plist_cache[configname]) | 1122 items = dict(XcodeSettings._plist_cache[configname]) |
| 1122 if self.isIOS: | 1123 if self.isIOS: |
| 1123 items['UIDeviceFamily'] = self._XcodeIOSDeviceFamily(configname) | 1124 items['UIDeviceFamily'] = self._XcodeIOSDeviceFamily(configname) |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 if toolset == 'target': | 1642 if toolset == 'target': |
| 1642 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' | 1643 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
| 1643 return targets | 1644 return targets |
| 1644 | 1645 |
| 1645 def CloneConfigurationForDeviceAndEmulator(target_dicts): | 1646 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
| 1646 """If |target_dicts| contains any iOS targets, automatically create -iphoneos | 1647 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
| 1647 targets for iOS device builds.""" | 1648 targets for iOS device builds.""" |
| 1648 if _HasIOSTarget(target_dicts): | 1649 if _HasIOSTarget(target_dicts): |
| 1649 return _AddIOSDeviceConfigurations(target_dicts) | 1650 return _AddIOSDeviceConfigurations(target_dicts) |
| 1650 return target_dicts | 1651 return target_dicts |
| OLD | NEW |