U ŁAT^=3c@shddlZddlZddlmZddlmZddlmZddlm Z dddœZ Gd d „d eƒZ d d d „Z dS)éN)ŚCommand)ŚDistutilsExecError)Ścustomize_compiler)Ślogz.cz.cxx)Śczc++c @sĘeZdZdZdddddddd d g Zd d „Zd d„Zdd„Zdd„Zdd„Z dd„Z dd„Z dd„Z dd„Z d0dd „Zd1d!d"„Zd2d#d$„Zd3d%d&„Zd4d'd(„Zd5d*d+„Zdddgfd,d-„Zd6d.d/„ZdS)7Śconfigzprepare to build)z compiler=Nzspecify the compiler type)zcc=Nzspecify the compiler executable)z include-dirs=ZIz.list of directories to search for header files)zdefine=ZDzC preprocessor macros to define)zundef=ZUz!C preprocessor macros to undefine)z libraries=Zlz!external C libraries to link with)z library-dirs=ZLz.directories to search for external C libraries)ŚnoisyNz1show every action (compile, link, run, ...) taken)z dump-sourceNz=dump generated source files before attempting to compile themcCs4d|_d|_d|_d|_d|_d|_d|_g|_dS)Né)ŚcompilerZccŚ include_dirsŚ librariesŚ library_dirsrŚ dump_sourceŚ temp_files©Śself©rś0/usr/lib64/python3.8/distutils/command/config.pyŚinitialize_options3szconfig.initialize_optionscCs|jdkr|jjpg|_nt|jtƒr6|j tj”|_|jdkrHg|_nt|jtƒr^|jg|_|jdkrpg|_nt|jtƒrŒ|j tj”|_dS©N) r Z distributionŚ isinstanceŚstrZsplitŚosZpathsepr r rrrrŚfinalize_optionsBs       zconfig.finalize_optionscCsdSrrrrrrŚrunRsz config.runcCszddlm}m}t|j|ƒsv||j|jdd|_t|jƒ|jrN|j |j”|j rb|j  |j ”|j rv|j  |j ”dS)Nr)Ś CCompilerŚ new_compilerr)r Śdry_runZforce) Śdistutils.ccompilerrrrr rrr Zset_include_dirsr Z set_librariesr Zset_library_dirs)rrrrrrŚ_check_compilerYs ’ zconfig._check_compilerc Csldt|}t|dƒL}|r>|D]}| d|”q | d”| |”|ddkr^| d”W5QRX|S)NZ _configtestZwz#include <%s> Ś i’’’’)ŚLANG_EXTŚopenZwrite)rŚbodyŚheadersŚlangŚfilenameŚfileŚheaderrrrŚ_gen_temp_sourcefileks     zconfig._gen_temp_sourcefilecCs<| |||”}d}|j ||g”|jj|||d||fS)Nz _configtest.i©r )r(rŚextendr Z preprocess)rr"r#r r$ŚsrcŚoutrrrŚ _preprocessws zconfig._preprocesscCs\| |||”}|jr"t|d|ƒ|j |g”\}|j ||g”|jj|g|d||fS)Nzcompiling '%s':r))r(r Ś dump_filer Zobject_filenamesrr*Ścompile)rr"r#r r$r+ŚobjrrrŚ_compile~szconfig._compilec Csr| ||||”\}}tj tj |””d} |jj|g| |||d|jjdk r\| |jj} |j  | ”||| fS)Nr)r r Z target_lang) r1rZpathZsplitextZbasenamer Zlink_executableZ exe_extensionrŚappend) rr"r#r r r r$r+r0ZprogrrrŚ_link‡s ż   z config._linkc GsT|s|j}g|_t dd |””|D](}zt |”Wq&tk rLYq&Xq&dS)Nz removing: %sz )rrŚinfoŚjoinrZremoveZOSError)rZ filenamesr%rrrŚ_clean–sz config._cleanNrcCsRddlm}| ”d}z| ||||”Wn|k rDd}YnX| ”|S)Nr©Ś CompileErrorTF)rr8rr-r6©rr"r#r r$r8ŚokrrrŚtry_cpp¬s  zconfig.try_cppc Csx| ”| ||||”\}}t|tƒr0t |”}t|ƒ.}d} | ”} | dkrPqb| | ”r>d} qbq>W5QRX|  ”| S)NFZT) rr-rrŚrer/r!ZreadlineZsearchr6) rZpatternr"r#r r$r+r,r&ZmatchZlinerrrŚ search_cpp¾s     zconfig.search_cppcCsdddlm}| ”z| ||||”d}Wn|k rDd}YnXt |rRdpTd”| ”|S)Nrr7TFśsuccess!śfailure.)rr8rr1rr4r6r9rrrŚ try_compileŚs  zconfig.try_compilec Cspddlm}m}| ”z| ||||||”d} Wn||fk rPd} YnXt | r^dp`d”| ”| S©Nr)r8Ś LinkErrorTFr>r?)rr8rBrr3rr4r6) rr"r#r r r r$r8rBr:rrrŚtry_linkźs ’ zconfig.try_linkc Cs„ddlm}m}| ”z.| ||||||”\} } } | | g”d} Wn||tfk rdd} YnXt | rrdptd”|  ”| SrA) rr8rBrr3Zspawnrrr4r6) rr"r#r r r r$r8rBr+r0Zexer:rrrŚtry_runżs ’   zconfig.try_runrc Cst| ”g}|r| d|”| d”|r<| d|”n| d|”| d”d |”d}| |||||”S)Nz int %s ();z int main () {z %s();z %s;Z}r)rr2r5rC) rZfuncr#r r r ZdeclZcallr"rrrŚ check_funcs   ’zconfig.check_funccCs | ”| d|||g||”S)Nzint main (void) { })rrC)rZlibraryr r#r Zother_librariesrrrŚ check_lib4s  ’zconfig.check_libcCs|jd|g|dS)Nz /* No body */)r"r#r )r;)rr'r r r$rrrŚ check_headerBs ’zconfig.check_header©NNNrrH©NNr©NNNNrrJ)NNNNrrrI)Z__name__Z __module__Z __qualname__Z descriptionZ user_optionsrrrrr(r-r1r3r6r;r=r@rCrDrErFrGrrrrrs\ī   ’  ’ ’ ’ ’ ’rcCsJ|dkrt d|”n t |”t|ƒ}zt | ””W5| ”XdS)Nz%s)rr4r!ZcloseZread)r%Zheadr&rrrr.Ks r.r) rr<Zdistutils.corerZdistutils.errorsrZdistutils.sysconfigrZ distutilsrr rr.rrrrZ s     8