B °Ÿu»´ÂUæã@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=ÚIz.list of directories to search for header files)zdefine=ÚDzC preprocessor macros to define)zundef=ÚUz!C preprocessor macros to undefine)z libraries=Úlz!external C libraries to link with)z library-dirs=ÚLz.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ú;/opt/alt/python37/lib/python3.7/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) rZ distributionÚ isinstanceÚstrÚsplitÚosÚpathseprr)rrrrÚfinalize_optionsBs       zconfig.finalize_optionscCsdS)Nr)rrrrÚ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_runÚforce) Údistutils.ccompilerr r!rrr"rrZset_include_dirsrZ set_librariesrZset_library_dirs)rr r!rrrÚ_check_compilerYs  zconfig._check_compilercCsldt|}t|dƒ}|r@x|D]}| d|¡q W| d¡| |¡|ddkr`| d¡| ¡|S)NZ _configtestÚwz#include <%s> Ú éÿÿÿÿ)ÚLANG_EXTÚopenÚwriteÚclose)rÚbodyÚheadersÚlangÚfilenameÚfileÚheaderrrrÚ_gen_temp_sourcefileks       zconfig._gen_temp_sourcefilecCs<| |||¡}d}|j ||g¡|jj|||d||fS)Nz _configtest.i)r)r3rÚextendrZ preprocess)rr-r.rr/ÚsrcÚoutrrrÚ _preprocessxs zconfig._preprocesscCs\| |||¡}|jr"t|d|ƒ|j |g¡\}|j ||g¡|jj|g|d||fS)Nzcompiling '%s':)r)r3rÚ dump_filerZobject_filenamesrr4Úcompile)rr-r.rr/r5ÚobjrrrÚ_compileszconfig._compilec Csr| ||||¡\}}tj tj |¡¡d} |jj|g| |||d|jjdk r\| |jj} |j  | ¡||| fS)Nr)rrZ target_lang) r;rÚpathÚsplitextÚbasenamerZlink_executableZ exe_extensionrÚappend) rr-r.rrrr/r5r:ÚprogrrrÚ_linkˆs    z config._linkc GsX|s|j}g|_t dd |¡¡x0|D](}yt |¡Wq(tk rNYq(Xq(WdS)Nz removing: %sú )rrÚinfoÚjoinrÚremoveÚOSError)rÚ filenamesr0rrrÚ_clean—s z config._cleanNrcCsRddlm}| ¡d}y| ||||¡Wn|k rDd}YnX| ¡|S)Nr)Ú CompileErrorTF)r$rIr%r7rH)rr-r.rr/rIÚokrrrÚtry_cpp­s  zconfig.try_cppc Csx| ¡| ||||¡\}}t|tƒr0t |¡}t|ƒ}d} x&| ¡} | dkrPP| | ¡r>d} Pq>W|  ¡|  ¡| S)NFÚT) r%r7rrÚrer9r*ÚreadlineÚsearchr,rH) rÚpatternr-r.rr/r5r6r1ÚmatchÚlinerrrÚ search_cpp¿s    zconfig.search_cppcCsdddlm}| ¡y| ||||¡d}Wn|k rDd}YnXt |rRdpTd¡| ¡|S)Nr)rITFzsuccess!zfailure.)r$rIr%r;rrCrH)rr-r.rr/rIrJrrrÚ try_compileÜs  zconfig.try_compilec Cspddlm}m}| ¡y| ||||||¡d} Wn||fk rPd} YnXt | r^dp`d¡| ¡| S)Nr)rIÚ LinkErrorTFzsuccess!zfailure.)r$rIrUr%rArrCrH) rr-r.rrrr/rIrUrJrrrÚtry_linkìs   zconfig.try_linkc Cs„ddlm}m}| ¡y.| ||||||¡\} } } | | g¡d} Wn||tfk rdd} YnXt | rrdptd¡|  ¡| S)Nr)rIrUTFzsuccess!zfailure.) r$rIrUr%rAZspawnrrrCrH) rr-r.rrrr/rIrUr5r:ZexerJrrrÚ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;Ú}r')r%r?rDrV) rÚfuncr.rrrZdeclZcallr-rrrÚ check_funcs   zconfig.check_funccCs | ¡| d|||g||¡S)Nzint main (void) { })r%rV)rZlibraryrr.rZother_librariesrrrÚ check_lib6s  zconfig.check_libcCs|jd|g|dS)Nz /* No body */)r-r.r)rK)rr2rrr/rrrÚ check_headerDs zconfig.check_header)NNNr)NNNr)NNr)NNNNr)NNNNr)NNNNrr)NNr)Ú__name__Ú __module__Ú __qualname__Ú descriptionZ user_optionsrrrr%r3r7r;rArHrKrSrTrVrWrZr[r\rrrrrsB         rcCsJ|dkrt d|¡n t |¡t|ƒ}zt | ¡¡Wd| ¡XdS)Nz%s)rrCr*Úreadr,)r0Úheadr1rrrr8Ns r8)N) rrMZdistutils.corerZdistutils.errorsrZdistutils.sysconfigrZ distutilsrr)rr8rrrrÚ s     ;