3 2a3@shddlZddlZddlmZddlmZddlmZddlm Z dddZ Gd d d eZ d d d Z dS)N)Command)DistutilsExecError)customize_compiler)logz.cz.cxx)czc++c @seZdZdZd>d?d@dAdBdCdDdEdFg ZddZddZddZd d!Zd"d#Z d$d%Z d&d'Z d(d)Z d*d+Z dGd-d.ZdHd/d0ZdId1d2ZdJd3d4ZdKd5d6ZdLd8d9Zdddgfd:d;ZdMd  r)LANG_EXTopenwriteclose)r&bodyheaderslangfilenamefileheaderr'r'r(_gen_temp_sourcefileks       zconfig._gen_temp_sourcefilecCs<|j|||}d}|jj||g|jj|||d||fS)Nz _configtest.i)r!)rDr%extendr Z preprocess)r&r>r?r!r@srcoutr'r'r( _preprocessxs zconfig._preprocesscCs\|j|||}|jr"t|d||jj|g\}|jj||g|jj|g|d||fS)Nzcompiling '%s':)r!)rDr$ dump_filer Zobject_filenamesr%rEcompile)r&r>r?r!r@rFobjr'r'r(_compileszconfig._compilec Csr|j||||\}}tjjtjj|d} |jj|g| |||d|jjdk r\| |jj} |jj | ||| fS)Nr)r"r#Z target_lang) rLr-pathsplitextbasenamer Zlink_executableZ exe_extensionr%append) r&r>r?r!r"r#r@rFrKprogr'r'r(_links    z config._linkc GsX|s|j}g|_tjddj|x0|D](}ytj|Wq(tk rNYq(Xq(WdS)Nz removing: %s )r%rinfojoinr-removeOSError)r& filenamesrAr'r'r(_cleans z config._cleanrc CsRddlm}|jd}y|j||||Wn|k rDd}YnX|j|S)Nr) CompileErrorTF)r5rZr6rHrY)r&r>r?r!r@rZokr'r'r(try_cpps  zconfig.try_cppc Csx|j|j||||\}}t|tr0tj|}t|}d} x&|j} | dkrPP|j| r>d} Pq>W|j |j | S)NFT) r6rHr*r+rerJr;readlinesearchr=rY) r&patternr>r?r!r@rFrGrBmatchliner'r'r( search_cpps    zconfig.search_cppc Csdddlm}|jy|j||||d}Wn|k rDd}YnXtj|rRdpTd|j|S)Nr)rZTFzsuccess!zfailure.)r5rZr6rLrrTrY)r&r>r?r!r@rZr[r'r'r( try_compiles  zconfig.try_compilec Cspddlm}m}|jy|j||||||d} Wn||fk rPd} YnXtj| r^dp`d|j| S)Nr)rZ LinkErrorTFzsuccess!zfailure.)r5rZrfr6rRrrTrY) r&r>r?r!r"r#r@rZrfr[r'r'r(try_links   zconfig.try_linkc Csddlm}m}|jy.|j||||||\} } } |j| gd} Wn||tfk rdd} YnXtj| rrdptd|j | S)Nr)rZrfTFzsuccess!zfailure.) r5rZrfr6rRZspawnrrrTrY) r&r>r?r!r"r#r@rZrfrFrKZexer[r'r'r(try_runs   zconfig.try_runrc Cst|jg}|r|jd||jd|r<|jd|n|jd||jddj|d}|j|||||S)Nz int %s ();z int main () {z %s();z %s;}r8)r6rPrUrg) r&funcr?r!r"r#ZdeclZcallr>r'r'r( check_funcs   zconfig.check_funccCs |j|jd|||g||S)Nzint main (void) { })r6rg)r&Zlibraryr#r?r!Zother_librariesr'r'r( check_lib6s  zconfig.check_libcCs|jd|g|dS)Nz /* No body */)r>r?r!)r\)r&rCr!r#r@r'r'r( check_headerDs zconfig.check_header)rNr )r Nr )r r r)rrr)rrr)rrr)rrr)rNr)rNr)NNNr)NNNr)NNr)NNNNr)NNNNr)NNNNrr)NNr)__name__ __module__ __qualname__ descriptionZ user_optionsr)r/r0r6rDrHrLrRrYr\rdrergrhrkrlrmr'r'r'r(rsT         rc CsJ|dkrtjd|n tj|t|}ztj|jWd|jXdS)Nz%s)rrTr;readr=)rAheadrBr'r'r(rINs rI)N) r-r^Zdistutils.corerZdistutils.errorsrZdistutils.sysconfigrZ distutilsrr:rrIr'r'r'r( s     ;