3 /f:@sddlZddlZddlZddlmZddlmZddlmZm Z m Z ddl m Z m Z mZmZddlmZejdkrzddlZGdd d eZdS) 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)NLIBDIR)super _fix_lib_argsrget_config_varremove)self libraries library_dirsruntime_library_dirsZlibdir) __class__//usr/lib64/python3.6/distutils/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_argsrrextendappendZforcermkpathospathdirnamespawnrr) 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.r1rr2r#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;r@ target_langoutput_filenamer2r#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 EXECUTABLErrrbasenamer4r5r6r7r+rr r r@)rZ target_descr?rBr;rr r!Zexport_symbolsr@r-r.Z build_temprAr/Zlib_optsZld_argsZlinkerir2r#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)rLrrr4r5rR)rrOrr#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+)/rEz/System/z/usr/z /usr/local/) r=r4r5rrresearchgroupr(r)rK startswithexists)rdirsrYr@Zshared_fZdylib_fZ xcode_stub_fZstatic_fZcflagsmZsysrootrOr[r\r^r]r#r#r$find_library_file s>       zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__Z compiler_typeZ executablesr4r5Zsrc_extensionsZ obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ exe_extensionrr3r:rCrNrPrRrXrZrh __classcell__r#r#)r"r$r -sF       6,r )r(r4raZ distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr r r r5r6r r#r#r#r$s