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     ø  --