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

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

Issue 376603002: This CL adds support for extension in GYP. (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Created 6 years, 5 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
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if self.spec['type'] in ('loadable_module', 'shared_library'): 231 if self.spec['type'] in ('loadable_module', 'shared_library'):
232 default_wrapper_extension = { 232 default_wrapper_extension = {
233 'loadable_module': 'bundle', 233 'loadable_module': 'bundle',
234 'shared_library': 'framework', 234 'shared_library': 'framework',
235 }[self.spec['type']] 235 }[self.spec['type']]
236 wrapper_extension = self.GetPerTargetSetting( 236 wrapper_extension = self.GetPerTargetSetting(
237 'WRAPPER_EXTENSION', default=default_wrapper_extension) 237 'WRAPPER_EXTENSION', default=default_wrapper_extension)
238 return '.' + self.spec.get('product_extension', wrapper_extension) 238 return '.' + self.spec.get('product_extension', wrapper_extension)
239 elif self.spec['type'] == 'executable': 239 elif self.spec['type'] == 'executable':
240 return '.' + self.spec.get('product_extension', 'app') 240 return '.' + self.spec.get('product_extension', 'app')
241 elif self.spec['type'] == 'extension':
242 return '.' + self.spec.get('product_extension', 'appex')
241 else: 243 else:
242 assert False, "Don't know extension for '%s', target '%s'" % ( 244 assert False, "Don't know extension for '%s', target '%s'" % (
243 self.spec['type'], self.spec['target_name']) 245 self.spec['type'], self.spec['target_name'])
244 246
245 def GetProductName(self): 247 def GetProductName(self):
246 """Returns PRODUCT_NAME.""" 248 """Returns PRODUCT_NAME."""
247 return self.spec.get('product_name', self.spec['target_name']) 249 return self.spec.get('product_name', self.spec['target_name'])
248 250
249 def GetFullProductName(self): 251 def GetFullProductName(self):
250 """Returns FULL_PRODUCT_NAME.""" 252 """Returns FULL_PRODUCT_NAME."""
(...skipping 26 matching lines...) Expand all
277 Chromium.app/Contents/Resources. Only valid for bundles.""" 279 Chromium.app/Contents/Resources. Only valid for bundles."""
278 assert self._IsBundle() 280 assert self._IsBundle()
279 if self.isIOS: 281 if self.isIOS:
280 return self.GetBundleContentsFolderPath() 282 return self.GetBundleContentsFolderPath()
281 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') 283 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources')
282 284
283 def GetBundlePlistPath(self): 285 def GetBundlePlistPath(self):
284 """Returns the qualified path to the bundle's plist file. E.g. 286 """Returns the qualified path to the bundle's plist file. E.g.
285 Chromium.app/Contents/Info.plist. Only valid for bundles.""" 287 Chromium.app/Contents/Info.plist. Only valid for bundles."""
286 assert self._IsBundle() 288 assert self._IsBundle()
287 if self.spec['type'] in ('executable', 'loadable_module'): 289 if self.spec['type'] in ('executable', 'extension', 'loadable_module'):
288 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') 290 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist')
289 else: 291 else:
290 return os.path.join(self.GetBundleContentsFolderPath(), 292 return os.path.join(self.GetBundleContentsFolderPath(),
291 'Resources', 'Info.plist') 293 'Resources', 'Info.plist')
292 294
293 def GetProductType(self): 295 def GetProductType(self):
294 """Returns the PRODUCT_TYPE of this target.""" 296 """Returns the PRODUCT_TYPE of this target."""
295 if self._IsBundle(): 297 if self._IsBundle():
296 return { 298 return {
297 'executable': 'com.apple.product-type.application', 299 'executable': 'com.apple.product-type.application',
300 'extension': 'com.apple.product-type.app-extension',
298 'loadable_module': 'com.apple.product-type.bundle', 301 'loadable_module': 'com.apple.product-type.bundle',
299 'shared_library': 'com.apple.product-type.framework', 302 'shared_library': 'com.apple.product-type.framework',
300 }[self.spec['type']] 303 }[self.spec['type']]
301 else: 304 else:
302 return { 305 return {
303 'executable': 'com.apple.product-type.tool', 306 'executable': 'com.apple.product-type.tool',
307 'extension': 'com.apple.product-type.app-extension',
304 'loadable_module': 'com.apple.product-type.library.dynamic', 308 'loadable_module': 'com.apple.product-type.library.dynamic',
305 'shared_library': 'com.apple.product-type.library.dynamic', 309 'shared_library': 'com.apple.product-type.library.dynamic',
306 'static_library': 'com.apple.product-type.library.static', 310 'static_library': 'com.apple.product-type.library.static',
307 }[self.spec['type']] 311 }[self.spec['type']]
308 312
309 def GetMachOType(self): 313 def GetMachOType(self):
310 """Returns the MACH_O_TYPE of this target.""" 314 """Returns the MACH_O_TYPE of this target."""
311 # Weird, but matches Xcode. 315 # Weird, but matches Xcode.
312 if not self._IsBundle() and self.spec['type'] == 'executable': 316 if not self._IsBundle() and (self.spec['type'] == 'executable' or
317 self.spec['type'] == 'extension'):
313 return '' 318 return ''
314 return { 319 return {
315 'executable': 'mh_execute', 320 'executable': 'mh_execute',
321 'extension': 'mh_execute',
316 'static_library': 'staticlib', 322 'static_library': 'staticlib',
317 'shared_library': 'mh_dylib', 323 'shared_library': 'mh_dylib',
318 'loadable_module': 'mh_bundle', 324 'loadable_module': 'mh_bundle',
319 }[self.spec['type']] 325 }[self.spec['type']]
320 326
321 def _GetBundleBinaryPath(self): 327 def _GetBundleBinaryPath(self):
322 """Returns the name of the bundle binary of by this target. 328 """Returns the name of the bundle binary of by this target.
323 E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles.""" 329 E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles."""
324 assert self._IsBundle() 330 assert self._IsBundle()
325 if self.spec['type'] in ('shared_library') or self.isIOS: 331 if self.spec['type'] in ('shared_library') or self.isIOS:
326 path = self.GetBundleContentsFolderPath() 332 path = self.GetBundleContentsFolderPath()
327 elif self.spec['type'] in ('executable', 'loadable_module'): 333 elif self.spec['type'] in ('executable', 'extension', 'loadable_module'):
328 path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS') 334 path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS')
329 return os.path.join(path, self.GetExecutableName()) 335 return os.path.join(path, self.GetExecutableName())
330 336
331 def _GetStandaloneExecutableSuffix(self): 337 def _GetStandaloneExecutableSuffix(self):
332 if 'product_extension' in self.spec: 338 if 'product_extension' in self.spec:
333 return '.' + self.spec['product_extension'] 339 return '.' + self.spec['product_extension']
334 return { 340 return {
335 'executable': '', 341 'executable': '',
342 'extension': '',
336 'static_library': '.a', 343 'static_library': '.a',
337 'shared_library': '.dylib', 344 'shared_library': '.dylib',
338 'loadable_module': '.so', 345 'loadable_module': '.so',
339 }[self.spec['type']] 346 }[self.spec['type']]
340 347
341 def _GetStandaloneExecutablePrefix(self): 348 def _GetStandaloneExecutablePrefix(self):
342 return self.spec.get('product_prefix', { 349 return self.spec.get('product_prefix', {
343 'executable': '', 350 'executable': '',
351 'extension': '',
344 'static_library': 'lib', 352 'static_library': 'lib',
345 'shared_library': 'lib', 353 'shared_library': 'lib',
346 # Non-bundled loadable_modules are called foo.so for some reason 354 # Non-bundled loadable_modules are called foo.so for some reason
347 # (that is, .so and no prefix) with the xcode build -- match that. 355 # (that is, .so and no prefix) with the xcode build -- match that.
348 'loadable_module': '', 356 'loadable_module': '',
349 }[self.spec['type']]) 357 }[self.spec['type']])
350 358
351 def _GetStandaloneBinaryPath(self): 359 def _GetStandaloneBinaryPath(self):
352 """Returns the name of the non-bundle binary represented by this target. 360 """Returns the name of the non-bundle binary represented by this target.
353 E.g. hello_world. Only valid for non-bundles.""" 361 E.g. hello_world. Only valid for non-bundles."""
354 assert not self._IsBundle() 362 assert not self._IsBundle()
355 assert self.spec['type'] in ( 363 assert self.spec['type'] in ('executable', 'extension', 'shared_library',
356 'executable', 'shared_library', 'static_library', 'loadable_module'), ( 364 'static_library', 'loadable_module'), (
357 'Unexpected type %s' % self.spec['type']) 365 'Unexpected type %s' % self.spec['type'])
358 target = self.spec['target_name'] 366 target = self.spec['target_name']
359 if self.spec['type'] == 'static_library': 367 if self.spec['type'] == 'static_library':
360 if target[:3] == 'lib': 368 if target[:3] == 'lib':
361 target = target[3:] 369 target = target[3:]
362 elif self.spec['type'] in ('loadable_module', 'shared_library'): 370 elif self.spec['type'] in ('loadable_module', 'shared_library'):
363 if target[:3] == 'lib': 371 if target[:3] == 'lib':
364 target = target[3:] 372 target = target[3:]
365 373
366 target_prefix = self._GetStandaloneExecutablePrefix() 374 target_prefix = self._GetStandaloneExecutablePrefix()
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 ldflags.append('-Wl,-rpath,' + rpath) 795 ldflags.append('-Wl,-rpath,' + rpath)
788 796
789 sdk_root = self._SdkPath() 797 sdk_root = self._SdkPath()
790 if not sdk_root: 798 if not sdk_root:
791 sdk_root = '' 799 sdk_root = ''
792 config = self.spec['configurations'][self.configname] 800 config = self.spec['configurations'][self.configname]
793 framework_dirs = config.get('mac_framework_dirs', []) 801 framework_dirs = config.get('mac_framework_dirs', [])
794 for directory in framework_dirs: 802 for directory in framework_dirs:
795 ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root)) 803 ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
796 804
805 if sdk_root and self.spec['type'] == "extension":
806 ldflags.append('-lpkstart ' + sdk_root +
807 '/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit')
justincohen 2014/07/07 14:13:58 Maybe a comment on why this has to be hard coded,
olivierrobin 2014/07/07 14:36:35 Done.
808 ldflags.append('-fapplication-extension ' +
809 '-Xlinker -rpath -Xlinker @executable_path/../../Frameworks')
810
797 self._Appendf(ldflags, 'CLANG_CXX_LIBRARY', '-stdlib=%s') 811 self._Appendf(ldflags, 'CLANG_CXX_LIBRARY', '-stdlib=%s')
798 812
799 self.configname = None 813 self.configname = None
800 return ldflags 814 return ldflags
801 815
802 def GetLibtoolflags(self, configname): 816 def GetLibtoolflags(self, configname):
803 """Returns flags that need to be passed to the static linker. 817 """Returns flags that need to be passed to the static linker.
804 818
805 Args: 819 Args:
806 configname: The name of the configuration to get ld flags for. 820 configname: The name of the configuration to get ld flags for.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 877
864 result = [] 878 result = []
865 if (self._Test('DEPLOYMENT_POSTPROCESSING', 'YES', default='NO') and 879 if (self._Test('DEPLOYMENT_POSTPROCESSING', 'YES', default='NO') and
866 self._Test('STRIP_INSTALLED_PRODUCT', 'YES', default='NO')): 880 self._Test('STRIP_INSTALLED_PRODUCT', 'YES', default='NO')):
867 881
868 default_strip_style = 'debugging' 882 default_strip_style = 'debugging'
869 if self.spec['type'] == 'loadable_module' and self._IsBundle(): 883 if self.spec['type'] == 'loadable_module' and self._IsBundle():
870 default_strip_style = 'non-global' 884 default_strip_style = 'non-global'
871 elif self.spec['type'] == 'executable': 885 elif self.spec['type'] == 'executable':
872 default_strip_style = 'all' 886 default_strip_style = 'all'
887 elif self.spec['type'] == 'extension':
888 default_strip_style = 'all'
873 889
874 strip_style = self._Settings().get('STRIP_STYLE', default_strip_style) 890 strip_style = self._Settings().get('STRIP_STYLE', default_strip_style)
875 strip_flags = { 891 strip_flags = {
876 'all': '', 892 'all': '',
877 'non-global': '-x', 893 'non-global': '-x',
878 'debugging': '-S', 894 'debugging': '-S',
879 }[strip_style] 895 }[strip_style]
880 896
881 explicit_strip_flags = self._Settings().get('STRIPFLAGS', '') 897 explicit_strip_flags = self._Settings().get('STRIPFLAGS', '')
882 if explicit_strip_flags: 898 if explicit_strip_flags:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 to run as postbuilds for this target, before the actual postbuilds.""" 930 to run as postbuilds for this target, before the actual postbuilds."""
915 # dSYMs need to build before stripping happens. 931 # dSYMs need to build before stripping happens.
916 return ( 932 return (
917 self._GetDebugInfoPostbuilds(configname, output, output_binary, quiet) + 933 self._GetDebugInfoPostbuilds(configname, output, output_binary, quiet) +
918 self._GetStripPostbuilds(configname, output_binary, quiet)) 934 self._GetStripPostbuilds(configname, output_binary, quiet))
919 935
920 def _GetIOSPostbuilds(self, configname, output_binary): 936 def _GetIOSPostbuilds(self, configname, output_binary):
921 """Return a shell command to codesign the iOS output binary so it can 937 """Return a shell command to codesign the iOS output binary so it can
922 be deployed to a device. This should be run as the very last step of the 938 be deployed to a device. This should be run as the very last step of the
923 build.""" 939 build."""
924 if not (self.isIOS and self.spec['type'] == "executable"): 940 if not (self.isIOS and (self.spec['type'] == "executable" or
941 self.spec['type'] == "extension")):
925 return [] 942 return []
926 943
927 settings = self.xcode_settings[configname] 944 settings = self.xcode_settings[configname]
928 key = self._GetIOSCodeSignIdentityKey(settings) 945 key = self._GetIOSCodeSignIdentityKey(settings)
929 if not key: 946 if not key:
930 return [] 947 return []
931 948
932 # Warn for any unimplemented signing xcode keys. 949 # Warn for any unimplemented signing xcode keys.
933 unimpl = ['OTHER_CODE_SIGN_FLAGS'] 950 unimpl = ['OTHER_CODE_SIGN_FLAGS']
934 unimpl = set(unimpl) & set(self.xcode_settings[configname].keys()) 951 unimpl = set(unimpl) & set(self.xcode_settings[configname].keys())
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 # written for bundles: 1412 # written for bundles:
1396 'TARGET_BUILD_DIR' : built_products_dir, 1413 'TARGET_BUILD_DIR' : built_products_dir,
1397 'TEMP_DIR' : '${TMPDIR}', 1414 'TEMP_DIR' : '${TMPDIR}',
1398 } 1415 }
1399 if xcode_settings.GetPerConfigSetting('SDKROOT', configuration): 1416 if xcode_settings.GetPerConfigSetting('SDKROOT', configuration):
1400 env['SDKROOT'] = xcode_settings._SdkPath(configuration) 1417 env['SDKROOT'] = xcode_settings._SdkPath(configuration)
1401 else: 1418 else:
1402 env['SDKROOT'] = '' 1419 env['SDKROOT'] = ''
1403 1420
1404 if spec['type'] in ( 1421 if spec['type'] in (
1405 'executable', 'static_library', 'shared_library', 'loadable_module'): 1422 'executable',
1423 'extension',
1424 'static_library',
1425 'shared_library',
1426 'loadable_module'):
1406 env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName() 1427 env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName()
1407 env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath() 1428 env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath()
1408 env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName() 1429 env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName()
1409 mach_o_type = xcode_settings.GetMachOType() 1430 mach_o_type = xcode_settings.GetMachOType()
1410 if mach_o_type: 1431 if mach_o_type:
1411 env['MACH_O_TYPE'] = mach_o_type 1432 env['MACH_O_TYPE'] = mach_o_type
1412 env['PRODUCT_TYPE'] = xcode_settings.GetProductType() 1433 env['PRODUCT_TYPE'] = xcode_settings.GetProductType()
1413 if xcode_settings._IsBundle(): 1434 if xcode_settings._IsBundle():
1414 env['CONTENTS_FOLDER_PATH'] = \ 1435 env['CONTENTS_FOLDER_PATH'] = \
1415 xcode_settings.GetBundleContentsFolderPath() 1436 xcode_settings.GetBundleContentsFolderPath()
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 if toolset == 'target': 1571 if toolset == 'target':
1551 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' 1572 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos'
1552 return targets 1573 return targets
1553 1574
1554 def CloneConfigurationForDeviceAndEmulator(target_dicts): 1575 def CloneConfigurationForDeviceAndEmulator(target_dicts):
1555 """If |target_dicts| contains any iOS targets, automatically create -iphoneos 1576 """If |target_dicts| contains any iOS targets, automatically create -iphoneos
1556 targets for iOS device builds.""" 1577 targets for iOS device builds."""
1557 if _HasIOSTarget(target_dicts): 1578 if _HasIOSTarget(target_dicts):
1558 return _AddIOSDeviceConfigurations(target_dicts) 1579 return _AddIOSDeviceConfigurations(target_dicts)
1559 return target_dicts 1580 return target_dicts
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698