o _a8@sdZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z ddl mZmZmZmZddlmZejdkrCddlZGd 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 kr'd ged <gd Zd Zd Z dZ dZ dZ dZ ZZeZejdkrDdZ  d'ddZddZ d(ddZ    d)ddZddZdd Zd!d"Zd#d$Zd*d%d&ZdS)+ UnixCCompilerunixNccz-sharedarz-cr) preprocessorcompiler compiler_so compiler_cxx linker_so linker_exearchiverranlibr r)z.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%scygwinz.exec Cs|d||}|\}}}t||} |j| } |r| d|g|r'|| dd<|r.| || ||js?|dus?t||rc|rJ|tj |z| | WdSt yb} zt | d} ~ wwdS)N-or)_fix_compile_argsrrextendappendforcermkpathospathdirnamespawnrr) selfsource output_filemacros include_dirs extra_preargsextra_postargs fixed_argsignorepp_optspp_argsmsgr1E/usr/lib/python3/dist-packages/setuptools/_distutils/unixccompiler.py preprocessUs*      zUnixCCompiler.preprocessc Csd|j}tjdkrt|||}z||||d|g|WdSty1}zt|d}~ww)Nr r)rsysplatform _osx_supportcompiler_fixupr$rr) r%objsrcextcc_argsr+r.rr0r1r1r2_compileos  zUnixCCompiler._compilerc Cs|||\}}|j||d}|||rN|tj|||j|g||j |j rLz ||j |gWdSt yK}zt |d}~wwdSt d|dS)N) output_dirskipping %s (up-to-date))_fix_object_argslibrary_filename _need_linkr r!r"r#r$robjectsrrr r debug)r%rBoutput_libnamer=rC target_langoutput_filenamer0r1r1r2create_static_libzs*   zUnixCCompiler.create_static_libc Cs|||\}}||||}|\}}}t||||}t|ttdfs(td|dur3tj ||}| ||r||j |d|g}| rMdg|dd<| rU| |dd<| r\| | | tj|zf|tjkrs|jdd}n|jdd}| dkr|jrd}tj|ddkrd}d||vr|d7}d||vstj||d krd}nd}|j||||<tjd krt||}|||WdSty}zt|d}~wwtd |dS) Nz%'output_dir' must be a string or Nonerz-grzc++env= ld_so_aixr r>)r? _fix_lib_argsr isinstancestrtype TypeErrorr!r"joinrArBrr r#r EXECUTABLErrrbasenamer4r5r6r7r$rr r rC)r% target_descrBrFr= libraries library_dirsruntime_library_dirsexport_symbolsrCr*r+ build_temprEr,lib_optsld_argslinkerioffsetr0r1r1r2links`         zUnixCCompiler.linkcCd|S)N-Lr1)r%dirr1r1r2library_dir_optionz UnixCCompiler.library_dir_optioncCsd|vpd|vS)Ngcczg++r1)r% compiler_namer1r1r2_is_gccszUnixCCompiler._is_gcccCstjttdd}tjdddkr4ddl m }m }|}|r0||ddgkr0d|Sd |Stjdd d krAd |Stjddd kr[| |rUdd |gSdd |gStddkrfd|Sd|S)NCCrrr )get_macosx_target_ver split_version z -Wl,-rpath,rafreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sGNULDyesz-Wl,--enable-new-dtags,-Rz-Wl,-R) r!r"rSshlexsplitrget_config_varr4r5distutils.utilrirjrg)r%rbrrirjmacosx_target_verr1r1r2runtime_library_dir_options    z(UnixCCompiler.runtime_library_dir_optioncCr`)Nz-lr1)r%libr1r1r2library_optionrdzUnixCCompiler.library_optioncCs|j|dd}|j|dd}|j|dd}|j|dd}tjdkr8td}td|} | dur3d } n| d } |D]} tj | |} tj | |} tj | |}tj | |}tjdkr| d sl| d r| d stj | | d d|} tj | | d d|} tj | | d d|}tj | | d d|}tj | r| Stj |r|Stj | r| Stj |r|Sq:dS)Nshared)lib_typedylib xcode_stubstaticr CFLAGSz-isysroot\s*(\S+)/rIz/System/z/usr/z /usr/local/) r@r4r5rrsresearchgroupr!r"rQ startswithexists)r%dirsrwrCshared_fdylib_f xcode_stub_fstatic_fcflagsmsysrootrbryr{r}r|r1r1r2find_library_filesH         zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__ compiler_type executablesr4r5src_extensions obj_extensionstatic_lib_extensionshared_lib_extensiondylib_lib_extensionxcode_stub_lib_extensionstatic_lib_formatshared_lib_formatdylib_lib_formatxcode_stub_lib_format exe_extensionr3r<rGr_rcrgrvrxrr1r1r1r2r -sN      B'r )__doc__r!r4rrq distutilsrdistutils.dep_utilrdistutils.ccompilerrrrdistutils.errorsrrr r r r5r6r r1r1r1r2s