a X´ZgÖ;ã@s’dZddlZddlZddlZddlmZddlmZddlm 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)Ú CCompilerÚgen_preprocess_optionsÚgen_lib_options)ÚDistutilsExecErrorÚ CompileErrorÚLibErrorÚ LinkError)ÚlogÚdarwinc sìeZdZdZddgdgdgddgdgddgddœZejdd…d krNd ged <gd ¢Zd Zd Z dZ dZ dZ dZ ZZeZejdkrˆdZ‡fdd„Zd)dd„Zdd„Zd*dd„Zd+dd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd,d'd(„Z‡ZS)-Ú UnixCCompilerZunixNZccz-sharedÚarz-cr)Ú preprocessorÚcompilerÚ compiler_soÚ compiler_cxxÚ linker_soÚ linker_exeÚarchiverÚranlibér r)z.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%sÚcygwinz.execs@tƒ |||¡\}}}t d¡}|r6||vr6| |¡|||fS)z'Remove standard library path from rpathZLIBDIR)ÚsuperÚ _fix_lib_argsrÚget_config_varÚremove)ÚselfÚ librariesÚ library_dirsÚruntime_library_dirsÚlibdir©Ú __class__©ú//usr/lib64/python3.9/distutils/unixccompiler.pyrUsÿ    zUnixCCompiler._fix_lib_argsc CsÔ| d||¡}|\}}}t||ƒ} |j| } |r>|  d|g¡|rN|| dd…<|r\|  |¡|  |¡|js~|dus~t||ƒrÐ|r”| tj   |¡¡z|  | ¡Wn,t yÎ} zt | ƒ‚WYd} ~ n d} ~ 00dS)Nú-or)Z_fix_compile_argsrrÚextendÚappendÚforcerÚmkpathÚosÚpathÚdirnameÚspawnrr) rÚsourceZ output_fileZmacrosZ include_dirsÚ extra_preargsÚextra_postargsÚ fixed_argsÚignoreÚpp_optsZpp_argsÚmsgr$r$r%Ú preprocess^s$      zUnixCCompiler.preprocessc Csr|j}tjdkr t |||¡}z | |||d|g|¡Wn,tyl}zt|ƒ‚WYd}~n d}~00dS)Nr r&)rÚsysÚplatformÚ _osx_supportÚcompiler_fixupr.rr) rÚobjÚsrcÚextZcc_argsr1r4rr5r$r$r%Ú_compilexs ÿÿ zUnixCCompiler._compilerc Cs´| ||¡\}}|j||d}| ||¡r¤| tj |¡¡| |j|g||j ¡|j r°z| |j |g¡Wq°t y }zt |ƒ‚WYd}~q°d}~00n t  d|¡dS)N)Ú output_dirúskipping %s (up-to-date))Ú_fix_object_argsÚlibrary_filenameÚ _need_linkr*r+r,r-r.rÚobjectsrrr r Údebug)rrDZoutput_libnamer?rEÚ target_langÚoutput_filenamer5r$r$r%Úcreate_static_libƒs$ ÿ ÿþþ  zUnixCCompiler.create_static_libc CsÜ| ||¡\}}| |||¡}|\}}}t||||ƒ}t|ttdƒfƒsPtdƒ‚|durftj  ||¡}|  ||¡rÌ||j |d|g}| rœdg|dd…<| r¬| |dd…<| rº|  | ¡|  tj |¡¡zÎ|tjkrè|jdd…}n|jdd…}| dkrr|jrrd}tj |d¡dkr@d}d||vr@|d7}q&tj ||¡d kr\d}nd}|j||||<tjd krŠt ||¡}| ||¡Wn.tyÈ}zt|ƒ‚WYd}~n d}~00n t d |¡dS) Nz%'output_dir' must be a string or Noner&z-grzc++Úenvéú=Z ld_so_aixr r@)rArrÚ isinstanceÚstrÚtypeÚ TypeErrorr+r,ÚjoinrCrDr'r*r-rZ EXECUTABLErrrÚbasenamer7r8r9r:r.rr r rE)rZ target_descrDrGr?rrr Zexport_symbolsrEr0r1Z build_temprFr2Zlib_optsZld_argsZlinkerÚiÚoffsetr5r$r$r%ÚlinksZÿ ÿÿÿ       zUnixCCompiler.linkcCsd|S)Nú-Lr$)rÚdirr$r$r%Úlibrary_dir_optionßsz UnixCCompiler.library_dir_optioncst‡fdd„dDƒƒS)Nc3s|]}|ˆvVqdS)Nr$)Ú.0Úname©Ú compiler_namer$r%Ú äóz(UnixCCompiler._is_gcc..)Zgcczg++Zclang)Úany)rr[r$rZr%Ú_is_gccâszUnixCCompiler._is_gcccCs°tj t d¡¡}tjdd…dkr,d|Stjdd…dkrFd|Stjdd…d krz| |¡rnd d|gSd d|gS| |¡r¤t d ¡d kršd|Sd|Snd|SdS)NÚCCrr rUéZfreebsdz -Wl,-rpath=ézhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r+r,rQrrr7r8r_)rrVrr$r$r%Úruntime_library_dir_optionæs     z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr$)rÚlibr$r$r%Úlibrary_optionszUnixCCompiler.library_optioncCs¨|j|dd}|j|dd}|j|dd}|j|dd}tjdkr|t d¡}t d|¡} | durrt t d ¡¡} n |   d ¡} |D] } t j   | |¡} t j   | |¡} t j   | |¡}t j   | |¡}tjdkrL|   d ¡sì|   d ¡rL|   d ¡sLt j   | | d d…|¡} t j   | | d d…|¡} t j   | | d d…|¡}t j   | | d d…|¡}t j  | ¡rb| St j  |¡rx|St j  | ¡rŽ| St j  |¡r€|Sq€dS)NÚshared)Zlib_typeÚdylibÚ xcode_stubÚstaticr ZCFLAGSz-isysroot\s*(\S+)r`rJz/System/z/usr/z /usr/local/)rBr7r8rrÚreÚsearchr9Z_default_sysrootÚgroupr+r,rPÚ startswithÚexists)rÚdirsrdrEZshared_fZdylib_fZ xcode_stub_fZstatic_fZcflagsÚmZsysrootrVrfrgrirhr$r$r%Úfind_library_filesF      ÿþþ  zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)Ú__name__Ú __module__Ú __qualname__Z compiler_typeZ executablesr7r8Zsrc_extensionsZ obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ exe_extensionrr6r>rHrTrWr_rcrerqÚ __classcell__r$r$r"r%r -sNù     ÿ  ÿ ü B*r )Ú__doc__r+r7rjZ distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr r r r8r9r r$r$r$r%Ús