U e5dI��@s�ddlZddlZddlZddlTddlmZddlmZddlm Z ddl m Z m Z ddl mZmZddlmZGd d �d �Zd Zdd d �Zdddddd�Zdd�Zddd�Zdd�Zdd�ZdS)�N)�*)�spawn)� move_file)�mkpath)�newer_pairwise� newer_group)� split_quoted�execute)�logc @seZdZdZdZdZdZdZdZdZ dZ dddddd�Z dddgZ dpdd�Z d d �Zd d �Zd d�Zdd�Zdqdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z drd/d0�Z!d1d2�Z"d3d4�Z#d5d6�Z$d7d8�Z%dsd9d:�Z&dtd;d<�Z'd=d>�Z(dud?d@�Z)dAZ*dBZ+dCZ,dvdDdE�Z-dwdFdG�Z.dxdHdI�Z/dydJdK�Z0dLdM�Z1dNdO�Z2dPdQ�Z3dzdRdS�Z4d{dTdU�Z5d|dWdX�Z6d}dYdZ�Z7d~d[d\�Z8dd^d_�Z9d�dadb�Z:dcdd�Z;dedf�Zdkdl�Z?d�dndo�Z@dS)�� CCompilerN�czc++Zobjc)�.cz.ccz.cppz.cxxz.mrcCsb||_||_||_d|_g|_g|_g|_g|_g|_g|_ |j � �D]}|� ||j |�qFdS�N) �dry_run�force�verbose� output_dir�macros� include_dirs� libraries� library_dirs�runtime_library_dirs�objects� executables�keys�set_executable)�selfrrr�key�r�+/usr/lib64/python3.8/distutils/ccompiler.py�__init__UszCCompiler.__init__cKs<|D]2}||jkr&td||jjf��|�|||�qdS)Nz$unknown executable '%s' for class %s)r� ValueError� __class__�__name__r)r�kwargsrrrr�set_executablesys   �zCCompiler.set_executablescCs,t|t�rt||t|��n t|||�dSr)� isinstance�str�setattrr)rr�valuerrrr�s zCCompiler.set_executablecCs0d}|jD] }|d|kr"|S|d7}q dS)Nr�)r)r�name�i�defnrrr� _find_macro�s    zCCompiler._find_macrocCs`|D]V}t|t�rFt|�dkrFt|dt�s8|ddkrFt|dt�std|dd��qdS)N)r*�r*rzinvalid macro definition '%s': z.must be tuple (string,), (string, string), or z(string, None))r&�tuple�lenr'� TypeError)rZ definitionsr-rrr�_check_macro_definitions�s  � � � ���z"CCompiler._check_macro_definitionscCs.|�|�}|dk r|j|=|j�||f�dSr�r.r�append)rr+r)r,rrr� define_macro�s zCCompiler.define_macrocCs0|�|�}|dk r|j|=|f}|j�|�dSrr4)rr+r,Zundefnrrr�undefine_macro�s zCCompiler.undefine_macrocCs|j�|�dSr)rr5�r�dirrrr�add_include_dir�szCCompiler.add_include_dircCs|dd�|_dSr�r�r�dirsrrr�set_include_dirs�szCCompiler.set_include_dirscCs|j�|�dSr)rr5)r�libnamerrr� add_library�szCCompiler.add_librarycCs|dd�|_dSr)r)rZlibnamesrrr� set_libraries�szCCompiler.set_librariescCs|j�|�dSr)rr5r8rrr�add_library_dirszCCompiler.add_library_dircCs|dd�|_dSr)rr<rrr�set_library_dirs szCCompiler.set_library_dirscCs|j�|�dSr)rr5r8rrr�add_runtime_library_dirsz!CCompiler.add_runtime_library_dircCs|dd�|_dSr)rr<rrr�set_runtime_library_dirssz"CCompiler.set_runtime_library_dirscCs|j�|�dSr)rr5)r�objectrrr�add_link_object szCCompiler.add_link_objectcCs|dd�|_dSr)r)rrrrr�set_link_objects(szCCompiler.set_link_objectscCs|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|dkr�g}|j|d|d�}t ||�}i} t t |��D]B} || } || } t j �| �d} |�t j �| ��| | f| | <q�||||| fS)N�%'output_dir' must be a string or None�/'macros' (if supplied) must be a list of tuples�6'include_dirs' (if supplied) must be a list of stringsr)� strip_dirrr*)rr&r'r2r�listrr0�object_filenames�gen_preprocess_options�ranger1�os�path�splitextr�dirname)rZoutdirrZincdirs�sources�dependsZextrar�pp_opts�buildr,�src�obj�extrrr�_setup_compile6s<  �� zCCompiler._setup_compilecCs0|dg}|rdg|dd�<|r,||dd�<|S)Nz-cz-grr)rrW�debugZbefore�cc_argsrrr� _get_cc_argsas   zCCompiler._get_cc_argscCs�|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)NrIrJrK)rr&r'r2rrMrr0)rrrrrrr�_fix_compile_argsjs"   �zCCompiler._fix_compile_argscCs|j||d�}|ifS)N)r)rN)rrUrrVrrrr� _prep_compile�s zCCompiler._prep_compilecCsHt|ttf�std��t|�}|dkr.|j}nt|t�s@td��||fS)Nz,'objects' must be a list or tuple of stringsrI)r&rMr0r2rr')rrrrrr�_fix_object_args�s zCCompiler._fix_object_argscCs�|dkr|j}n*t|ttf�r2t|�|jp,g}ntd��|dkrJ|j}n*t|ttf�rlt|�|jpfg}ntd��|dkr�|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)Nz3'libraries' (if supplied) must be a list of stringsz6'library_dirs' (if supplied) must be a list of stringsz>'runtime_library_dirs' (if supplied) must be a list of strings)rr&rMr0r2rr)rrrrrrr� _fix_lib_args�s,���zCCompiler._fix_lib_argscCs2|jr dS|jr t||dd�}n t||�}|SdS)NT�newer)Zmissing)rrr)rr� output_filerdrrr� _need_link�s  zCCompiler._need_linkc Cs~t|t�s|g}d}t|j�}|D]V}tj�|�\}}|j�|�}z |j� |�}||kr`|}|}Wq"t k rvYq"Xq"|Sr) r&rMr1�language_orderrQrRrS� language_map�get�indexr!) rrUZlangrj�source�baser[ZextlangZextindexrrr�detect_language�s    zCCompiler.detect_languagecCsdSrr)rrkrerr� extra_preargs�extra_postargsrrr� preprocess�s zCCompiler.preprocessc  Csx|�||||||�\}} }} } |�| ||�} | D]B} z| | \}}Wntk r\Yq0YnX|�| ||| || �q0| Sr)r\r_�KeyError�_compile)rrUrrrr]rnrorVrrWrXr^rZrYr[rrr�compile�s6 ��  zCCompiler.compilecCsdSrr)rrZrYr[r^rorWrrrrrCszCCompiler._compilecCsdSrr)rr�output_libnamerr]� target_langrrr�create_static_libIszCCompiler.create_static_libZ shared_objectZshared_library� executablecCst�dSr��NotImplementedError)rZ target_descr�output_filenamerrrr�export_symbolsr]rnro� build_temprurrr�linkis9zCCompiler.linkc Cs2|�tj||j|dd�||||||| | | | � dS)N�shared)�lib_type)r}r �SHARED_LIBRARY�library_filename) rrrtrrrrr{r]rnror|rurrr�link_shared_lib�s  �zCCompiler.link_shared_libc Cs(|�tj||||||||| | | | � dSr)r}r � SHARED_OBJECT) rrrzrrrrr{r]rnror|rurrr�link_shared_object�s �zCCompiler.link_shared_objectc Cs.|�tj||�|�||||d||| d| � dSr)r}r � EXECUTABLE�executable_filename) rrZoutput_prognamerrrrr]rnrorurrr�link_executable�s �zCCompiler.link_executablecCst�dSrrxr8rrr�library_dir_option�szCCompiler.library_dir_optioncCst�dSrrxr8rrr�runtime_library_dir_option�sz$CCompiler.runtime_library_dir_optioncCst�dSrrx)r�librrr�library_option�szCCompiler.library_optionc Cs�ddl}|dkrg}|dkr g}|dkr,g}|dkr8g}|jd|dd�\}}t�|d�} z*|D]} | �d| �q^| �d|�W5| ��Xz|j|g|d�} Wntk r�Yd SXz|j| d ||d �Wnt t fk r�Yd SXdS) Nrr T)�text�wz#include "%s" z=int main (int argc, char **argv) { %s(); return 0; } r;Fza.out)rr) �tempfileZmkstemprQ�fdopen�close�writersZ CompileErrorr�Z LinkErrorr2) r�funcnameZincludesrrrr��fdZfname�fZinclrrrr� has_function�s<  �  � zCCompiler.has_functioncCst�dSrrx)rr=r�r]rrr�find_library_file$szCCompiler.find_library_file�cCs�|dkr d}g}|D]|}tj�|�\}}tj�|�d}|tj�|�d�}||jkrftd||f��|rvtj�|�}|�tj� |||j ��q|S)Nr�r*z"unknown file type '%s' (from '%s')) rQrRrS� splitdrive�isabs�src_extensionsZUnknownFileError�basenamer5�join� obj_extension)rZsource_filenamesrLrZ obj_namesZsrc_namerlr[rrrrNOs"  �  �zCCompiler.object_filenamescCs$|rtj�|�}tj�|||j�Sr)rQrRr�r��shared_lib_extension�rr�rLrrrr�shared_object_filename`s z CCompiler.shared_object_filenamecCs(|rtj�|�}tj�|||jp"d�S)Nr�)rQrRr�r�� exe_extensionr�rrrr�fs zCCompiler.executable_filename�staticc Cs`|dkrtd��t||d�}t||d�}tj�|�\}}|||f} |rPd}tj�||| �S)N)r�r~ZdylibZ xcode_stubz?'lib_type' must be "static", "shared", "dylib", or "xcode_stub"Z _lib_formatZ_lib_extensionr�)r!�getattrrQrR�splitr�) rr?rrLrZfmtr[r9rl�filenamerrrr�ls� zCCompiler.library_filenamer*cCst�|�dSr)r r])r�msg�levelrrr�announceszCCompiler.announcecCsddlm}|rt|�dS)Nr)�DEBUG)Zdistutils.debugr��print)rr�r�rrr� debug_print�s zCCompiler.debug_printcCstj�d|�dS)Nz warning: %s )�sys�stderrr�)rr�rrr�warn�szCCompiler.warncCst||||j�dSr)r r)r�func�argsr�r�rrrr �szCCompiler.executecCst||jd�dS�N)r)rr)r�cmdrrrr�szCCompiler.spawncCst|||jd�Sr�)rr)rrYZdstrrrr�szCCompiler.move_file��cCst|||jd�dSr�)rr)rr+�moderrrr�szCCompiler.mkpath)rrr)N)N)NNNNN)NNNrNNN)NrN) NNNNNrNNNN) NNNNNrNNNN) NNNNNrNNNN)NNNNrNNN)NNNN)r)rr�)rr�)rr�)r�rr�)r*)Nr*)r�)Ar#� __module__� __qualname__Z compiler_typer�r�Zstatic_lib_extensionr�Zstatic_lib_formatZshared_lib_formatr�rhrgr r%rr.r3r6r7r:r>r@rArBrCrDrErGrHr\r_r`rarbrcrfrmrprsrrrvr�r�r�r}r�r�r�r�r�r�r�r�rNr�r�r�r�r�r�r rrrrrrrr s��  $   +  " � � D� � A� � � � , +   �   r ))zcygwin.*�unix)�posixr�)�nt�msvccCsV|dkrtj}|dkrtj}tD]0\}}t�||�dk sHt�||�dk r |Sq dS)Nr�)rQr+r��platform�_default_compilers�re�match)Zosnamer��pattern�compilerrrr�get_default_compiler�s  � r�)Z unixccompilerZ UnixCCompilerzstandard UNIX-style compiler)Z _msvccompilerZ MSVCCompilerzMicrosoft Visual C++)�cygwinccompilerZCygwinCCompilerz'Cygwin port of GNU C Compiler for Win32)r�ZMingw32CCompilerz(Mingw32 port of GNU C Compiler for Win32)Z bcppcompilerZ BCPPCompilerzBorland C++ Compiler)r�r��cygwinZmingw32ZbcppcCsXddlm}g}t��D] }|�d|dt|df�q|��||�}|�d�dS)Nr)� FancyGetoptz compiler=r/zList of available compilers:)Zdistutils.fancy_getoptr��compiler_classrr5�sortZ print_help)r�Z compilersr�Zpretty_printerrrr�show_compilers�s    �r�c Cs�|dkrtj}z"|dkr t|�}t|\}}}Wn8tk rhd|}|dk r\|d|}t|��YnXz*d|}t|�tj|} t | �|} WnBt k r�t d|��Yn$tk r�t d||f��YnX| d||�S)Nz5don't know how to compile C/C++ code on platform '%s'z with '%s' compilerz distutils.z4can't compile C/C++ code: unable to load module '%s'zBcan't compile C/C++ code: unable to find class '%s' in module '%s') rQr+r�r�rqZDistutilsPlatformError� __import__r��modules�vars� ImportErrorZDistutilsModuleError) Zplatr�rrrZ module_name� class_nameZlong_descriptionr��module�klassrrr� new_compiler�s:   ���� r�cCs�g}|D]�}t|t�r0dt|�kr.dkss6     �  --