o ?Og:@s ddlZddlZddlZddlTddlmZddlmZddlm Z ddl m Z ddl m Z mZddlmZGd d d Zd Zdd d ZddddddZddZdddZddZddZdS)N)*)spawn) move_file)mkpath) newer_group) split_quotedexecute)logc@sbeZdZ dZdZdZdZdZdZdZ 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 drd0d1Z!d2d3Z"d4d5Z#d6d7Z$d8d9Z%  dsd:d;Z&   dtdd?Z(  dud@dAZ)dBZ*dCZ+dDZ,          dvdEdFZ-          dvdGdHZ.          dvdIdJZ/        dwdKdLZ0dMdNZ1dOdPZ2dQdRZ3  dxdSdTZ4dydUdVZ5dzdXdYZ6dzdZd[Z7dzd\d]Z8 ^ Wd{d_d`Z9d|dbdcZ:dddeZ;dfdgZdldmZ?d~dodpZ@dS) CCompilerNcc++objc).cz.ccz.cppz.cxxz.m)r r r rcCsb||_||_||_d|_g|_g|_g|_g|_g|_g|_ |j D] }| ||j |q#dSN) dry_runforceverbose output_dirmacros include_dirs libraries library_dirsruntime_library_dirsobjects executableskeysset_executable)selfrrrkeyr:/opt/alt/python310/lib64/python3.10/distutils/ccompiler.py__init__UszCCompiler.__init__cKs> |D]}||jvrtd||jjf||||qdS)Nz$unknown executable '%s' for class %s)r ValueError __class____name__r)rkwargsrrrr set_executablesys  zCCompiler.set_executablescCs.t|trt||t|dSt|||dSr) isinstancestrsetattrr)rrvaluerrr rs zCCompiler.set_executablecCs0d}|jD]}|d|kr|S|d7}qdS)Nr)r)rnameidefnrrr _find_macros    zCCompiler._find_macrocCsb |D]+}t|tr$t|dvr$t|dts|ddur$t|dts.td|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_definitionscCs0 ||}|dur|j|=|j||fdSrr/rappend)rr,r*r-rrr define_macros  zCCompiler.define_macrocCs2 ||}|dur|j|=|f}|j|dSrr5)rr,r-Zundefnrrr undefine_macros  zCCompiler.undefine_macrocC |j|dSr)rr6rdirrrr add_include_dirzCCompiler.add_include_dircC |dd|_dSrrrdirsrrr set_include_dirsszCCompiler.set_include_dirscCr9r)rr6)rlibnamerrr add_librarys zCCompiler.add_librarycCr>r)r)rZlibnamesrrr set_librarieszCCompiler.set_librariescCr9r)rr6r:rrr add_library_dirr=zCCompiler.add_library_dircCr>r)rr@rrr set_library_dirs szCCompiler.set_library_dirscCr9r)rr6r:rrr add_runtime_library_dirsz!CCompiler.add_runtime_library_dircCr>r)rr@rrr set_runtime_library_dirsrFz"CCompiler.set_runtime_library_dirscCr9r)rr6)robjectrrr add_link_object r=zCCompiler.add_link_objectcCr>r)r)rrrrr set_link_objects(rFzCCompiler.set_link_objectscCs |dur |j}n t|tstd|dur|j}nt|tr'||jp$g}ntd|dur3|j}nt|ttfrDt||jpAg}ntd|durNg}|j|d|d}t ||}i} t t |D]!} || } || } t j | d} |t j | | | f| | <qc||||| 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)rr\debugZbeforecc_argsrrr _get_cc_argsas  zCCompiler._get_cc_argscCs |dur |j}n t|tstd|dur|j}nt|tr'||jp$g}ntd|dur3|j}nt|ttfrDt||jpAg}ntd|||fS)NrNrOrP)rr'r(r3rrRrr1)rrrrrrr _fix_compile_argsjs$    zCCompiler._fix_compile_argscCs |j||d}|ifS)N)r)rS)rrZrr[rrrr _prep_compileszCCompiler._prep_compilecCsP t|ttfs tdt|}|dur|j}||fSt|ts$td||fS)Nz,'objects' must be a list or tuple of stringsrN)r'rRr1r3rr()rrrrrr _fix_object_argss zCCompiler._fix_object_argscCs |dur |j}nt|ttfrt||jpg}ntd|dur&|j}nt|ttfr7t||jp4g}ntd|durC|j}nt|ttfrTt||jpQg}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'rRr1r3rr)rrrrrrr _fix_lib_argss. zCCompiler._fix_lib_argscCs2 |jrdS|jrt||dd}|St||}|S)NTnewer)Zmissing)rrr)rr output_filerirrr _need_links zCCompiler._need_linkc Cs| t|ts |g}d}t|j}|D])}tj|\}}|j|}z|j |}||kr1|}|}Wqt y;Yqw|Sr) r'rRr2language_orderrVrWrX language_mapgetindexr") rrZZlangrosourcebaser`ZextlangZextindexrrr detect_languages$     zCCompiler.detect_languagecC dSrr)rrprjrr extra_preargsextra_postargsrrr preprocesss zCCompiler.preprocessc  Cst |||||||\}} }} } || ||} | D]} z| | \}}Wn ty,Yqw|| ||| || q| Sr)rardKeyError_compile)rrZrrrrbrtrur[rr\r]rcr_r^r`rrr compiles 3  zCCompiler.compilecCrsrr)rr_r^r`rcrur\rrr rxCzCCompiler._compilecCrsrr)rroutput_libnamerrb target_langrrr create_static_libIszCCompiler.create_static_libZ shared_objectZshared_library executablecC trNotImplementedError)rZ target_descroutput_filenamerrrrexport_symbolsrbrtru build_tempr|rrr linkis+zCCompiler.linkc Cs2|tj||j|dd||||||| | | | dS)Nshared)lib_type)rr SHARED_LIBRARYlibrary_filename) rrr{rrrrrrbrtrurr|rrr link_shared_libs zCCompiler.link_shared_libc Cs(|tj||||||||| | | | dSr)rr SHARED_OBJECT) rrrrrrrrrbrtrurr|rrr link_shared_objects zCCompiler.link_shared_objectc Cs.|tj|||||||d||| d| dSr)rr EXECUTABLEexecutable_filename) rrZoutput_prognamerrrrrbrtrur|rrr link_executables  zCCompiler.link_executablecCrrrr:rrr library_dir_optionrzzCCompiler.library_dir_optioncCrrrr:rrr runtime_library_dir_optionrzz$CCompiler.runtime_library_dir_optioncCrrr)rlibrrr library_optionrzzCCompiler.library_optionc Cs ddl}|dur g}|durg}|durg}|durg}|jd|dd\}}t|d} z|D] } | d| q0| d|W| n| wz |j|g|d} Wn ty`Yd Swz |j| d ||d WdSt t fyyYd Sw) NrrT)textwz#include "%s" z=int main (int argc, char **argv) { %s(); return 0; } r?Fza.out)rr) tempfileZmkstemprVfdopenwritecloseryZ CompileErrorrZ LinkErrorr3) rfuncnameZincludesrrrrfdZfnamefZinclrrrr has_functionsB  zCCompiler.has_functioncCrrr)rrArrbrrr find_library_file$szCCompiler.find_library_filecCs|durd}g}|D]>}tj|\}}tj|d}|tj|d}||jvr3td||f|r;tj|}|tj |||j q |S)Nrr+z"unknown file type '%s' (from '%s')) rVrWrX splitdriveisabssrc_extensionsZUnknownFileErrorbasenamer6join obj_extension)rZsource_filenamesrQrZ obj_namesZsrc_namerqr`rrr rSOs"    zCCompiler.object_filenamescCs$|rtj|}tj|||jSr)rVrWrrshared_lib_extensionrrrQrrrr shared_object_filename`s z CCompiler.shared_object_filenamecCs(|rtj|}tj|||jpdS)Nr)rVrWrr exe_extensionrrrr rfs zCCompiler.executable_filenamestaticc Cs`|dvrtdt||d}t||d}tj|\}}|||f} |r(d}tj||| S)N)rrZdylibZ xcode_stubz?'lib_type' must be "static", "shared", "dylib", or "xcode_stub"Z _lib_formatZ_lib_extensionr)r"getattrrVrWsplitr) rrCrrQrZfmtr`r;rqfilenamerrr rls zCCompiler.library_filenamer+cCst|dSr)r rb)rmsglevelrrr announceszCCompiler.announcecCs ddlm}|rt|dSdS)Nr)DEBUG)Zdistutils.debugrprint)rrrrrr debug_prints  zCCompiler.debug_printcCstjd|dS)Nz warning: %s )sysstderrr)rrrrr warnzCCompiler.warncCst||||jdSr)rr)rfuncargsrrrrr rrzCCompiler.executecCst||jddSN)r)rr)rcmdrrr rszCCompiler.spawncCst|||jdSr)rr)rr^Zdstrrr rszCCompiler.move_filecCst|||jddSr)rr)rr,moderrr rrzCCompiler.mkpath)rrrr)NNNNN)NNNrNNN)NrN) NNNNNrNNNN)NNNNrNNN)NNNN)r)rr)rrr)r+)Nr+)r)Ar$ __module__ __qualname__Z compiler_typerrZstatic_lib_extensionrZstatic_lib_formatZshared_lib_formatrrmrlr!r&rr/r4r7r8r<rBrDrErGrHrIrJrLrMrardrerfrgrhrkrrrvryrxr}rrrrrrrrrrrrrSrrrrrrrrrrrrrr r s $   + "    D  A    , +    r ))zcygwin.*unix)posixr)ntmsvccCsX |durtj}|durtj}tD]\}}t||dus%t||dur)|SqdS)Nr)rVr,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)rrcygwinZmingw32ZbcppcCsZ ddlm}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|durt|}t|\}}}Wnty2d|}|dur.|d|}t|wzd|}t|tj|} t | |} Wnt yUt d|tyct d||fw| 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') rVr,rrrwZDistutilsPlatformError __import__rmodulesvars ImportErrorZDistutilsModuleError) ZplatrrrrZ module_name class_nameZlong_descriptionrmoduleklassrrr new_compilers@       rcCs g}|D]G}t|trdt|krdksntd|t|dkr/|d|dqt|dkrL|ddurE|d|dq|d|q|D] }|d|qO|S) Nr+r0zPbad 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'r1r2r3r6)rrr\Zmacror;rrr rT s&$   rTc Cs g}|D] }|||q|D]}||}t|tr#||}q||q|D]+}tj|\}} |rN||g| } | rF|| q+| d|q+|| |q+|S)Nz6no library file corresponding to '%s' found (skipping)) r6rrr'rRrVrWrrrr) rrrrZlib_optsr;optrZlib_dirZlib_nameZlib_filerrr gen_lib_options8s(     r)NN)NNrrr)rrVrZdistutils.errorsZdistutils.spawnrZdistutils.file_utilrZdistutils.dir_utilrZdistutils.dep_utilrZdistutils.utilrrZ distutilsr r rrrrrrTrrrrr s:       - -