U &Ì.e–;ã@sŽddlZddlZddlZddlmZddlmZddlmZm Z m Z ddl m Z m Z mZmZddlmZejdkrzddlZGdd „d eƒZdS) éN)Ú sysconfig)Únewer)Ú CCompilerÚgen_preprocess_optionsÚgen_lib_options)ÚDistutilsExecErrorÚ CompileErrorÚLibErrorÚ LinkError)ÚlogÚdarwinc sôeZdZdZddgdgdgddgdgddgddœZejdd…d krNd ged <d d d dddgZdZdZ dZ dZ dZ dZ ZZeZejdkrdZ‡fdd„Zd.dd„Zdd„Zd/d d!„Zd0d"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd1d,d-„Z‡ZS)2Ú UnixCCompilerZunixNZccz-sharedZarz-cr)Ú preprocessorÚcompilerÚ compiler_soÚ compiler_cxxÚ linker_soÚ linker_exeÚarchiverÚranlibér rz.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%sÚcygwinz.execs@tƒ |||¡\}}}t d¡}|r6||kr6| |¡|||fS)NZLIBDIR)ÚsuperÚ _fix_lib_argsrÚget_config_varÚremove)ÚselfÚ librariesÚ library_dirsÚruntime_library_dirsZlibdir©Ú __class__©ú//usr/lib64/python3.8/distutils/unixccompiler.pyrUsÿ    zUnixCCompiler._fix_lib_argsc CsÒ| d||¡}|\}}}t||ƒ} |j| } |r>|  d|g¡|rN|| dd…<|r\|  |¡|  |¡|js~|dks~t||ƒrÎ|r”| tj   |¡¡z|  | ¡Wn*t k rÌ} z t | ƒ‚W5d} ~ XYnXdS)Nú-or)Z_fix_compile_argsrrÚextendÚappendZforcerÚ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 Csp|j}tjdkr t |||¡}z | |||d|g|¡Wn*tk rj}z t|ƒ‚W5d}~XYnXdS)Nr r$)rÚsysÚplatformÚ _osx_supportÚcompiler_fixupr+rr) rÚobjÚsrcZextZcc_argsr.r1rr2r"r"r#Ú_compilexs ÿÿ zUnixCCompiler._compilerc Cs²| ||¡\}}|j||d}| ||¡r¢| tj |¡¡| |j|g||j ¡|j r®z| |j |g¡Wq®t k rž}z t |ƒ‚W5d}~XYq®Xn 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)rr@Zoutput_libnamer;rAÚ target_langÚoutput_filenamer2r"r"r#Úcreate_static_libƒs$ ÿ ÿþþ zUnixCCompiler.create_static_libc CsÚ| ||¡\}}| |||¡}|\}}}t||||ƒ}t|ttdƒfƒsPtdƒ‚|dk rftj  ||¡}|  ||¡rÊ||j |d|g}| rœdg|dd…<| r¬| |dd…<| rº|  | ¡|  tj |¡¡zÎ|tjkrè|jdd…}n|jdd…}| dkrr|jrrd}tj |d¡dkr@d}d||kr@|d7}q&tj ||¡d kr\d}nd}|j||||<tjd krŠt ||¡}| ||¡Wn,tk rÆ}z t|ƒ‚W5d}~XYnXn t d |¡dS) Nz%'output_dir' must be a string or Noner$z-grzc++Úenvéú=Z ld_so_aixr r<)r=rrÚ isinstanceÚstrÚtypeÚ TypeErrorr(r)Újoinr?r@r%r'r*rZ EXECUTABLErrrÚbasenamer4r5r6r7r+rr r rA)rZ target_descr@rCr;rrrZexport_symbolsrAr-r.Z build_temprBr/Zlib_optsZld_argsZlinkerÚiÚoffsetr2r"r"r#ÚlinksZÿ ÿÿÿ      zUnixCCompiler.linkcCsd|S)Nú-Lr")rÚdirr"r"r#Úlibrary_dir_optionßsz UnixCCompiler.library_dir_optioncCsd|kpd|kS)NZgcczg++r")rZ compiler_namer"r"r#Ú_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 rQéZfreebsdz -Wl,-rpath=ézhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r(r)rMrrr4r5rT)rrRrr"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|¡} | dkrrt 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+)rUrFz/System/z/usr/z /usr/local/)r>r4r5rrÚreÚsearchr6Z_default_sysrootÚgroupr(r)rLÚ startswithÚexists)rÚdirsrYrAZshared_fZdylib_fZ xcode_stub_fZstatic_fZcflagsÚmZsysrootrRr[r\r^r]r"r"r#Úfind_library_filesF      ÿþþ  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:rDrPrSrTrXrZrfÚ __classcell__r"r"r r#r -sbù     ÿ  ÿ ü B*r )r(r4r_Z distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr r r r5r6r r"r"r"r#Ús