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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 # Convert that to '0463', '4H1503'. | 785 # Convert that to '0463', '4H1503'. |
786 version_list = self._GetStdout(['xcodebuild', '-version']).splitlines() | 786 version_list = self._GetStdout(['xcodebuild', '-version']).splitlines() |
787 version = version_list[0] | 787 version = version_list[0] |
788 build = version_list[-1] | 788 build = version_list[-1] |
789 # Be careful to convert "4.2" to "0420": | 789 # Be careful to convert "4.2" to "0420": |
790 version = version.split()[-1].replace('.', '') | 790 version = version.split()[-1].replace('.', '') |
791 version = (version + '0' * (3 - len(version))).zfill(4) | 791 version = (version + '0' * (3 - len(version))).zfill(4) |
792 build = build.split()[-1] | 792 build = build.split()[-1] |
793 return version, build | 793 return version, build |
794 | 794 |
| 795 def _XcodeIOSDeviceFamily(self, configname): |
| 796 family = self.xcode_settings[configname].get('TARGETED_DEVICE_FAMILY', '1') |
| 797 return [int(x) for x in family.split(',')] |
| 798 |
795 def GetExtraPlistItems(self, configname=None): | 799 def GetExtraPlistItems(self, configname=None): |
796 """Returns a dictionary with extra items to insert into Info.plist.""" | 800 """Returns a dictionary with extra items to insert into Info.plist.""" |
797 if not XcodeSettings._plist_cache: | 801 if configname not in XcodeSettings._plist_cache: |
798 cache = XcodeSettings._plist_cache | 802 cache = {} |
799 cache['BuildMachineOSBuild'] = self._BuildMachineOSBuild() | 803 cache['BuildMachineOSBuild'] = self._BuildMachineOSBuild() |
800 | 804 |
801 xcode, xcode_build = self._XcodeVersion() | 805 xcode, xcode_build = self._XcodeVersion() |
802 cache['DTXcode'] = xcode | 806 cache['DTXcode'] = xcode |
803 cache['DTXcodeBuild'] = xcode_build | 807 cache['DTXcodeBuild'] = xcode_build |
804 | 808 |
805 sdk_root = self._SdkRoot(configname) | 809 sdk_root = self._SdkRoot(configname) |
806 cache['DTSDKName'] = sdk_root | 810 cache['DTSDKName'] = sdk_root |
807 if xcode >= '0430': | 811 if xcode >= '0430': |
808 cache['DTSDKBuild'] = self._GetSdkVersionInfoItem( | 812 cache['DTSDKBuild'] = self._GetSdkVersionInfoItem( |
809 sdk_root, 'ProductBuildVersion') | 813 sdk_root, 'ProductBuildVersion') |
810 else: | 814 else: |
811 cache['DTSDKBuild'] = cache['BuildMachineOSBuild'] | 815 cache['DTSDKBuild'] = cache['BuildMachineOSBuild'] |
812 | 816 |
813 return XcodeSettings._plist_cache | 817 if self.isIOS: |
| 818 cache['UIDeviceFamily'] = self._XcodeIOSDeviceFamily(configname) |
| 819 if configname.endswith("iphoneos"): |
| 820 cache['CFBundleSupportedPlatforms'] = ['iPhoneOS'] |
| 821 else: |
| 822 cache['CFBundleSupportedPlatforms'] = ['iPhoneSimulator'] |
| 823 XcodeSettings._plist_cache[configname] = cache |
| 824 return XcodeSettings._plist_cache[configname] |
814 | 825 |
815 | 826 |
816 class MacPrefixHeader(object): | 827 class MacPrefixHeader(object): |
817 """A class that helps with emulating Xcode's GCC_PREFIX_HEADER feature. | 828 """A class that helps with emulating Xcode's GCC_PREFIX_HEADER feature. |
818 | 829 |
819 This feature consists of several pieces: | 830 This feature consists of several pieces: |
820 * If GCC_PREFIX_HEADER is present, all compilations in that project get an | 831 * If GCC_PREFIX_HEADER is present, all compilations in that project get an |
821 additional |-include path_to_prefix_header| cflag. | 832 additional |-include path_to_prefix_header| cflag. |
822 * If GCC_PRECOMPILE_PREFIX_HEADER is present too, then the prefix header is | 833 * If GCC_PRECOMPILE_PREFIX_HEADER is present too, then the prefix header is |
823 instead compiled, and all other compilations in the project get an | 834 instead compiled, and all other compilations in the project get an |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 new_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' | 1227 new_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
1217 target_dict['configurations'][new_config_name] = new_config_dict | 1228 target_dict['configurations'][new_config_name] = new_config_dict |
1218 return targets | 1229 return targets |
1219 | 1230 |
1220 def CloneConfigurationForDeviceAndEmulator(target_dicts): | 1231 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
1221 """If |target_dicts| contains any iOS targets, automatically create -iphoneos | 1232 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
1222 targets for iOS device builds.""" | 1233 targets for iOS device builds.""" |
1223 if _HasIOSTarget(target_dicts): | 1234 if _HasIOSTarget(target_dicts): |
1224 return _AddIOSDeviceConfigurations(target_dicts) | 1235 return _AddIOSDeviceConfigurations(target_dicts) |
1225 return target_dicts | 1236 return target_dicts |
OLD | NEW |