U +am:@sdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z ddl m Z mZmZmZddlmZejdkr~ddlZGd d d e ZdS) a9distutils.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' N) sysconfig)newer) CCompilergen_preprocess_optionsgen_lib_options)DistutilsExecError CompileErrorLibError LinkError)logdarwinc @seZdZdZddgdgdgddgdgddgddZejddd krNd ged <d d d dddgZdZdZ dZ dZ dZ dZ ZZeZejdkrdZd,ddZddZd-ddZd.d d!Zd"d#Zd$d%Zd&d'Zd(d)Zd/d*d+ZdS)0 UnixCCompilerunixNccz-sharedarz-cr) preprocessorcompiler compiler_so compiler_cxx linker_so linker_exearchiverranlibr rz.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%scygwinz.exec Cs|d||}|\}}}t||} |j| } |r>| d|g|rN|| dd<|r\| || ||js~|dks~t||r|r|tj |z| | Wn*t k r} z t | W5d} ~ XYnXdS)N-or)Z_fix_compile_argsrrextendappendforcermkpathospathdirnamespawnrr) selfsourceZ output_fileZmacros include_dirs extra_preargsextra_postargs fixed_argsignorepp_optsZpp_argsmsgr-K/tmp/pip-install-1bd_1mtk/setuptools/setuptools/_distutils/unixccompiler.py preprocessUs$      zUnixCCompiler.preprocessc Csp|j}tjdkr t|||}z ||||d|g|Wn*tk rj}z t|W5d}~XYnXdS)Nr r)rsysplatform _osx_supportcompiler_fixupr#rr) r$objsrcextZcc_argsr(r+rr,r-r-r._compileos  zUnixCCompiler._compilerc Cs|||\}}|j||d}|||r|tj|||j|g||j |j rz||j |gWqt k r}z t |W5d}~XYqXn t d|dS)N) output_dirskipping %s (up-to-date))_fix_object_argslibrary_filename _need_linkrr r!r"r#robjectsrrr r debug)r$r=Zoutput_libnamer8r> target_langoutput_filenamer,r-r-r.create_static_libzs$   zUnixCCompiler.create_static_libc Cs|||\}}||||}|\}}}t||||}t|ttdfsPtd|dk rftj ||}| ||r||j |d|g}| rdg|dd<| r| |dd<| r| | | tj|z|tjkr|jdd}n|jdd}| dkrr|jrrd}tj|ddkr@d}d||kr@|d7}q&tj||d kr\d}nd}|j||||<tjd krt||}|||Wn,tk r}z t|W5d}~XYnXn td |dS) Nz%'output_dir' must be a string or Nonerz-grzc++env=Z ld_so_aixr r9)r:Z _fix_lib_argsr isinstancestrtype TypeErrorr r!joinr<r=rrr"rZ EXECUTABLErrrbasenamer0r1r2r3r#rr r r>)r$Z target_descr=r@r8 libraries library_dirsruntime_library_dirsexport_symbolsr>r'r( build_tempr?r)Zlib_optsZld_argsZlinkerioffsetr,r-r-r.linksZ       zUnixCCompiler.linkcCsd|S)N-Lr-)r$dirr-r-r.library_dir_optionsz UnixCCompiler.library_dir_optioncCsd|kpd|kS)Ngcczg++r-)r$Z compiler_namer-r-r._is_gccszUnixCCompiler._is_gcccCstjtd}tjdddkr`ddlm}m }|}|rV||ddgkrVd|Sd |Sntjdd d krzd |Stjddd kr| |rdd |gSdd |gS| |rtddkrd|Sd|Snd|SdS)NCCrr r)get_macosx_target_ver split_version z -Wl,-rpath,rSZfreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sGNULDyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R) r r!rJrget_config_varr0r1distutils.utilrYrZrW)r$rTrrYrZZmacosx_target_verr-r-r.runtime_library_dir_options$      z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr-)r$libr-r-r.library_option szUnixCCompiler.library_optioncCs|j|dd}|j|dd}|j|dd}|j|dd}tjdkrptd}td|} | dkrfd } n | d } |D] } tj | |} tj | |} tj | |}tj | |}tjdkr@| d s| d r@| d s@tj | | d d|} tj | | d d|} tj | | d d|}tj | | d d|}tj | rV| Stj |rl|Stj | r| Stj |rt|SqtdS)Nshared)Zlib_typedylib xcode_stubstaticr CFLAGSz-isysroot\s*(\S+)/rCz/System/z/usr/z /usr/local/) r;r0r1rr`researchgroupr r!rI startswithexists)r$dirsrcr>Zshared_fZdylib_fZ xcode_stub_fZstatic_fcflagsmZsysrootrTrerfrhrgr-r-r.find_library_file sF        zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__ compiler_typeZ executablesr0r1Zsrc_extensionsZ obj_extensionZstatic_lib_extensionshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ exe_extensionr/r7rArRrUrWrbrdrsr-r-r-r.r -s`       B.r )__doc__r r0rk distutilsrdistutils.dep_utilrdistutils.ccompilerrrrdistutils.errorsrrr r r r1r2r r-r-r-r.s