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

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

Issue 739303003: Cleanup pylint errors (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: it's clean now Created 6 years, 1 month 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
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 For "iphoneos" and "iphonesimulator" SDKROOT, 64-bit architectures are part 108 For "iphoneos" and "iphonesimulator" SDKROOT, 64-bit architectures are part
109 of $(ARCHS_STANDARD_INCLUDING_64_BIT) from Xcode 5.0. From Xcode 5.1, they 109 of $(ARCHS_STANDARD_INCLUDING_64_BIT) from Xcode 5.0. From Xcode 5.1, they
110 are also part of $(ARCHS_STANDARD). 110 are also part of $(ARCHS_STANDARD).
111 111
112 All thoses rules are coded in the construction of the |XcodeArchsDefault| 112 All thoses rules are coded in the construction of the |XcodeArchsDefault|
113 object to use depending on the version of Xcode detected. The object is 113 object to use depending on the version of Xcode detected. The object is
114 for performance reason.""" 114 for performance reason."""
115 global XCODE_ARCHS_DEFAULT_CACHE 115 global XCODE_ARCHS_DEFAULT_CACHE
116 if XCODE_ARCHS_DEFAULT_CACHE: 116 if XCODE_ARCHS_DEFAULT_CACHE:
117 return XCODE_ARCHS_DEFAULT_CACHE 117 return XCODE_ARCHS_DEFAULT_CACHE
118 # pylint: disable=unpacking-non-sequence
118 xcode_version, _ = XcodeVersion() 119 xcode_version, _ = XcodeVersion()
119 if xcode_version < '0500': 120 if xcode_version < '0500':
120 XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault( 121 XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
121 '$(ARCHS_STANDARD)', 122 '$(ARCHS_STANDARD)',
122 XcodeArchsVariableMapping(['i386']), 123 XcodeArchsVariableMapping(['i386']),
123 XcodeArchsVariableMapping(['i386']), 124 XcodeArchsVariableMapping(['i386']),
124 XcodeArchsVariableMapping(['armv7'])) 125 XcodeArchsVariableMapping(['armv7']))
125 elif xcode_version < '0510': 126 elif xcode_version < '0510':
126 XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault( 127 XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
127 '$(ARCHS_STANDARD_INCLUDING_64_BIT)', 128 '$(ARCHS_STANDARD_INCLUDING_64_BIT)',
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 return install_name 707 return install_name
707 708
708 def _MapLinkerFlagFilename(self, ldflag, gyp_to_build_path): 709 def _MapLinkerFlagFilename(self, ldflag, gyp_to_build_path):
709 """Checks if ldflag contains a filename and if so remaps it from 710 """Checks if ldflag contains a filename and if so remaps it from
710 gyp-directory-relative to build-directory-relative.""" 711 gyp-directory-relative to build-directory-relative."""
711 # This list is expanded on demand. 712 # This list is expanded on demand.
712 # They get matched as: 713 # They get matched as:
713 # -exported_symbols_list file 714 # -exported_symbols_list file
714 # -Wl,exported_symbols_list file 715 # -Wl,exported_symbols_list file
715 # -Wl,exported_symbols_list,file 716 # -Wl,exported_symbols_list,file
716 LINKER_FILE = '(\S+)' 717 LINKER_FILE = r'r(\S+)'
717 WORD = '\S+' 718 WORD = r'r\S+'
718 linker_flags = [ 719 linker_flags = [
719 ['-exported_symbols_list', LINKER_FILE], # Needed for NaCl. 720 ['-exported_symbols_list', LINKER_FILE], # Needed for NaCl.
720 ['-unexported_symbols_list', LINKER_FILE], 721 ['-unexported_symbols_list', LINKER_FILE],
721 ['-reexported_symbols_list', LINKER_FILE], 722 ['-reexported_symbols_list', LINKER_FILE],
722 ['-sectcreate', WORD, WORD, LINKER_FILE], # Needed for remoting. 723 ['-sectcreate', WORD, WORD, LINKER_FILE], # Needed for remoting.
723 ] 724 ]
724 for flag_pattern in linker_flags: 725 for flag_pattern in linker_flags:
725 regex = re.compile('(?:-Wl,)?' + '[ ,]'.join(flag_pattern)) 726 regex = re.compile('(?:-Wl,)?' + '[ ,]'.join(flag_pattern))
726 m = regex.match(ldflag) 727 m = regex.match(ldflag)
727 if m: 728 if m:
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 def _XcodeIOSDeviceFamily(self, configname): 1020 def _XcodeIOSDeviceFamily(self, configname):
1020 family = self.xcode_settings[configname].get('TARGETED_DEVICE_FAMILY', '1') 1021 family = self.xcode_settings[configname].get('TARGETED_DEVICE_FAMILY', '1')
1021 return [int(x) for x in family.split(',')] 1022 return [int(x) for x in family.split(',')]
1022 1023
1023 def GetExtraPlistItems(self, configname=None): 1024 def GetExtraPlistItems(self, configname=None):
1024 """Returns a dictionary with extra items to insert into Info.plist.""" 1025 """Returns a dictionary with extra items to insert into Info.plist."""
1025 if configname not in XcodeSettings._plist_cache: 1026 if configname not in XcodeSettings._plist_cache:
1026 cache = {} 1027 cache = {}
1027 cache['BuildMachineOSBuild'] = self._BuildMachineOSBuild() 1028 cache['BuildMachineOSBuild'] = self._BuildMachineOSBuild()
1028 1029
1030 # pylint: disable=unpacking-non-sequence
scottmg 2014/11/20 07:29:12 there seems to be enough of these, maybe it would
Shezan Baig (Bloomberg) 2014/11/20 07:48:22 Makes sense, will do.
1029 xcode, xcode_build = XcodeVersion() 1031 xcode, xcode_build = XcodeVersion()
1030 cache['DTXcode'] = xcode 1032 cache['DTXcode'] = xcode
1031 cache['DTXcodeBuild'] = xcode_build 1033 cache['DTXcodeBuild'] = xcode_build
1032 1034
1033 sdk_root = self._SdkRoot(configname) 1035 sdk_root = self._SdkRoot(configname)
1034 if not sdk_root: 1036 if not sdk_root:
1035 sdk_root = self._DefaultSdkRoot() 1037 sdk_root = self._DefaultSdkRoot()
1036 cache['DTSDKName'] = sdk_root 1038 cache['DTSDKName'] = sdk_root
1037 if xcode >= '0430': 1039 if xcode >= '0430':
1038 cache['DTSDKBuild'] = self._GetSdkVersionInfoItem( 1040 cache['DTSDKBuild'] = self._GetSdkVersionInfoItem(
(...skipping 18 matching lines...) Expand all
1057 items['UIDeviceFamily'] = self._XcodeIOSDeviceFamily(configname) 1059 items['UIDeviceFamily'] = self._XcodeIOSDeviceFamily(configname)
1058 return items 1060 return items
1059 1061
1060 def _DefaultSdkRoot(self): 1062 def _DefaultSdkRoot(self):
1061 """Returns the default SDKROOT to use. 1063 """Returns the default SDKROOT to use.
1062 1064
1063 Prior to version 5.0.0, if SDKROOT was not explicitly set in the Xcode 1065 Prior to version 5.0.0, if SDKROOT was not explicitly set in the Xcode
1064 project, then the environment variable was empty. Starting with this 1066 project, then the environment variable was empty. Starting with this
1065 version, Xcode uses the name of the newest SDK installed. 1067 version, Xcode uses the name of the newest SDK installed.
1066 """ 1068 """
1069 # pylint: disable=unpacking-non-sequence
1067 xcode_version, xcode_build = XcodeVersion() 1070 xcode_version, xcode_build = XcodeVersion()
1068 if xcode_version < '0500': 1071 if xcode_version < '0500':
1069 return '' 1072 return ''
1070 default_sdk_path = self._XcodeSdkPath('') 1073 default_sdk_path = self._XcodeSdkPath('')
1071 default_sdk_root = XcodeSettings._sdk_root_cache.get(default_sdk_path) 1074 default_sdk_root = XcodeSettings._sdk_root_cache.get(default_sdk_path)
1072 if default_sdk_root: 1075 if default_sdk_root:
1073 return default_sdk_root 1076 return default_sdk_root
1074 try: 1077 try:
1075 all_sdks = GetStdout(['xcodebuild', '-showsdks']) 1078 all_sdks = GetStdout(['xcodebuild', '-showsdks'])
1076 except: 1079 except:
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 if XCODE_VERSION_CACHE: 1209 if XCODE_VERSION_CACHE:
1207 return XCODE_VERSION_CACHE 1210 return XCODE_VERSION_CACHE
1208 try: 1211 try:
1209 version_list = GetStdout(['xcodebuild', '-version']).splitlines() 1212 version_list = GetStdout(['xcodebuild', '-version']).splitlines()
1210 # In some circumstances xcodebuild exits 0 but doesn't return 1213 # In some circumstances xcodebuild exits 0 but doesn't return
1211 # the right results; for example, a user on 10.7 or 10.8 with 1214 # the right results; for example, a user on 10.7 or 10.8 with
1212 # a bogus path set via xcode-select 1215 # a bogus path set via xcode-select
1213 # In that case this may be a CLT-only install so fall back to 1216 # In that case this may be a CLT-only install so fall back to
1214 # checking that version. 1217 # checking that version.
1215 if len(version_list) < 2: 1218 if len(version_list) < 2:
1216 raise GypError, "xcodebuild returned unexpected results" 1219 raise GypError("xcodebuild returned unexpected results")
1217 except: 1220 except:
1218 version = CLTVersion() 1221 version = CLTVersion()
1219 if version: 1222 if version:
1220 version = re.match('(\d\.\d\.?\d*)', version).groups()[0] 1223 version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
1221 else: 1224 else:
1222 raise GypError, "No Xcode or CLT version detected!" 1225 raise GypError("No Xcode or CLT version detected!")
1223 # The CLT has no build information, so we return an empty string. 1226 # The CLT has no build information, so we return an empty string.
1224 version_list = [version, ''] 1227 version_list = [version, '']
1225 version = version_list[0] 1228 version = version_list[0]
1226 build = version_list[-1] 1229 build = version_list[-1]
1227 # Be careful to convert "4.2" to "0420": 1230 # Be careful to convert "4.2" to "0420":
1228 version = version.split()[-1].replace('.', '') 1231 version = version.split()[-1].replace('.', '')
1229 version = (version + '0' * (3 - len(version))).zfill(4) 1232 version = (version + '0' * (3 - len(version))).zfill(4)
1230 if build: 1233 if build:
1231 build = build.split()[-1] 1234 build = build.split()[-1]
1232 XCODE_VERSION_CACHE = (version, build) 1235 XCODE_VERSION_CACHE = (version, build)
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 if toolset == 'target': 1575 if toolset == 'target':
1573 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' 1576 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos'
1574 return targets 1577 return targets
1575 1578
1576 def CloneConfigurationForDeviceAndEmulator(target_dicts): 1579 def CloneConfigurationForDeviceAndEmulator(target_dicts):
1577 """If |target_dicts| contains any iOS targets, automatically create -iphoneos 1580 """If |target_dicts| contains any iOS targets, automatically create -iphoneos
1578 targets for iOS device builds.""" 1581 targets for iOS device builds."""
1579 if _HasIOSTarget(target_dicts): 1582 if _HasIOSTarget(target_dicts):
1580 return _AddIOSDeviceConfigurations(target_dicts) 1583 return _AddIOSDeviceConfigurations(target_dicts)
1581 return target_dicts 1584 return target_dicts
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698