a �DOg:��@s�ddlZddlZddlZddlTddlmZddlmZddlm Z ddl m Z ddl m Z mZddlmZGd d �d �Zd Zdd d �Zdddddd�Zdd�Zddd�Zdd�Zdd�ZdS)�N)�*)�spawn)� move_file)�mkpath)� newer_group)� split_quoted�execute)�logc @s�eZdZdZdZdZdZdZdZdZ dZ dddddd�Z gd�Z dqdd �Z d d �Zd d �Zdd�Zdd�Zdrdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z dsd0d1�Z!d2d3�Z"d4d5�Z#d6d7�Z$d8d9�Z%dtd:d;�Z&dudd?�Z(dvd@dA�Z)dBZ*dCZ+dDZ,dwdEdF�Z-dxdGdH�Z.dydIdJ�Z/dzdKdL�Z0dMdN�Z1dOdP�Z2dQdR�Z3d{dSdT�Z4d|dUdV�Z5d}dXdY�Z6d~dZd[�Z7dd\d]�Z8d�d_d`�Z9d�dbdc�Z:ddde�Z;dfdg�Zdldm�Z?d�dodp�Z@dS)�� CCompilerN�c�c++�objc)�.cz.ccz.cppz.cxxz.m)r r r rcCsb||_||_||_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.9/distutils/ccompiler.py�__init__UszCCompiler.__init__cKs<|D]2}||jvr&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�valuerrr r�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|�dvrFt|dt�s8|ddurFt|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.|�|�}|dur|j|=|j�||f�dSr�r/r�append)rr,r*r-rrr � define_macro�s zCCompiler.define_macrocCs0|�|�}|dur|j|=|f}|j�|�dSrr5)rr,r-Zundefnrrr �undefine_macro�s zCCompiler.undefine_macrocCs|j�|�dSr)rr6�r�dirrrr �add_include_dir�szCCompiler.add_include_dircCs|dd�|_dSr�r�r�dirsrrr �set_include_dirs�szCCompiler.set_include_dirscCs|j�|�dSr)rr6)r�libnamerrr � add_library�szCCompiler.add_librarycCs|dd�|_dSr)r)rZlibnamesrrr � set_libraries�szCCompiler.set_librariescCs|j�|�dSr)rr6r9rrr �add_library_dirszCCompiler.add_library_dircCs|dd�|_dSr)rr=rrr �set_library_dirs szCCompiler.set_library_dirscCs|j�|�dSr)rr6r9rrr �add_runtime_library_dirsz!CCompiler.add_runtime_library_dircCs|dd�|_dSr)rr=rrr �set_runtime_library_dirssz"CCompiler.set_runtime_library_dirscCs|j�|�dSr)rr6)r�objectrrr �add_link_object szCCompiler.add_link_objectcCs|dd�|_dSr)r)rrrrr �set_link_objects(szCCompiler.set_link_objectscCs|dur|j}nt|t�s"td��|dur2|j}n"t|t�rL||jpFg}ntd��|durd|j}n*t|ttf�r�t|�|jp�g}ntd��|dur�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(r3r�listrr1�object_filenames�gen_preprocess_options�ranger2�os�path�splitextr�dirname)rZoutdirrZincdirs�sources�depends�extrar�pp_opts�buildr-�src�obj�extrrr �_setup_compile6s<  �� zCCompiler._setup_compilecCs0|dg}|rdg|dd�<|r,||dd�<|S)Nz-cz-grr)rrY�debug�before�cc_argsrrr � _get_cc_argsas   zCCompiler._get_cc_argscCs�|dur|j}nt|t�s"td��|dur2|j}n"t|t�rL||jpFg}ntd��|durd|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)NrJrKrL)rr'r(r3rrNrr1)rrrrrrr �_fix_compile_argsjs"   �zCCompiler._fix_compile_argscCs|j||d�}|ifS)N)r)rO)rrVrrWrrrr � _prep_compile�s zCCompiler._prep_compilecCsHt|ttf�std��t|�}|dur.|j}nt|t�s@td��||fS)Nz,'objects' must be a list or tuple of stringsrJ)r'rNr1r3rr()rrrrrr �_fix_object_args�s zCCompiler._fix_object_argscCs�|dur|j}n*t|ttf�r2t|�|jp,g}ntd��|durJ|j}n*t|ttf�rlt|�|jpfg}ntd��|dur�|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'rNr1r3rr)rrrrrrr � _fix_lib_args�s,���zCCompiler._fix_lib_argscCs2|jr dS|jr t||dd�}n t||�}|SdS)NT�newer)�missing)rrr)rr� output_filergrrr � _need_link�s  zCCompiler._need_linkc Cs|t|t�s|g}d}t|j�}|D]T}tj�|�\}}|j�|�}z |j� |�}||kr`|}|}Wq"t ytYq"0q"|Sr) r'rNr2�language_orderrRrSrT� language_map�get�indexr") rrV�langrn�source�baser]ZextlangZextindexrrr �detect_language�s     zCCompiler.detect_languagecCsdSrr)rrprirr� extra_preargs�extra_postargsrrr � preprocess�s zCCompiler.preprocessc  Csv|�||||||�\}} }} } |�| ||�} | D]@} z| | \}}WntyZYq0Yn0|�| ||| || �q0| Sr)r^rb�KeyError�_compile)rrVrrrr_rsrtrWrrYrZrar\r[r]rrr �compile�s6 ��   zCCompiler.compilecCsdSrr)rr\r[r]rartrYrrr rwCszCCompiler._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_rsrt� build_temprzrrr �linkis9zCCompiler.linkc Cs2|�tj||j|dd�||||||| | | | � dS)N�shared)�lib_type)r�r �SHARED_LIBRARY�library_filename) rrryrrrrr�r_rsrtr�rzrrr �link_shared_lib�s  �zCCompiler.link_shared_libc Cs(|�tj||||||||| | | | � dSr)r�r � SHARED_OBJECT) rrrrrrrr�r_rsrtr�rzrrr �link_shared_object�s �zCCompiler.link_shared_objectc Cs.|�tj||�|�||||d||| d| � dSr)r�r � EXECUTABLE�executable_filename) rrZoutput_prognamerrrrr_rsrtrzrrr �link_executable�s   �zCCompiler.link_executablecCst�dSrr}r9rrr �library_dir_option�szCCompiler.library_dir_optioncCst�dSrr}r9rrr �runtime_library_dir_option�sz$CCompiler.runtime_library_dir_optioncCst�dSrr})r�librrr �library_option�szCCompiler.library_optionc Cs�ddl}|durg}|dur g}|dur,g}|dur8g}|jd|dd�\}}t�|d�} z2|D]} | �d| �q^| �d|�W| ��n | ��0z|j|g|d�} Wnty�Yd S0z|j| d ||d �Wnt t fy�Yd S0dS) NrrT)�text�wz#include "%s" z=int main (int argc, char **argv) { %s(); return 0; } r<Fza.out)rr) �tempfile�mkstemprR�fdopen�write�closerxZ CompileErrorr�Z LinkErrorr3) r�funcnameZincludesrrrr��fd�fname�fZinclrrrr � has_function�s<  � � zCCompiler.has_functioncCst�dSrr})rr>r�r_rrr �find_library_file$szCCompiler.find_library_file�cCs�|dur d}g}|D]|}tj�|�\}}tj�|�d}|tj�|�d�}||jvrftd||f��|rvtj�|�}|�tj� |||j ��q|S)Nr�r+z"unknown file type '%s' (from '%s')) rRrSrT� splitdrive�isabs�src_extensionsZUnknownFileError�basenamer6�join� obj_extension)rZsource_filenamesrMrZ obj_namesZsrc_namerqr]rrr rOOs"  �  �zCCompiler.object_filenamescCs$|rtj�|�}tj�|||j�Sr)rRrSr�r��shared_lib_extension�rr�rMrrrr �shared_object_filename`s z CCompiler.shared_object_filenamecCs(|rtj�|�}tj�|||jp"d�S)Nr�)rRrSr�r�� exe_extensionr�rrr r�fs zCCompiler.executable_filename�staticc Cs`|dvrtd��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"�getattrrRrS�splitr�) rr@r�rMr�fmtr]r:rq�filenamerrr r�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)rr)r�func�argsr�r�rrr r�szCCompiler.executecCst||jd�dS�N)r)rr)r�cmdrrr r�szCCompiler.spawncCst|||jd�Sr�)rr)rr[�dstrrr r�szCCompiler.move_file��cCst|||jd�dSr�)rr)rr,�moderrr r�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�rlrkr!r&rr/r4r7r8r;r?rArBrCrDrErFrHrIr^rbrcrdrerfrjrrrurxrwr{r�r�r�r�r�r�r�r�r�r�r�r�rOr�r�r�r�r�r�rrrrrrrr r s�� $   +  " � � D� � A� � � � , +   �   r ))zcygwin.*�unix)�posixr�)�nt�msvccCsV|durtj}|durtj}tD]0\}}t�||�dusHt�||�dur |Sq dS)Nr�)rRr,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=r0zList of available compilers:)Zdistutils.fancy_getoptr��compiler_classrr6�sort� print_help)r�Z compilersr�Zpretty_printerrrr �show_compilers�s    �r�c Cs�|durtj}z"|dur t|�}t|\}}}Wn6tyfd|}|durZ|d|}t|��Yn0z*d|}t|�tj|} t | �|} Wn>t y�t d|��Yn"ty�t d||f��Yn0| 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') rRr,r�r�rvZDistutilsPlatformError� __import__r��modules�vars� ImportErrorZDistutilsModuleError) Zplatr�rrr� module_name� class_nameZlong_descriptionr��module�klassrrr � new_compiler�s:     �� �� r�cCs�g}|D]�}t|t�r0dt|�kr.dkss6      �  --