Changeset 391 for python/trunk/Lib/distutils/unixccompiler.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/distutils/unixccompiler.py
r10 r391 14 14 """ 15 15 16 __revision__ = "$Id : unixccompiler.py 77378 2010-01-08 23:48:37Z tarek.ziade$"17 18 import os, sys 16 __revision__ = "$Id$" 17 18 import os, sys, re 19 19 from types import StringType, NoneType 20 20 … … 26 26 DistutilsExecError, CompileError, LibError, LinkError 27 27 from distutils import log 28 29 if sys.platform == 'darwin': 30 import _osx_support 28 31 29 32 # XXX Things not currently handled: … … 42 45 # options and carry on. 43 46 44 def _darwin_compiler_fixup(compiler_so, cc_args):45 """46 This function will strip '-isysroot PATH' and '-arch ARCH' from the47 compile flags if the user has specified one them in extra_compile_flags.48 49 This is needed because '-arch ARCH' adds another architecture to the50 build, without a way to remove an architecture. Furthermore GCC will51 barf if multiple '-isysroot' arguments are present.52 """53 stripArch = stripSysroot = 054 55 compiler_so = list(compiler_so)56 kernel_version = os.uname()[2] # 8.4.357 major_version = int(kernel_version.split('.')[0])58 59 if major_version < 8:60 # OSX before 10.4.0, these don't support -arch and -isysroot at61 # all.62 stripArch = stripSysroot = True63 else:64 stripArch = '-arch' in cc_args65 stripSysroot = '-isysroot' in cc_args66 67 if stripArch or 'ARCHFLAGS' in os.environ:68 while 1:69 try:70 index = compiler_so.index('-arch')71 # Strip this argument and the next one:72 del compiler_so[index:index+2]73 except ValueError:74 break75 76 if 'ARCHFLAGS' in os.environ and not stripArch:77 # User specified different -arch flags in the environ,78 # see also distutils.sysconfig79 compiler_so = compiler_so + os.environ['ARCHFLAGS'].split()80 81 if stripSysroot:82 try:83 index = compiler_so.index('-isysroot')84 # Strip this argument and the next one:85 del compiler_so[index:index+2]86 except ValueError:87 pass88 89 # Check if the SDK that is used during compilation actually exists,90 # the universal build requires the usage of a universal SDK and not all91 # users have that installed by default.92 sysroot = None93 if '-isysroot' in cc_args:94 idx = cc_args.index('-isysroot')95 sysroot = cc_args[idx+1]96 elif '-isysroot' in compiler_so:97 idx = compiler_so.index('-isysroot')98 sysroot = compiler_so[idx+1]99 100 if sysroot and not os.path.isdir(sysroot):101 log.warn("Compiling with an SDK that doesn't seem to exist: %s",102 sysroot)103 log.warn("Please check your Xcode installation")104 105 return compiler_so106 47 107 48 class UnixCCompiler(CCompiler): … … 173 114 compiler_so = self.compiler_so 174 115 if sys.platform == 'darwin': 175 compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) 116 compiler_so = _osx_support.compiler_fixup(compiler_so, 117 cc_args + extra_postargs) 176 118 try: 177 119 self.spawn(compiler_so + cc_args + [src, '-o', obj] + … … 252 194 253 195 if sys.platform == 'darwin': 254 linker = _ darwin_compiler_fixup(linker, ld_args)196 linker = _osx_support.compiler_fixup(linker, ld_args) 255 197 256 198 self.spawn(linker + ld_args) … … 306 248 static_f = self.library_filename(lib, lib_type='static') 307 249 250 if sys.platform == 'darwin': 251 # On OSX users can specify an alternate SDK using 252 # '-isysroot', calculate the SDK root if it is specified 253 # (and use it further on) 254 cflags = sysconfig.get_config_var('CFLAGS') 255 m = re.search(r'-isysroot\s+(\S+)', cflags) 256 if m is None: 257 sysroot = '/' 258 else: 259 sysroot = m.group(1) 260 261 262 308 263 for dir in dirs: 309 264 shared = os.path.join(dir, shared_f) 310 265 dylib = os.path.join(dir, dylib_f) 311 266 static = os.path.join(dir, static_f) 267 268 if sys.platform == 'darwin' and ( 269 dir.startswith('/System/') or ( 270 dir.startswith('/usr/') and not dir.startswith('/usr/local/'))): 271 272 shared = os.path.join(sysroot, dir[1:], shared_f) 273 dylib = os.path.join(sysroot, dir[1:], dylib_f) 274 static = os.path.join(sysroot, dir[1:], static_f) 275 312 276 # We're second-guessing the linker here, with not much hard 313 277 # data to go on: GCC seems to prefer the shared library, so I'm
Note:
See TracChangeset
for help on using the changeset viewer.