Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: pylib/gyp/xcode_emulation.py

Issue 1907523002: [ios-ninja] Support xctests for devices in release. (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Simpler mac_tool changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pylib/gyp/mac_tool.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 Chromium.app/Contents/Resources. Only valid for bundles.""" 305 Chromium.app/Contents/Resources. Only valid for bundles."""
306 assert self._IsBundle() 306 assert self._IsBundle()
307 if self.isIOS: 307 if self.isIOS:
308 return self.GetBundleContentsFolderPath() 308 return self.GetBundleContentsFolderPath()
309 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') 309 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources')
310 310
311 def GetBundlePlistPath(self): 311 def GetBundlePlistPath(self):
312 """Returns the qualified path to the bundle's plist file. E.g. 312 """Returns the qualified path to the bundle's plist file. E.g.
313 Chromium.app/Contents/Info.plist. Only valid for bundles.""" 313 Chromium.app/Contents/Info.plist. Only valid for bundles."""
314 assert self._IsBundle() 314 assert self._IsBundle()
315 if self.spec['type'] in ('executable', 'loadable_module'): 315 if self.spec['type'] in ('executable', 'loadable_module') or \
316 self.IsIosFramework():
316 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') 317 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist')
317 else: 318 else:
318 return os.path.join(self.GetBundleContentsFolderPath(), 319 return os.path.join(self.GetBundleContentsFolderPath(),
319 'Resources', 'Info.plist') 320 'Resources', 'Info.plist')
320 321
321 def GetProductType(self): 322 def GetProductType(self):
322 """Returns the PRODUCT_TYPE of this target.""" 323 """Returns the PRODUCT_TYPE of this target."""
323 if self._IsIosAppExtension(): 324 if self._IsIosAppExtension():
324 assert self._IsBundle(), ('ios_app_extension flag requires mac_bundle ' 325 assert self._IsBundle(), ('ios_app_extension flag requires mac_bundle '
325 '(target %s)' % self.spec['target_name']) 326 '(target %s)' % self.spec['target_name'])
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1002
1002 def _GetIOSPostbuilds(self, configname, output_binary): 1003 def _GetIOSPostbuilds(self, configname, output_binary):
1003 """Return a shell command to codesign the iOS output binary so it can 1004 """Return a shell command to codesign the iOS output binary so it can
1004 be deployed to a device. This should be run as the very last step of the 1005 be deployed to a device. This should be run as the very last step of the
1005 build.""" 1006 build."""
1006 if not (self.isIOS and 1007 if not (self.isIOS and
1007 (self.spec['type'] == 'executable' or self._IsXCTest()) or 1008 (self.spec['type'] == 'executable' or self._IsXCTest()) or
1008 self.IsIosFramework()): 1009 self.IsIosFramework()):
1009 return [] 1010 return []
1010 1011
1012 postbuilds = []
1013 product_name = self.GetFullProductName()
1011 settings = self.xcode_settings[configname] 1014 settings = self.xcode_settings[configname]
1015
1016 # Xcode expects XCTests to be copied into the TEST_HOST dir.
1017 if self._IsXCTest():
1018 source = os.path.join("${BUILT_PRODUCTS_DIR}", product_name)
1019 test_host = os.path.dirname(settings.get('TEST_HOST'));
1020 xctest_destination = os.path.join(test_host, 'PlugIns', product_name)
1021 postbuilds.extend(['ditto %s %s' % (source, xctest_destination)])
1022
1012 key = self._GetIOSCodeSignIdentityKey(settings) 1023 key = self._GetIOSCodeSignIdentityKey(settings)
1013 if not key: 1024 if not key:
1014 return [] 1025 return postbuilds
1015 1026
1016 # Warn for any unimplemented signing xcode keys. 1027 # Warn for any unimplemented signing xcode keys.
1017 unimpl = ['OTHER_CODE_SIGN_FLAGS'] 1028 unimpl = ['OTHER_CODE_SIGN_FLAGS']
1018 unimpl = set(unimpl) & set(self.xcode_settings[configname].keys()) 1029 unimpl = set(unimpl) & set(self.xcode_settings[configname].keys())
1019 if unimpl: 1030 if unimpl:
1020 print 'Warning: Some codesign keys not implemented, ignoring: %s' % ( 1031 print 'Warning: Some codesign keys not implemented, ignoring: %s' % (
1021 ', '.join(sorted(unimpl))) 1032 ', '.join(sorted(unimpl)))
1022 1033
1023 return ['%s code-sign-bundle "%s" "%s" "%s"' % ( 1034 if self._IsXCTest():
1035 # For device xctests, Xcode copies two extra frameworks into $TEST_HOST.
1036 test_host = os.path.dirname(settings.get('TEST_HOST'));
1037 frameworks_dir = os.path.join(test_host, 'Frameworks')
1038 platform_root = self._XcodePlatformPath(configname)
1039 frameworks = \
1040 ['Developer/Library/PrivateFrameworks/IDEBundleInjection.framework',
1041 'Developer/Library/Frameworks/XCTest.framework']
1042 for framework in frameworks:
1043 source = os.path.join(platform_root, framework)
1044 destination = os.path.join(frameworks_dir, os.path.basename(framework))
1045 postbuilds.extend(['ditto %s %s' % (source, destination)])
1046
1047 # Then re-sign everything with 'preserve=True'
1048 postbuilds.extend(['%s code-sign-bundle "%s" "%s" "%s" "%s" %s' % (
1049 os.path.join('${TARGET_BUILD_DIR}', 'gyp-mac-tool'), key,
1050 settings.get('CODE_SIGN_ENTITLEMENTS', ''),
1051 settings.get('PROVISIONING_PROFILE', ''), destination, True)
1052 ])
1053 plugin_dir = os.path.join(test_host, 'PlugIns')
1054 targets = [os.path.join(plugin_dir, product_name), test_host]
1055 for target in targets:
1056 postbuilds.extend(['%s code-sign-bundle "%s" "%s" "%s" "%s" %s' % (
1057 os.path.join('${TARGET_BUILD_DIR}', 'gyp-mac-tool'), key,
1058 settings.get('CODE_SIGN_ENTITLEMENTS', ''),
1059 settings.get('PROVISIONING_PROFILE', ''), target, True)
1060 ])
1061
1062 postbuilds.extend(['%s code-sign-bundle "%s" "%s" "%s" "%s" %s' % (
1024 os.path.join('${TARGET_BUILD_DIR}', 'gyp-mac-tool'), key, 1063 os.path.join('${TARGET_BUILD_DIR}', 'gyp-mac-tool'), key,
1025 settings.get('CODE_SIGN_ENTITLEMENTS', ''), 1064 settings.get('CODE_SIGN_ENTITLEMENTS', ''),
1026 settings.get('PROVISIONING_PROFILE', '')) 1065 settings.get('PROVISIONING_PROFILE', ''),
1027 ] 1066 os.path.join("${BUILT_PRODUCTS_DIR}", product_name), False)
1067 ])
1068 return postbuilds
1028 1069
1029 def _GetIOSCodeSignIdentityKey(self, settings): 1070 def _GetIOSCodeSignIdentityKey(self, settings):
1030 identity = settings.get('CODE_SIGN_IDENTITY') 1071 identity = settings.get('CODE_SIGN_IDENTITY')
1031 if not identity: 1072 if not identity:
1032 return None 1073 return None
1033 if identity not in XcodeSettings._codesigning_key_cache: 1074 if identity not in XcodeSettings._codesigning_key_cache:
1034 output = subprocess.check_output( 1075 output = subprocess.check_output(
1035 ['security', 'find-identity', '-p', 'codesigning', '-v']) 1076 ['security', 'find-identity', '-p', 'codesigning', '-v'])
1036 for line in output.splitlines(): 1077 for line in output.splitlines():
1037 if identity in line: 1078 if identity in line:
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 if toolset == 'target': 1709 if toolset == 'target':
1669 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' 1710 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos'
1670 return targets 1711 return targets
1671 1712
1672 def CloneConfigurationForDeviceAndEmulator(target_dicts): 1713 def CloneConfigurationForDeviceAndEmulator(target_dicts):
1673 """If |target_dicts| contains any iOS targets, automatically create -iphoneos 1714 """If |target_dicts| contains any iOS targets, automatically create -iphoneos
1674 targets for iOS device builds.""" 1715 targets for iOS device builds."""
1675 if _HasIOSTarget(target_dicts): 1716 if _HasIOSTarget(target_dicts):
1676 return _AddIOSDeviceConfigurations(target_dicts) 1717 return _AddIOSDeviceConfigurations(target_dicts)
1677 return target_dicts 1718 return target_dicts
OLDNEW
« no previous file with comments | « pylib/gyp/mac_tool.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698