509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \3  ã               @   sh   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 dddœZ
G d	d
„ d
eƒZddd„ZdS )é    N)ÚCommand)ÚDistutilsExecError)Úcustomize_compiler)Úlogz.cz.cxx)Úczc++c               @   sÆ   e Zd ZdZd>d?d@dAdBdCdDdEdFg	Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Z	d$d%„ Z
d&d'„ Zd(d)„ Zd*d+„ ZdGd-d.„ZdHd/d0„ZdId1d2„ZdJd3d4„ZdKd5d6„ZdLd8d9„Zdddg fd:d;„ZdMd<d=„ZdS )NÚconfigzprepare to buildú	compiler=Núspecify the compiler typeúcc=úspecify the compiler executableúinclude-dirs=ÚIú.list of directories to search for header filesúdefine=ÚDúC preprocessor macros to defineúundef=ÚUú!C preprocessor macros to undefineú
libraries=Úlú!external C libraries to link withúlibrary-dirs=ÚLú.directories to search for external C librariesÚnoisyú1show every action (compile, link, run, ...) takenúdump-sourceú=dump generated source files before attempting to compile themc             C   s4   d | _ d | _d | _d | _d | _d| _d| _g | _d S )Né   )ÚcompilerZccÚinclude_dirsÚ	librariesÚlibrary_dirsr   Údump_sourceÚ
temp_files)Úself© r'   ú0/usr/lib64/python3.6/distutils/command/config.pyÚinitialize_options3   s    zconfig.initialize_optionsc             C   s�   | j d kr| jj pg | _ nt| j tƒr6| j jtjƒ| _ | jd krHg | _nt| jtƒr^| jg| _| jd krpg | _nt| jtƒrŒ| jjtjƒ| _d S )N)	r!   ZdistributionÚ
isinstanceÚstrÚsplitÚosÚpathsepr"   r#   )r&   r'   r'   r(   Úfinalize_optionsB   s    



zconfig.finalize_optionsc             C   s   d S )Nr'   )r&   r'   r'   r(   ÚrunR   s    z
config.runc             C   sz   ddl m}m} t| j|ƒsv|| j| jdd�| _t| jƒ | jrN| jj| jƒ | j	rb| jj
| j	ƒ | jrv| jj| jƒ d S )Nr   )Ú	CCompilerÚnew_compilerr   )r    Údry_runZforce)Údistutils.ccompilerr1   r2   r*   r    r3   r   r!   Zset_include_dirsr"   Zset_librariesr#   Zset_library_dirs)r&   r1   r2   r'   r'   r(   Ú_check_compilerY   s    
zconfig._check_compilerc             C   sl   dt |  }t|dƒ}|r@x|D ]}|jd| ƒ q W |jdƒ |j|ƒ |d dkr`|jdƒ |jƒ  |S )NZ_configtestÚwz#include <%s>
Ú
r   éÿÿÿÿ)ÚLANG_EXTÚopenÚwriteÚclose)r&   ÚbodyÚheadersÚlangÚfilenameÚfileÚheaderr'   r'   r(   Ú_gen_temp_sourcefilek   s    




zconfig._gen_temp_sourcefilec             C   s<   | j |||ƒ}d}| jj||gƒ | jj|||d� ||fS )Nz_configtest.i)r!   )rC   r%   Úextendr    Z
preprocess)r&   r=   r>   r!   r?   ÚsrcÚoutr'   r'   r(   Ú_preprocessx   s
    zconfig._preprocessc             C   s\   | j |||ƒ}| jr"t|d| ƒ | jj|gƒ\}| jj||gƒ | jj|g|d� ||fS )Nzcompiling '%s':)r!   )rC   r$   Ú	dump_filer    Zobject_filenamesr%   rD   Úcompile)r&   r=   r>   r!   r?   rE   Úobjr'   r'   r(   Ú_compile   s    zconfig._compilec       
      C   sr   | j ||||ƒ\}}tjjtjj|ƒƒd }	| jj|g|	|||d� | jjd k	r\|	| jj }	| jj	|	ƒ |||	fS )Nr   )r"   r#   Ztarget_lang)
rK   r-   ÚpathÚsplitextÚbasenamer    Zlink_executableZexe_extensionr%   Úappend)
r&   r=   r>   r!   r"   r#   r?   rE   rJ   Úprogr'   r'   r(   Ú_linkˆ   s    zconfig._linkc             G   sX   |s| j }g | _ tjddj|ƒƒ x0|D ](}ytj|ƒ W q( tk
rN   Y q(X q(W d S )Nzremoving: %sú )r%   r   ÚinfoÚjoinr-   ÚremoveÚOSError)r&   Ú	filenamesr@   r'   r'   r(   Ú_clean—   s    
zconfig._cleanr   c             C   sR   ddl m} | jƒ  d}y| j||||ƒ W n |k
rD   d}Y nX | jƒ  |S )Nr   )ÚCompileErrorTF)r4   rY   r5   rG   rX   )r&   r=   r>   r!   r?   rY   Úokr'   r'   r(   Útry_cpp­   s    
zconfig.try_cppc             C   sx   | j ƒ  | j||||ƒ\}}t|tƒr0tj|ƒ}t|ƒ}d}	x&|jƒ }
|
dkrPP |j|
ƒr>d}	P q>W |j	ƒ  | j
ƒ  |	S )NFÚ T)r5   rG   r*   r+   ÚrerI   r:   ÚreadlineÚsearchr<   rX   )r&   Úpatternr=   r>   r!   r?   rE   rF   rA   ÚmatchÚliner'   r'   r(   Ú
search_cpp¿   s     	


zconfig.search_cppc             C   sd   ddl m} | jƒ  y| j||||ƒ d}W n |k
rD   d}Y nX tj|rRdpTdƒ | jƒ  |S )Nr   )rY   TFzsuccess!zfailure.)r4   rY   r5   rK   r   rS   rX   )r&   r=   r>   r!   r?   rY   rZ   r'   r'   r(   Útry_compileÜ   s    
zconfig.try_compilec       
      C   sp   ddl m}m} | jƒ  y| j||||||ƒ d}	W n ||fk
rP   d}	Y nX tj|	r^dp`dƒ | jƒ  |	S )Nr   )rY   Ú	LinkErrorTFzsuccess!zfailure.)r4   rY   re   r5   rQ   r   rS   rX   )
r&   r=   r>   r!   r"   r#   r?   rY   re   rZ   r'   r'   r(   Útry_linkì   s    


zconfig.try_linkc             C   s„   ddl m}m} | jƒ  y.| j||||||ƒ\}	}
}| j|gƒ d}W n ||tfk
rd   d}Y nX tj|rrdptdƒ | j	ƒ  |S )Nr   )rY   re   TFzsuccess!zfailure.)
r4   rY   re   r5   rQ   Zspawnr   r   rS   rX   )r&   r=   r>   r!   r"   r#   r?   rY   re   rE   rJ   ZexerZ   r'   r'   r(   Útry_runÿ   s    

zconfig.try_runr   c       	      C   st   | j ƒ  g }|r|jd| ƒ |jdƒ |r<|jd| ƒ n|jd| ƒ |jdƒ dj|ƒd }| j|||||ƒS )Nz
int %s ();zint main () {z  %s();z  %s;ú}r7   )r5   rO   rT   rf   )	r&   Úfuncr>   r!   r"   r#   ZdeclZcallr=   r'   r'   r(   Ú
check_func  s    


zconfig.check_funcc             C   s    | j ƒ  | jd|||g| |ƒS )Nzint main (void) { })r5   rf   )r&   Zlibraryr#   r>   r!   Zother_librariesr'   r'   r(   Ú	check_lib6  s    

zconfig.check_libc             C   s   | j d|g|d�S )Nz/* No body */)r=   r>   r!   )r[   )r&   rB   r!   r#   r?   r'   r'   r(   Úcheck_headerD  s    
zconfig.check_header)r   Nr	   )r
   Nr   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   Nr   )r   Nr   )NNNr   )NNNr   )NNr   )NNNNr   )NNNNr   )NNNNr   r   )NNr   )Ú__name__Ú
__module__Ú__qualname__ZdescriptionZuser_optionsr)   r/   r0   r5   rC   rG   rK   rQ   rX   r[   rc   rd   rf   rg   rj   rk   rl   r'   r'   r'   r(   r      sT            	
 

 
 
 
 r   c          
   C   sJ   |d krt jd| ƒ n
t j|ƒ t| ƒ}zt j|jƒ ƒ W d |jƒ  X d S )Nz%s)r   rS   r:   Úreadr<   )r@   ÚheadrA   r'   r'   r(   rH   N  s    
rH   )N)r-   r]   Zdistutils.corer   Zdistutils.errorsr   Zdistutils.sysconfigr   Z	distutilsr   r9   r   rH   r'   r'   r'   r(   Ú<module>   s   
  ;