
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    ¡ê,a=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ddddd	d
g	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d0dd „Zd1d!d"„Zd2d#d$„Zd3d%d&„Zd4d'd(„Zd5d*d+„Zdddg fd,d-„Zd6d.d/„ZdS )7Úconfigzprepare to build)z	compiler=Nzspecify the compiler type)zcc=Nzspecify the compiler executable)zinclude-dirs=ÚIz.list of directories to search for header files)zdefine=ÚDzC preprocessor macros to define)zundef=Ú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 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   ú=/opt/alt/python38/lib64/python3.8/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  tj¡| _ | jd krHg | _nt| jtƒr^| jg| _| jd krpg | _nt| jtƒrŒ| 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 r   r   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	rb| j 
| j	¡ | jrv| j | j¡ d S )Nr   )Ú	CCompilerÚnew_compilerr   )r   Údry_runZforce)Údistutils.ccompilerr"   r#   r   r   r$   r   r   Zset_include_dirsr   Zset_librariesr   Zset_library_dirs)r   r"   r#   r   r   r   Ú_check_compilerY   s     ÿ
zconfig._check_compilerc              	   C   sl   dt |  }t|dƒ�L}|r>|D ]}| d| ¡ q | d¡ | |¡ |d dkr^| d¡ W 5 Q R X |S )NZ_configtestÚwz#include <%s>
Ú
éÿÿÿÿ)ÚLANG_EXTÚopenÚwrite)r   ÚbodyÚheadersÚlangÚfilenameÚfileÚheaderr   r   r   Ú_gen_temp_sourcefilek   s    

zconfig._gen_temp_sourcefilec                 C   s<   |   |||¡}d}| j ||g¡ | jj|||d� ||fS )Nz_configtest.i©r   )r3   r   Úextendr   Z
preprocess)r   r-   r.   r   r/   ÚsrcÚoutr   r   r   Ú_preprocessw   s
    zconfig._preprocessc                 C   s\   |   |||¡}| jr"t|d| ƒ | j |g¡\}| j ||g¡ | jj|g|d� ||fS )Nzcompiling '%s':r4   )r3   r   Ú	dump_filer   Zobject_filenamesr   r5   Úcompile)r   r-   r.   r   r/   r6   Úobjr   r   r   Ú_compile~   s    zconfig._compilec           
      C   sr   |   ||||¡\}}tj tj |¡¡d }	| jj|g|	|||d� | jjd k	r\|	| jj }	| j 	|	¡ |||	fS )Nr   )r   r   Ztarget_lang)
r<   r   ÚpathÚsplitextÚbasenamer   Zlink_executableZexe_extensionr   Úappend)
r   r-   r.   r   r   r   r/   r6   r;   Úprogr   r   r   Ú_link‡   s    ýzconfig._linkc              	   G   sT   |s| j }g | _ t dd |¡¡ |D ](}zt |¡ W q& tk
rL   Y q&X q&d S )Nzremoving: %sú )r   r   ÚinfoÚjoinr   ÚremoveÚOSError)r   Ú	filenamesr0   r   r   r   Ú_clean–   s    zconfig._cleanNr   c                 C   sR   ddl m} |  ¡  d}z|  ||||¡ W n |k
rD   d}Y nX |  ¡  |S )Nr   ©ÚCompileErrorTF)r%   rK   r&   r8   rI   ©r   r-   r.   r   r/   rK   Úokr   r   r   Útry_cpp¬   s    
zconfig.try_cppc              	   C   sx   |   ¡  |  ||||¡\}}t|tƒr0t |¡}t|ƒ�.}d}	| ¡ }
|
dkrPqb| |
¡r>d}	qbq>W 5 Q R X |  	¡  |	S )NFÚ T)
r&   r8   r   r   Úrer:   r+   ÚreadlineÚsearchrI   )r   Úpatternr-   r.   r   r/   r6   r7   r1   ÚmatchÚliner   r   r   Ú
search_cpp¾   s    	



zconfig.search_cppc                 C   sd   ddl m} |  ¡  z|  ||||¡ d}W n |k
rD   d}Y nX t |rRdpTd¡ |  ¡  |S )Nr   rJ   TFúsuccess!úfailure.)r%   rK   r&   r<   r   rD   rI   rL   r   r   r   Útry_compileÚ   s    
zconfig.try_compilec           
   	   C   sp   ddl m}m} |  ¡  z|  ||||||¡ d}	W n ||fk
rP   d}	Y nX t |	r^dp`d¡ |  ¡  |	S ©Nr   )rK   Ú	LinkErrorTFrW   rX   )r%   rK   r[   r&   rB   r   rD   rI   )
r   r-   r.   r   r   r   r/   rK   r[   rM   r   r   r   Útry_linkê   s    
  ÿ
zconfig.try_linkc              
   C   s„   ddl m}m} |  ¡  z.|  ||||||¡\}	}
}|  |g¡ d}W n ||tfk
rd   d}Y nX t |rrdptd¡ |  	¡  |S rZ   )
r%   rK   r[   r&   rB   Zspawnr   r   rD   rI   )r   r-   r.   r   r   r   r/   rK   r[   r6   r;   ZexerM   r   r   r   Útry_runý   s    
  ÿ

zconfig.try_runr   c           	      C   st   |   ¡  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@   rE   r\   )	r   Úfuncr.   r   r   r   ZdeclZcallr-   r   r   r   Ú
check_func  s    


 ÿzconfig.check_funcc                 C   s    |   ¡  |  d|||g| |¡S )Nzint main (void) { })r&   r\   )r   Zlibraryr   r.   r   Zother_librariesr   r   r   Ú	check_lib4  s
    

 ÿzconfig.check_libc                 C   s   | j d|g|d�S )Nz/* No body */)r-   r.   r   )rN   )r   r2   r   r   r/   r   r   r   Úcheck_headerB  s    
ÿzconfig.check_header)NNNr   )NNNr   )NNr   )NNNNr   )NNNNr   )NNNNr   r   )NNr   )Ú__name__Ú
__module__Ú__qualname__ZdescriptionZuser_optionsr   r    r!   r&   r3   r8   r<   rB   rI   rN   rV   rY   r\   r]   r`   ra   rb   r   r   r   r   r      s\   î	
  ÿ

    ÿ
    ÿ
        ÿ
 ÿ
  ÿr   c                 C   sJ   |d krt  d| ¡ n
t  |¡ t| ƒ}zt  | ¡ ¡ W 5 | ¡  X d S )Nz%s)r   rD   r+   ÚcloseÚread)r0   Úheadr1   r   r   r   r9   K  s    
r9   )N)r   rP   Zdistutils.corer   Zdistutils.errorsr   Zdistutils.sysconfigr   Z	distutilsr   r*   r   r9   r   r   r   r   Ú<module>   s   
  8