a DOg:@sddlZddlZddlZddlTddlmZddlmZddlm Z ddl m Z ddl m Z mZddlmZGd d d Zd Zdd d ZddddddZddZdddZddZddZdS)N)*)spawn) move_file)mkpath) newer_group) split_quotedexecute)logc @seZdZdZdZdZdZdZdZdZ dZ ddddddZ gdZ dqdd Z d d Zd d ZddZddZdrddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Z dsd0d1Z!d2d3Z"d4d5Z#d6d7Z$d8d9Z%dtd:d;Z&dudd?Z(dvd@dAZ)dBZ*dCZ+dDZ,dwdEdFZ-dxdGdHZ.dydIdJZ/dzdKdLZ0dMdNZ1dOdPZ2dQdRZ3d{dSdTZ4d|dUdVZ5d}dXdYZ6d~dZd[Z7dd\d]Z8dd_d`Z9ddbdcZ:dddeZ;dfdgZdldmZ?ddodpZ@dS) CCompilerNcc++objc).cz.ccz.cppz.cxxz.m)r r r rcCsb||_||_||_d|_g|_g|_g|_g|_g|_g|_ |j D]}| ||j |qFdSN) dry_runforceverbose output_dirmacros include_dirs libraries library_dirsruntime_library_dirsobjects executableskeysset_executable)selfrrrkeyr8/opt/alt/python39/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)rkwargsrrrr set_executablesys   zCCompiler.set_executablescCs,t|trt||t|n t|||dSr) isinstancestrsetattrr)rrvaluerrr rs zCCompiler.set_executablecCs0d}|jD] }|d|kr"|S|d7}q dS)Nr)r)rnameidefnrrr _find_macros    zCCompiler._find_macrocCs`|D]V}t|trFt|dvrFt|dts8|ddurFt|dtstd|ddqdS)N)r+r+rzinvalid macro definition '%s': z.must be tuple (string,), (string, string), or z(string, None))r'tuplelenr( TypeError)rZ definitionsr.rrr _check_macro_definitionss     z"CCompiler._check_macro_definitionscCs.||}|dur|j|=|j||fdSrr/rappend)rr,r*r-rrr define_macros zCCompiler.define_macrocCs0||}|dur|j|=|f}|j|dSrr5)rr,r-Zundefnrrr undefine_macros zCCompiler.undefine_macrocCs|j|dSr)rr6rdirrrr add_include_dirszCCompiler.add_include_dircCs|dd|_dSrrrdirsrrr set_include_dirsszCCompiler.set_include_dirscCs|j|dSr)rr6)rlibnamerrr add_libraryszCCompiler.add_librarycCs|dd|_dSr)r)rZlibnamesrrr set_librariesszCCompiler.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)robjectrrr add_link_object szCCompiler.add_link_objectcCs|dd|_dSr)r)rrrrr set_link_objects(szCCompiler.set_link_objectscCs|dur|j}nt|ts"td|dur2|j}n"t|trL||jpFg}ntd|durd|j}n*t|ttfrt||jpg}ntd|durg}|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 tuples6'include_dirs' (if supplied) must be a list of stringsr) strip_dirrr+)rr'r(r3rlistrr1object_filenamesgen_preprocess_optionsranger2ospathsplitextrdirname)rZoutdirrZincdirssourcesdependsZextrarpp_optsbuildr-srcobjextrrr _setup_compile6s<   zCCompiler._setup_compilecCs0|dg}|rdg|dd<|r,||dd<|S)Nz-cz-grr)rrXdebugZbeforecc_argsrrr _get_cc_argsas   zCCompiler._get_cc_argscCs|dur|j}nt|ts"td|dur2|j}n"t|trL||jpFg}ntd|durd|j}n*t|ttfrt||jpg}ntd|||fS)NrJrKrL)rr'r(r3rrNrr1)rrrrrrr _fix_compile_argsjs"   zCCompiler._fix_compile_argscCs|j||d}|ifS)N)r)rO)rrVrrWrrrr _prep_compiles zCCompiler._prep_compilecCsHt|ttfstdt|}|dur.|j}nt|ts@td||fS)Nz,'objects' must be a list or tuple of stringsrJ)r'rNr1r3rr()rrrrrr _fix_object_argss zCCompiler._fix_object_argscCs|dur|j}n*t|ttfr2t||jp,g}ntd|durJ|j}n*t|ttfrlt||jpfg}ntd|dur|j}n*t|ttfrt||jpg}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_argss,zCCompiler._fix_lib_argscCs2|jr dS|jr t||dd}n t||}|SdS)NTnewer)Zmissing)rrr)rr output_filererrr _need_links  zCCompiler._need_linkc Cs|t|ts|g}d}t|j}|D]T}tj|\}}|j|}z |j |}||kr`|}|}Wq"t ytYq"0q"|Sr) r'rNr2language_orderrRrSrT language_mapgetindexr") rrVZlangrksourcebaser\ZextlangZextindexrrr detect_languages     zCCompiler.detect_languagecCsdSrr)rrlrfrr extra_preargsextra_postargsrrr preprocesss zCCompiler.preprocessc  Csv|||||||\}} }} } || ||} | D]@} z| | \}}WntyZYq0Yn0|| ||| || q0| Sr)r]r`KeyError_compile)rrVrrrr^rorprWrrXrYr_r[rZr\rrr compiles6    zCCompiler.compilecCsdSrr)rr[rZr\r_rprXrrr rsCszCCompiler._compilecCsdSrr)rroutput_libnamerr^ target_langrrr create_static_libIszCCompiler.create_static_libZ shared_objectZshared_library executablecCstdSrNotImplementedError)rZ target_descroutput_filenamerrrrexport_symbolsr^rorp build_temprvrrr linkis9zCCompiler.linkc Cs2|tj||j|dd||||||| | | | dS)Nshared)lib_type)r~r SHARED_LIBRARYlibrary_filename) rrrurrrrr|r^rorpr}rvrrr link_shared_libs  zCCompiler.link_shared_libc Cs(|tj||||||||| | | | dSr)r~r SHARED_OBJECT) rrr{rrrrr|r^rorpr}rvrrr link_shared_objects zCCompiler.link_shared_objectc Cs.|tj|||||||d||| d| dSr)r~r EXECUTABLEexecutable_filename) rrZoutput_prognamerrrrr^rorprvrrr link_executables   zCCompiler.link_executablecCstdSrryr9rrr library_dir_optionszCCompiler.library_dir_optioncCstdSrryr9rrr runtime_library_dir_optionsz$CCompiler.runtime_library_dir_optioncCstdSrry)rlibrrr library_optionszCCompiler.library_optionc Csddl}|durg}|dur g}|dur,g}|dur8g}|jd|dd\}}t|d} z2|D]} | d| q^| d|W| n | 0z|j|g|d} WntyYd S0z|j| d ||d Wnt t fyYd S0dS) NrrT)textwz#include "%s" z=int main (int argc, char **argv) { %s(); return 0; } r<Fza.out)rr) tempfileZmkstemprRfdopenwriteclosertZ CompileErrorrZ LinkErrorr3) rfuncnameZincludesrrrrfdZfnamefZinclrrrr has_functions<    zCCompiler.has_functioncCstdSrry)rr>rr^rrr find_library_file$szCCompiler.find_library_filecCs|dur d}g}|D]|}tj|\}}tj|d}|tj|d}||jvrftd||f|rvtj|}|tj |||j q|S)Nrr+z"unknown file type '%s' (from '%s')) rRrSrT splitdriveisabssrc_extensionsZUnknownFileErrorbasenamer6join obj_extension)rZsource_filenamesrMrZ obj_namesZsrc_namermr\rrr rOOs"    zCCompiler.object_filenamescCs$|rtj|}tj|||jSr)rRrSrrshared_lib_extensionrrrMrrrr shared_object_filename`s z CCompiler.shared_object_filenamecCs(|rtj|}tj|||jp"dS)Nr)rRrSrr exe_extensionrrrr rfs zCCompiler.executable_filenamestaticc Cs`|dvrtdt||d}t||d}tj|\}}|||f} |rPd}tj||| S)N)rrZdylibZ xcode_stubz?'lib_type' must be "static", "shared", "dylib", or "xcode_stub"Z _lib_formatZ_lib_extensionr)r"getattrrRrSsplitr) rr@rrMrZfmtr\r:rmfilenamerrr rls zCCompiler.library_filenamer+cCst|dSr)r r^)rmsglevelrrr announceszCCompiler.announcecCsddlm}|rt|dS)Nr)DEBUG)Zdistutils.debugrprint)rrrrrr debug_prints zCCompiler.debug_printcCstjd|dS)Nz warning: %s )sysstderrr)rrrrr warnszCCompiler.warncCst||||jdSr)rr)rfuncargsrrrrr rszCCompiler.executecCst||jddSN)r)rr)rcmdrrr rszCCompiler.spawncCst|||jdSr)rr)rrZZdstrrr rszCCompiler.move_filecCst|||jddSr)rr)rr,moderrr rszCCompiler.mkpath)rrr)N)N)NNNNN)NNNrNNN)NrN) NNNNNrNNNN) NNNNNrNNNN) NNNNNrNNNN)NNNNrNNN)NNNN)r)rr)rr)rr)rrr)r+)Nr+)r)Ar$ __module__ __qualname__Z compiler_typerrZstatic_lib_extensionrZstatic_lib_formatZshared_lib_formatrrirhr!r&rr/r4r7r8r;r?rArBrCrDrErFrHrIr]r`rarbrcrdrgrnrqrtrsrwrrrr~rrrrrrrrrOrrrrrrrrrrrrrr r s $   +  "   D  A    , +      r ))zcygwin.*unix)posixr)ntmsvccCsV|durtj}|durtj}tD]0\}}t||dusHt||dur |Sq dS)Nr)rRr,rplatform_default_compilersrematch)Zosnamerpatterncompilerrrr get_default_compilers   r)Z unixccompilerZ UnixCCompilerzstandard UNIX-style compiler)Z _msvccompilerZ MSVCCompilerzMicrosoft Visual C++)cygwinccompilerZCygwinCCompilerz'Cygwin port of GNU C Compiler for Win32)rZMingw32CCompilerz(Mingw32 port of GNU C Compiler for Win32)Z bcppcompilerZ BCPPCompilerzBorland C++ Compiler)rrcygwinZmingw32ZbcppcCsXddlm}g}tD] }|d|dt|dfq|||}|ddS)Nr) FancyGetoptz compiler=r0zList of available compilers:)Zdistutils.fancy_getoptrcompiler_classrr6sortZ print_help)rZ compilersrZpretty_printerrrr show_compilerss    rc Cs|durtj}z"|dur t|}t|\}}}Wn6tyfd|}|durZ|d|}t|Yn0z*d|}t|tj|} t | |} Wn>t yt d|Yn"tyt d||fYn0| 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,rrrrZDistutilsPlatformError __import__rmodulesvars ImportErrorZDistutilsModuleError) ZplatrrrrZ module_name class_nameZlong_descriptionrmoduleklassrrr new_compilers:       rcCsg}|D]}t|tr0dt|kr.dkss6        --