Back to index

python3.2  3.2.2
Classes | Functions
distutils.unixccompiler Namespace Reference

Classes

class  UnixCCompiler

Functions

def _darwin_compiler_fixup

Detailed Description

distutils.unixccompiler

Contains the UnixCCompiler class, a subclass of CCompiler that handles
the "typical" Unix-style command-line C compiler:
  * macros defined with -Dname[=value]
  * macros undefined with -Uname
  * include search directories specified with -Idir
  * libraries specified with -lllib
  * library search directories specified with -Ldir
  * compile handled by 'cc' (or similar) executable with -c option:
    compiles .c to .o
  * link static library handled by 'ar' command (possibly with 'ranlib')
  * link shared library handled by 'cc -shared'

Function Documentation

def distutils.unixccompiler._darwin_compiler_fixup (   compiler_so,
  cc_args 
) [private]
This function will strip '-isysroot PATH' and '-arch ARCH' from the
compile flags if the user has specified one them in extra_compile_flags.

This is needed because '-arch ARCH' adds another architecture to the
build, without a way to remove an architecture. Furthermore GCC will
barf if multiple '-isysroot' arguments are present.

Definition at line 41 of file unixccompiler.py.

00041 
00042 def _darwin_compiler_fixup(compiler_so, cc_args):
00043     """
00044     This function will strip '-isysroot PATH' and '-arch ARCH' from the
00045     compile flags if the user has specified one them in extra_compile_flags.
00046 
00047     This is needed because '-arch ARCH' adds another architecture to the
00048     build, without a way to remove an architecture. Furthermore GCC will
00049     barf if multiple '-isysroot' arguments are present.
00050     """
00051     stripArch = stripSysroot = False
00052 
00053     compiler_so = list(compiler_so)
00054     kernel_version = os.uname()[2] # 8.4.3
00055     major_version = int(kernel_version.split('.')[0])
00056 
00057     if major_version < 8:
00058         # OSX before 10.4.0, these don't support -arch and -isysroot at
00059         # all.
00060         stripArch = stripSysroot = True
00061     else:
00062         stripArch = '-arch' in cc_args
00063         stripSysroot = '-isysroot' in cc_args
00064 
00065     if stripArch or 'ARCHFLAGS' in os.environ:
00066         while True:
00067             try:
00068                 index = compiler_so.index('-arch')
00069                 # Strip this argument and the next one:
00070                 del compiler_so[index:index+2]
00071             except ValueError:
00072                 break
00073 
00074     if 'ARCHFLAGS' in os.environ and not stripArch:
00075         # User specified different -arch flags in the environ,
00076         # see also distutils.sysconfig
00077         compiler_so = compiler_so + os.environ['ARCHFLAGS'].split()
00078 
00079     if stripSysroot:
00080         try:
00081             index = compiler_so.index('-isysroot')
00082             # Strip this argument and the next one:
00083             del compiler_so[index:index+2]
00084         except ValueError:
00085             pass
00086 
00087     # Check if the SDK that is used during compilation actually exists,
00088     # the universal build requires the usage of a universal SDK and not all
00089     # users have that installed by default.
00090     sysroot = None
00091     if '-isysroot' in cc_args:
00092         idx = cc_args.index('-isysroot')
00093         sysroot = cc_args[idx+1]
00094     elif '-isysroot' in compiler_so:
00095         idx = compiler_so.index('-isysroot')
00096         sysroot = compiler_so[idx+1]
00097 
00098     if sysroot and not os.path.isdir(sysroot):
00099         log.warn("Compiling with an SDK that doesn't seem to exist: %s",
00100                 sysroot)
00101         log.warn("Please check your Xcode installation")
00102 
00103     return compiler_so

Here is the call graph for this function:

Here is the caller graph for this function: