add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
U

�AT^=3c@shddlZddlZddlmZddlmZddlmZddlm	Z	ddd�Z
Gd	d
�d
e�Zd
dd�ZdS)�N)�Command)�DistutilsExecError)�customize_compiler)�logz.cz.cxx)�czc++c	@s�eZdZdZdddddddd	d
g	Zdd�Zd
d�Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�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)zdump-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�osZpathseprrrrrr�finalize_optionsBs



zconfig.finalize_optionscCsdSrrrrrr�runRsz
config.runcCszddlm}m}t|j|�sv||j|jdd�|_t|j�|jrN|j�|j�|j	rb|j�
|j	�|jrv|j�|j�dS)Nr)�	CCompiler�new_compilerr)r	�dry_runZforce)
�distutils.ccompilerrrrr	rrr
Zset_include_dirsrZ
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)rrZtarget_lang)
r1rZpathZsplitextZbasenamer	Zlink_executableZ
exe_extensionr�append)
rr"r#r
rr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
rr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
rr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
rr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__ZdescriptionZ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<module>s
8