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

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

Issue 117013003: asdfasfsaf (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 def _GetStdout(self, cmdlist): 274 def _GetStdout(self, cmdlist):
275 job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE) 275 job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)
276 out = job.communicate()[0] 276 out = job.communicate()[0]
277 if job.returncode != 0: 277 if job.returncode != 0:
278 sys.stderr.write(out + '\n') 278 sys.stderr.write(out + '\n')
279 raise GypError('Error %d running %s' % (job.returncode, cmdlist[0])) 279 raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
280 return out.rstrip('\n') 280 return out.rstrip('\n')
281 281
282 def _GetSdkVersionInfoItem(self, sdk, infoitem): 282 def _GetSdkVersionInfoItem(self, sdk, infoitem):
283 return self._GetStdout(['xcodebuild', '-version', '-sdk', sdk, infoitem]) 283 # xcodebuild requires Xcode and can't run on Command Line Tools-only
284 # systems from 10.7 onward.
285 # Since the CLT has no SDK paths anyway, returning None is the
286 # most sensible route and should still do the right thing.
287 try:
288 return self._GetStdout(['xcodebuild', '-version', '-sdk', sdk, infoitem])
289 except:
290 pass
284 291
285 def _SdkRoot(self, configname): 292 def _SdkRoot(self, configname):
286 if configname is None: 293 if configname is None:
287 configname = self.configname 294 configname = self.configname
288 return self.GetPerConfigSetting('SDKROOT', configname, default='') 295 return self.GetPerConfigSetting('SDKROOT', configname, default='')
289 296
290 def _SdkPath(self, configname=None): 297 def _SdkPath(self, configname=None):
291 sdk_root = self._SdkRoot(configname) 298 sdk_root = self._SdkRoot(configname)
292 if sdk_root.startswith('/'): 299 if sdk_root.startswith('/'):
293 return sdk_root 300 return sdk_root
(...skipping 22 matching lines...) Expand all
316 def GetCflags(self, configname, arch=None): 323 def GetCflags(self, configname, arch=None):
317 """Returns flags that need to be added to .c, .cc, .m, and .mm 324 """Returns flags that need to be added to .c, .cc, .m, and .mm
318 compilations.""" 325 compilations."""
319 # This functions (and the similar ones below) do not offer complete 326 # This functions (and the similar ones below) do not offer complete
320 # emulation of all xcode_settings keys. They're implemented on demand. 327 # emulation of all xcode_settings keys. They're implemented on demand.
321 328
322 self.configname = configname 329 self.configname = configname
323 cflags = [] 330 cflags = []
324 331
325 sdk_root = self._SdkPath() 332 sdk_root = self._SdkPath()
326 if 'SDKROOT' in self._Settings(): 333 if 'SDKROOT' in self._Settings() and sdk_root:
327 cflags.append('-isysroot %s' % sdk_root) 334 cflags.append('-isysroot %s' % sdk_root)
328 335
329 if self._Test('CLANG_WARN_CONSTANT_CONVERSION', 'YES', default='NO'): 336 if self._Test('CLANG_WARN_CONSTANT_CONVERSION', 'YES', default='NO'):
330 cflags.append('-Wconstant-conversion') 337 cflags.append('-Wconstant-conversion')
331 338
332 if self._Test('GCC_CHAR_IS_UNSIGNED_CHAR', 'YES', default='NO'): 339 if self._Test('GCC_CHAR_IS_UNSIGNED_CHAR', 'YES', default='NO'):
333 cflags.append('-funsigned-char') 340 cflags.append('-funsigned-char')
334 341
335 if self._Test('GCC_CW_ASM_SYNTAX', 'YES', default='YES'): 342 if self._Test('GCC_CW_ASM_SYNTAX', 'YES', default='YES'):
336 cflags.append('-fasm-blocks') 343 cflags.append('-fasm-blocks')
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if self._Test('GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS', 'YES', 409 if self._Test('GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS', 'YES',
403 default='NO'): 410 default='NO'):
404 cflags.append('-mssse3') # Note 3rd 's'. 411 cflags.append('-mssse3') # Note 3rd 's'.
405 if self._Test('GCC_ENABLE_SSE41_EXTENSIONS', 'YES', default='NO'): 412 if self._Test('GCC_ENABLE_SSE41_EXTENSIONS', 'YES', default='NO'):
406 cflags.append('-msse4.1') 413 cflags.append('-msse4.1')
407 if self._Test('GCC_ENABLE_SSE42_EXTENSIONS', 'YES', default='NO'): 414 if self._Test('GCC_ENABLE_SSE42_EXTENSIONS', 'YES', default='NO'):
408 cflags.append('-msse4.2') 415 cflags.append('-msse4.2')
409 416
410 cflags += self._Settings().get('WARNING_CFLAGS', []) 417 cflags += self._Settings().get('WARNING_CFLAGS', [])
411 418
419 if sdk_root:
420 framework_root = sdk_root
421 else:
422 framework_root = ''
412 config = self.spec['configurations'][self.configname] 423 config = self.spec['configurations'][self.configname]
413 framework_dirs = config.get('mac_framework_dirs', []) 424 framework_dirs = config.get('mac_framework_dirs', [])
414 for directory in framework_dirs: 425 for directory in framework_dirs:
415 cflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root)) 426 cflags.append('-F' + directory.replace('$(SDKROOT)', framework_root))
416 427
417 self.configname = None 428 self.configname = None
418 return cflags 429 return cflags
419 430
420 def GetCflagsC(self, configname): 431 def GetCflagsC(self, configname):
421 """Returns flags that need to be added to .c, and .m compilations.""" 432 """Returns flags that need to be added to .c, and .m compilations."""
422 self.configname = configname 433 self.configname = configname
423 cflags_c = [] 434 cflags_c = []
424 if self._Settings().get('GCC_C_LANGUAGE_STANDARD', '') == 'ansi': 435 if self._Settings().get('GCC_C_LANGUAGE_STANDARD', '') == 'ansi':
425 cflags_c.append('-ansi') 436 cflags_c.append('-ansi')
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if self._Test('PREBINDING', 'YES', default='NO'): 632 if self._Test('PREBINDING', 'YES', default='NO'):
622 ldflags.append('-Wl,-prebind') 633 ldflags.append('-Wl,-prebind')
623 634
624 self._Appendf( 635 self._Appendf(
625 ldflags, 'DYLIB_COMPATIBILITY_VERSION', '-compatibility_version %s') 636 ldflags, 'DYLIB_COMPATIBILITY_VERSION', '-compatibility_version %s')
626 self._Appendf( 637 self._Appendf(
627 ldflags, 'DYLIB_CURRENT_VERSION', '-current_version %s') 638 ldflags, 'DYLIB_CURRENT_VERSION', '-current_version %s')
628 639
629 self._AppendPlatformVersionMinFlags(ldflags) 640 self._AppendPlatformVersionMinFlags(ldflags)
630 641
631 if 'SDKROOT' in self._Settings(): 642 if 'SDKROOT' in self._Settings() and self._SdkPath():
632 ldflags.append('-isysroot ' + self._SdkPath()) 643 ldflags.append('-isysroot ' + self._SdkPath())
633 644
634 for library_path in self._Settings().get('LIBRARY_SEARCH_PATHS', []): 645 for library_path in self._Settings().get('LIBRARY_SEARCH_PATHS', []):
635 ldflags.append('-L' + gyp_to_build_path(library_path)) 646 ldflags.append('-L' + gyp_to_build_path(library_path))
636 647
637 if 'ORDER_FILE' in self._Settings(): 648 if 'ORDER_FILE' in self._Settings():
638 ldflags.append('-Wl,-order_file ' + 649 ldflags.append('-Wl,-order_file ' +
639 '-Wl,' + gyp_to_build_path( 650 '-Wl,' + gyp_to_build_path(
640 self._Settings()['ORDER_FILE'])) 651 self._Settings()['ORDER_FILE']))
641 652
(...skipping 10 matching lines...) Expand all
652 # Xcode adds the product directory by default. 663 # Xcode adds the product directory by default.
653 ldflags.append('-L' + product_dir) 664 ldflags.append('-L' + product_dir)
654 665
655 install_name = self.GetInstallName() 666 install_name = self.GetInstallName()
656 if install_name and self.spec['type'] != 'loadable_module': 667 if install_name and self.spec['type'] != 'loadable_module':
657 ldflags.append('-install_name ' + install_name.replace(' ', r'\ ')) 668 ldflags.append('-install_name ' + install_name.replace(' ', r'\ '))
658 669
659 for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []): 670 for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []):
660 ldflags.append('-Wl,-rpath,' + rpath) 671 ldflags.append('-Wl,-rpath,' + rpath)
661 672
673 sdk_root = self._SdkPath()
674 if not sdk_root:
675 sdk_root = ''
662 config = self.spec['configurations'][self.configname] 676 config = self.spec['configurations'][self.configname]
663 framework_dirs = config.get('mac_framework_dirs', []) 677 framework_dirs = config.get('mac_framework_dirs', [])
664 for directory in framework_dirs: 678 for directory in framework_dirs:
665 ldflags.append('-F' + directory.replace('$(SDKROOT)', self._SdkPath())) 679 ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
666 680
667 self.configname = None 681 self.configname = None
668 return ldflags 682 return ldflags
669 683
670 def GetLibtoolflags(self, configname): 684 def GetLibtoolflags(self, configname):
671 """Returns flags that need to be passed to the static linker. 685 """Returns flags that need to be passed to the static linker.
672 686
673 Args: 687 Args:
674 configname: The name of the configuration to get ld flags for. 688 configname: The name of the configuration to get ld flags for.
675 """ 689 """
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 852
839 def _AdjustLibrary(self, library, config_name=None): 853 def _AdjustLibrary(self, library, config_name=None):
840 if library.endswith('.framework'): 854 if library.endswith('.framework'):
841 l = '-framework ' + os.path.splitext(os.path.basename(library))[0] 855 l = '-framework ' + os.path.splitext(os.path.basename(library))[0]
842 else: 856 else:
843 m = self.library_re.match(library) 857 m = self.library_re.match(library)
844 if m: 858 if m:
845 l = '-l' + m.group(1) 859 l = '-l' + m.group(1)
846 else: 860 else:
847 l = library 861 l = library
848 return l.replace('$(SDKROOT)', self._SdkPath(config_name)) 862
863 sdk_root = self._SdkPath(config_name)
864 if not sdk_root:
865 sdk_root = ''
866 return l.replace('$(SDKROOT)', sdk_root)
849 867
850 def AdjustLibraries(self, libraries, config_name=None): 868 def AdjustLibraries(self, libraries, config_name=None):
851 """Transforms entries like 'Cocoa.framework' in libraries into entries like 869 """Transforms entries like 'Cocoa.framework' in libraries into entries like
852 '-framework Cocoa', 'libcrypto.dylib' into '-lcrypto', etc. 870 '-framework Cocoa', 'libcrypto.dylib' into '-lcrypto', etc.
853 """ 871 """
854 libraries = [self._AdjustLibrary(library, config_name) 872 libraries = [self._AdjustLibrary(library, config_name)
855 for library in libraries] 873 for library in libraries]
856 return libraries 874 return libraries
857 875
858 def _BuildMachineOSBuild(self): 876 def _BuildMachineOSBuild(self):
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 new_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' 1389 new_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos'
1372 target_dict['configurations'][new_config_name] = new_config_dict 1390 target_dict['configurations'][new_config_name] = new_config_dict
1373 return targets 1391 return targets
1374 1392
1375 def CloneConfigurationForDeviceAndEmulator(target_dicts): 1393 def CloneConfigurationForDeviceAndEmulator(target_dicts):
1376 """If |target_dicts| contains any iOS targets, automatically create -iphoneos 1394 """If |target_dicts| contains any iOS targets, automatically create -iphoneos
1377 targets for iOS device builds.""" 1395 targets for iOS device builds."""
1378 if _HasIOSTarget(target_dicts): 1396 if _HasIOSTarget(target_dicts):
1379 return _AddIOSDeviceConfigurations(target_dicts) 1397 return _AddIOSDeviceConfigurations(target_dicts)
1380 return target_dicts 1398 return target_dicts
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698