3 /f:@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 ZZeZejdkrdZfddZd.ddZddZd/d d!Zd0d"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd1d,d-ZZS)2 UnixCCompilerZunixNZccz-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.execs@tj|||\}}}tjd}|r6||kr6|j||||fS)z'Remove standard library path from rpathLIBDIR)super _fix_lib_argsrget_config_varremove)self libraries library_dirsruntime_library_dirsZlibdir) __class__%/usr/lib64/python3.6/unixccompiler.pyrUs    zUnixCCompiler._fix_lib_argsc Cs|jd||}|\}}}t||} |j| } |r>| jd|g|rN|| dd<|r\| j|| j||js~|dks~t||r|r|jtj j |y|j | Wn*t k r} zt | WYdd} ~ XnXdS)Nz-or)Z_fix_compile_argsrrextendappendforcermkpathospathdirnamespawnrr) rsourceZ output_fileZmacrosZ include_dirs extra_preargsextra_postargs fixed_argsignorepp_optsZpp_argsmsgr#r#r$ preprocess^s$      zUnixCCompiler.preprocessc Csp|j}tjdkr tj|||}y |j|||d|g|Wn*tk rj}zt|WYdd}~XnXdS)Nr z-o)rsysplatform _osx_supportcompiler_fixupr,rr) robjsrcZextZcc_argsr/r2rr3r#r#r$_compilexs   zUnixCCompiler._compilercCs|j||\}}|j||d}|j||r|jtjj||j|j|g||j |j ry|j|j |gWqt k r}zt |WYdd}~XqXn t jd|dS)N) output_dirzskipping %s (up-to-date))_fix_object_argslibrary_filename _need_linkr(r)r*r+r,robjectsrrr r debug)rr@Zoutput_libnamer<rA target_langoutput_filenamer3r#r#r$create_static_libs zUnixCCompiler.create_static_libcCs|j||\}}|j|||}|\}}}t||||}t|ttdfsPtd|dk rftjj ||}|j ||r||j |d|g}| rdg|dd<| r| |dd<| r|j | |j tjj|y|tjkr|jdd}n|jdd}| dkrR|jrRd}tjj|ddkrDd}xd||krB|d7}q(W|j|||<tjd krjtj||}|j||Wn,tk r}zt|WYdd}~XnXn tjd |dS) Nz%'output_dir' must be a string or Nonez-oz-grzc++env=r zskipping %s (up-to-date))r=rr isinstancestrtype TypeErrorr)r*joinr?r@r%r(r+rZ EXECUTABLErrrbasenamer5r6r7r8r,rr r rA)rZ target_descr@rCr<rr r!Zexport_symbolsrAr.r/Z build_temprBr0Zlib_optsZld_argsZlinkerir3r#r#r$linksH      zUnixCCompiler.linkcCsd|S)Nz-Lr#)rdirr#r#r$library_dir_optionsz UnixCCompiler.library_dir_optioncCsd|kpd|kS)Ngcczg++r#)rZ compiler_namer#r#r$_is_gccszUnixCCompiler._is_gcccCstjjtjd}tjdddkr,d|StjdddkrFd|Stjddd krz|j|rnd d|gSd d|gStjddd kstjddd krd|gS|j|rtjddkrd|Sd|Snd|SdS)NCCrr z-LZfreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sZirix646Zosf1V5z-rpathGNULDyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r)r*rMrrr5r6rS)rrPrr#r#r$runtime_library_dir_options    $  z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr#)rlibr#r#r$library_option szUnixCCompiler.library_optioncCs|j|dd}|j|dd}|j|dd}|j|dd}tjdkrptjd}tjd|} | dkrfd } n | jd } x|D]} tj j | |} tj j | |} tj j | |}tj j | |}tjdko| j d s| j d o| j d  rBtj j | | d d|} tj j | | d d|} tj j | | d d|}tj j | | d d|}tj j | rT| Stj j |rf|Stj j | rx| Stj j |rx|SqxWdS)Nshared)Zlib_typedylib xcode_stubstaticr CFLAGSz-isysroot\s+(\S+)/rFz/System/z/usr/z /usr/local/) r>r5r6rrresearchgroupr)r*rL startswithexists)rdirsrZrAZshared_fZdylib_fZ xcode_stub_fZstatic_fZcflagsmZsysrootrPr\r]r_r^r#r#r$find_library_file s>       zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__Z compiler_typeZ executablesr5r6Zsrc_extensionsZ obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ exe_extensionrr4r;rDrOrQrSrYr[ri __classcell__r#r#)r"r$r -sF       6,r )__doc__r)r5rbZ distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr r r r6r7r r#r#r#r$s