3 \7��@s�ddlZddlZddlZddlTddlmZddlmZddlm Z ddl m Z m Z ddl mZmZddlmZGd d �d �Zd,Zd-dd�Zd.d/d0d1d2d �Zd!d"�Zd3d#d$�Zd%d&�Zd'd(�ZdS)4�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)z.cz.ccz.cppz.cxxz.mrcCsf||_||_||_d|_g|_g|_g|_g|_g|_g|_ x$|j j �D]}|j ||j |�qHWdS)N) �dry_run�force�verbose� output_dir�macros� include_dirs� libraries� library_dirs�runtime_library_dirs�objects� executables�keys�set_executable)�selfrr r�key�r�+/usr/lib64/python3.6/distutils/ccompiler.py�__init__UszCCompiler.__init__cKs@x:|D]2}||jkr(td||jjf��|j|||�qWdS)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|||�dS)N)� isinstance�str�setattrr)rr�valuerrrr�s zCCompiler.set_executablecCs0d}x&|jD]}|d|kr |S|d7}q WdS)Nr�)r)r�name�i�defnrrr� _find_macro�s    zCCompiler._find_macrocCsdx^|D]V}t|t�oFt|�dkoFt|dt�s:|ddkoFt|dt�std|dd��qWdS)Nr(�rzinvalid macro definition '%s': z.must be tuple (string,), (string, string), or z(string, None))r(r-)r$�tuple�lenr%� TypeError)rZ definitionsr+rrr�_check_macro_definitions�s    z"CCompiler._check_macro_definitionscCs.|j|�}|dk r|j|=|jj||f�dS)N)r,r�append)rr)r'r*rrr� define_macro�s zCCompiler.define_macrocCs0|j|�}|dk r|j|=|f}|jj|�dS)N)r,rr2)rr)r*Zundefnrrr�undefine_macro�s zCCompiler.undefine_macrocCs|jj|�dS)N)rr2)r�dirrrr�add_include_dir�szCCompiler.add_include_dircCs|dd�|_dS)N)r)r�dirsrrr�set_include_dirs�szCCompiler.set_include_dirscCs|jj|�dS)N)rr2)r�libnamerrr� add_library�szCCompiler.add_librarycCs|dd�|_dS)N)r)rZlibnamesrrr� set_libraries�szCCompiler.set_librariescCs|jj|�dS)N)rr2)rr5rrr�add_library_dirszCCompiler.add_library_dircCs|dd�|_dS)N)r)rr7rrr�set_library_dirs szCCompiler.set_library_dirscCs|jj|�dS)N)rr2)rr5rrr�add_runtime_library_dirsz!CCompiler.add_runtime_library_dircCs|dd�|_dS)N)r)rr7rrr�set_runtime_library_dirssz"CCompiler.set_runtime_library_dirscCs|jj|�dS)N)rr2)r�objectrrr�add_link_object szCCompiler.add_link_objectcCs|dd�|_dS)N)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} xRt t |��D]B} || } || } t j j| �d} |jt j j| ��| | f| | <q�W||||| fS)Nz%'output_dir' must be a string or Nonez/'macros' (if supplied) must be a list of tuplesz6'include_dirs' (if supplied) must be a list of stringsr)� strip_dirrr()rr$r%r0r�listrr.�object_filenames�gen_preprocess_options�ranger/�os�path�splitextr�dirname)rZoutdirrZincdirs�sources�dependsZextrar�pp_opts�buildr*�src�obj�extrrr�_setup_compile6s8   zCCompiler._setup_compilecCs0|dg}|rdg|dd�<|r,||dd�<|S)Nz-cz-grr)rrN�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)Nz%'output_dir' must be a string or Nonez/'macros' (if supplied) must be a list of tuplesz6'include_dirs' (if supplied) must be a list of strings)rr$r%r0rrDrr.)rrrrrrr�_fix_compile_argsjs   zCCompiler._fix_compile_argscCs|j||d�}|ifS)N)r)rE)rrLrrMrrrr� _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 stringsz%'output_dir' must be a string or None)r$rDr.r0rr%)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$rDr.r0rr)rrrrrrr� _fix_lib_args�s&zCCompiler._fix_lib_argscCs2|jr dS|jr t||dd�}n t||�}|SdS)NT�newer)Zmissing)rr r)rr� output_filer[rrr� _need_link�s  zCCompiler._need_linkc Cs�t|t�s|g}d}t|j�}x^|D]V}tjj|�\}}|jj|�}y |jj |�}||krb|}|}Wq$t k rxYq$Xq$W|S)N) r$rDr/�language_orderrHrIrJ� language_map�get�indexr) rrLZlangra�source�baserRZextlangZextindexrrr�detect_language�s      zCCompiler.detect_languagecCsdS)Nr)rrbr\rr� extra_preargs�extra_postargsrrr� preprocess�s zCCompiler.preprocessc Csz|j||||||�\}} }} } |j| ||�} xH| D]@} y| | \}}Wntk r\w2YnX|j| ||| || �q2W| S)N)rSrV�KeyError�_compile)rrLrrrrTrerfrMrrNrOrUrQrPrRrrr�compile�s6  zCCompiler.compilecCsdS)Nr)rrQrPrRrUrfrNrrrriCszCCompiler._compilecCsdS)Nr)rr�output_libnamerrT� target_langrrr�create_static_libIszCCompiler.create_static_libZ shared_objectZshared_library� executablecCst�dS)N)�NotImplementedError)rZ target_descr�output_filenamerrrr�export_symbolsrTrerf� build_temprlrrr�linkis9zCCompiler.linkc Cs2|jtj||j|dd�||||||| | | | � dS)N�shared)�lib_type)rsr �SHARED_LIBRARY�library_filename) rrrkrrrrrqrTrerfrrrlrrr�link_shared_lib�s  zCCompiler.link_shared_libc Cs(|jtj||||||||| | | | � dS)N)rsr � SHARED_OBJECT) rrrprrrrrqrTrerfrrrlrrr�link_shared_object�s zCCompiler.link_shared_objectc Cs.|jtj||j|�||||d||| d| � dS)N)rsr � EXECUTABLE�executable_filename) rrZoutput_prognamerrrrrTrerfrlrrr�link_executable�s  zCCompiler.link_executablecCst�dS)N)ro)rr5rrr�library_dir_option�szCCompiler.library_dir_optioncCst�dS)N)ro)rr5rrr�runtime_library_dir_option�sz$CCompiler.runtime_library_dir_optioncCst�dS)N)ro)r�librrr�library_option�szCCompiler.library_optionc Cs�ddl}|dkrg}|dkr g}|dkr,g}|dkr8g}|jd|dd�\}}tj|d�} z.x|D]} | jd| �q`W| jd|�Wd| j�Xy|j|g|d�} Wntk r�d SXy|j| d ||d �Wnt t fk r�d SXdS) Nrz.cT)�text�wz#include "%s" z+main (int argc, char **argv) { %s(); } )rFza.out)rr) �tempfileZmkstemprH�fdopen�write�closerjZ CompileErrorr}Z LinkErrorr0) r�funcnameZincludesrrrr��fdZfname�fZinclrrrr� has_function�s8     zCCompiler.has_functioncCst�dS)N)ro)rr7r�rTrrr�find_library_file#szCCompiler.find_library_file�cCs�|dkr d}g}x�|D]|}tjj|�\}}tjj|�d}|tjj|�d�}||jkrhtd||f��|rxtjj|�}|jtjj |||j ��qW|S)Nr�r(z"unknown file type '%s' (from '%s')) rHrIrJ� splitdrive�isabs�src_extensionsZUnknownFileError�basenamer2�join� obj_extension)rZsource_filenamesrCrZ obj_namesZsrc_namercrRrrrrENs    zCCompiler.object_filenamescCs$|rtjj|�}tjj|||j�S)N)rHrIr�r��shared_lib_extension)rr�rCrrrr�shared_object_filename_s z CCompiler.shared_object_filenamecCs(|rtjj|�}tjj|||jp"d�S)Nr�)rHrIr�r�� exe_extension)rr�rCrrrrr|es zCCompiler.executable_filename�staticc Cs`|d krtd��t||d�}t||d�}tjj|�\}}|||f} |rPd}tjj||| �S) Nr�rt�dylib� xcode_stubz?'lib_type' must be "static", "shared", "dylib", or "xcode_stub"Z _lib_formatZ_lib_extensionr�)r�rtr�r�)r�getattrrHrI�splitr�) rr9rurCrZfmtrRr5rc�filenamerrrrwks zCCompiler.library_filenamer(cCstj|�dS)N)r rT)r�msg�levelrrr�announce~szCCompiler.announcecCsddlm}|rt|�dS)Nr)�DEBUG)Zdistutils.debugr��print)rr�r�rrr� debug_print�s zCCompiler.debug_printcCstjjd|�dS)Nz warning: %s )�sys�stderrr�)rr�rrr�warn�szCCompiler.warncCst||||j�dS)N)r r )r�func�argsr�r�rrrr �szCCompiler.executecCst||jd�dS)N)r )rr )r�cmdrrrr�szCCompiler.spawncCst|||jd�S)N)r )rr )rrP�dstrrrr�szCCompiler.move_file��cCst|||jd�dS)N)r )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�r_r^rr#rr,r1r3r4r6r8r:r;r<r=r>r?rArBrSrVrWrXrYrZr]rdrgrjrirmryrvr{rsrxrzr}r~rr�r�r�rEr�r|rwr�r�r�r rrrrrrrr s�  $   +  "   B  4    * +      r �cygwin.*�unix�posix�nt�msvccCsV|dkrtj}|dkrtj}x4tD],\}}tj||�dk sJtj||�dk r"|Sq"WdS)Nr�)rHr)r��platform�_default_compilers�re�match)�osnamer��pattern�compilerrrr�get_default_compiler�s r�� unixccompiler� UnixCCompiler�standard UNIX-style compiler� _msvccompiler� MSVCCompiler�Microsoft Visual C++�cygwinccompiler�CygwinCCompiler�'Cygwin port of GNU C Compiler for Win32�Mingw32CCompiler�(Mingw32 port of GNU C Compiler for Win32� bcppcompiler� BCPPCompiler�Borland C++ Compiler)r�r��cygwinZmingw32ZbcppcCs\ddlm}g}x,tj�D] }|jd|dt|df�qW|j�||�}|jd�dS)Nr)� FancyGetoptz compiler=r-zList of available compilers:)Zdistutils.fancy_getoptr��compiler_classrr2�sortZ print_help)r�Z compilersr�Zpretty_printerrrr�show_compilers�s  r�c Cs�|dkrtj}y"|dkr t|�}t|\}}}Wn8tk rhd|}|dk r\|d|}t|��YnXy*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') rHr)r�r�rhZDistutilsPlatformError� __import__r��modules�vars� ImportErrorZDistutilsModuleError) Zplatr�rr rZ module_name� class_nameZlong_descriptionr��module�klassrrr� new_compiler�s2    r�cCs�g}x�|D]�}t|t�o2dt|�ko.dkns@td|��t|�dkr`|jd|d�q t|�dkr |ddkr�|jd|d�q |jd|�q Wx|D]}|jd|�q�W|S) Nr(r-zPbad macro definition '%s': each element of 'macros' list must be a 1- or 2-tuplez-U%srz-D%sz-D%s=%sz-I%s)r$r.r/r0r2)rrrNZmacror5rrrrF s &    rFc Cs�g}x|D]}|j|j|��q Wx4|D],}|j|�}t|t�rJ||}q(|j|�q(Wx^|D]V}tjj|�\}} |r�|j|g| �} | r�|j| �q�|j d|�q^|j|j |��q^W|S)Nz6no library file corresponding to '%s' found (skipping)) r2r~rr$rDrHrIr�r�r�r�) r�rrrZlib_optsr5�optr�Zlib_dirZlib_nameZlib_filerrr�gen_lib_options7s$        r��r�r��r�r��r�r�)r�r�r�)NN)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)NNrrr)r�rHr�Zdistutils.errorsZdistutils.spawnrZdistutils.file_utilrZdistutils.dir_utilrZdistutils.dep_utilrrZdistutils.utilrr Z distutilsr r r�r�r�r�r�rFr�rrrr�sB      --