o g;@s ddlZddlZddlZddlmZddlmZddlmZm Z m Z ddl m Z m Z mZmZddlmZejdkr>ddlZGdd d eZdS) N) sysconfig)newer) CCompilergen_preprocess_optionsgen_lib_options)DistutilsExecError CompileErrorLibError LinkError)logdarwinc seZdZdZddgdgdgddgdgddgddZejddd kr'd ged <gd Zd Zd Z dZ dZ dZ dZ ZZeZejdkrDdZfddZ  d)ddZddZ d*ddZ    d+ddZdd Zd!d"Zd#d$Zd%d&Zd,d'd(ZZS)- UnixCCompilerZunixNZccz-sharedZarz-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.execsB t|||\}}}td}|r||vr|||||fS)NZLIBDIR)super _fix_lib_argsrget_config_varremove)self libraries library_dirsruntime_library_dirslibdir __class__>/opt/alt/python310/lib64/python3.10/distutils/unixccompiler.pyrUs    zUnixCCompiler._fix_lib_argsc Cs|d||}|\}}}t||} |j| } |r| d|g|r'|| dd<|r.| || ||js?|dus?t||rc|rJ|tj |z| | WdSt yb} zt | d} ~ wwdS)N-or)Z_fix_compile_argsrrextendappendZforcermkpathospathdirnamespawnrr) rsourceZ output_fileZmacrosZ include_dirs extra_preargsextra_postargs fixed_argsignorepp_optsZpp_argsmsgr#r#r$ preprocess^s*      zUnixCCompiler.preprocessc Csd|j}tjdkrt|||}z||||d|g|WdSty1}zt|d}~ww)Nr r%)rsysplatform _osx_supportcompiler_fixupr,rr) robjsrcZextZcc_argsr/r2rr3r#r#r$_compilexs  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)rrAZoutput_libnamer<rB target_langoutput_filenamer3r#r#r$create_static_libs*   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 Noner%z-grzc++env=Z ld_so_aixr r=)r>rr isinstancestrtype TypeErrorr)r*joinr@rAr&r(r+rZ EXECUTABLErrrbasenamer5r6r7r8r,rr r rB)rZ target_descrArDr<rrrZexport_symbolsrBr.r/Z build_temprCr0Zlib_optsZld_argsZlinkerioffsetr3r#r#r$links`         zUnixCCompiler.linkcCd|S)N-Lr#)rdirr#r#r$library_dir_optionz UnixCCompiler.library_dir_optioncstfdddDS)Nc3s|]}|vVqdS)Nr#).0name compiler_namer#r$ sz(UnixCCompiler._is_gcc..)Zgcczg++Zclang)any)rrZr#rYr$_is_gccszUnixCCompiler._is_gcccCstjtd}tjdddkrd|Stjdddkr#d|Stjddd kr=||r7d d|gSd d|gS||rQtd d krMd|Sd|Sd|S)NCCrr rSZfreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r)r*rNrrr5r6r])rrTrr#r#r$runtime_library_dir_options    z(UnixCCompiler.runtime_library_dir_optioncCrR)Nz-lr#)rlibr#r#r$library_optionrVzUnixCCompiler.library_optioncCs|j|dd}|j|dd}|j|dd}|j|dd}tjdkr>td}td|} | dur9ttd } n| d } |D]} t j | |} t j | |} t j | |}t j | |}tjdkr| d sr| d r| d st j | | d d|} t j | | d d|} t j | | d d|}t j | | d d|}t j | r| St j |r|St j | r| St j |r|Sq@dS)Nshared)Zlib_typedylib xcode_stubstaticr ZCFLAGSz-isysroot\s*(\S+)r^rGz/System/z/usr/z /usr/local/)r?r5r6rrresearchr7Z_default_sysrootgroupr)r*rM startswithexists)rdirsrbrBZshared_fZdylib_fZ xcode_stub_fZstatic_fZcflagsmZsysrootrTrdrergrfr#r#r$find_library_filesH         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;rErQrUr]rarcro __classcell__r#r#r!r$r -sP        B*r )r)r5rhZ distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr r r r6r7r r#r#r#r$s