o ?Og?@s ddlZddlZddlZddlmZmZmZddlZddlm Z ddl m Z ddl m Z mZmZmZddlmZddlmZdd ZGd d d e ZGd d d eZdZdZdZddZedZddZddZddZ dS)N)PopenPIPE check_output) UnixCCompiler) write_file)DistutilsExecErrorCCompilerError CompileErrorUnknownFileError) LooseVersion)find_executablecCs tjd}|dkr?tj|d|d}|dkrdgS|dkr$dgS|d kr+d gS|d kr2d gS|d kr9dgStd|dS)NzMSC v. Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100zUnknown MS Compiler version %s )sysversionfind ValueError)Zmsc_posZmsc_verr@/opt/alt/python310/lib64/python3.10/distutils/cygwinccompiler.py get_msvcr=s   rc@sXeZdZ dZdZdZdZdZdZdZ dd d Z d d Z dddZ dddZ d S)CygwinCCompilercygwinz.o.az.dllzlib%s%sz%s%sz.exercCst||||t\}}|d||f|tur!|d|t\|_|_|_ ||j d|j|j|j f|jdkrCd|_ nd|_ |jdkrNd}nd }|j d d d d d|j |fd|jdkrodg|_ |ddSt|_ dS)Nz%Python's GCC status: %s (details: %s)zPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.z: gcc %s, ld %s, dllwrap %s z2.10.90gccdllwrap2.13-shared -mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallz gcc -mcygwinz%s -mcygwin %sZcompiler compiler_soZ compiler_cxxZ linker_exeZ linker_so2.91.57Zmsvcrtz,Consider upgrading to a newer version of gcc)r__init__check_config_hZ debug_print CONFIG_H_OKwarn get_versions gcc_version ld_versionZdllwrap_version compiler_type linker_dllset_executables dll_librariesr)selfverbosedry_runforceZstatusZdetails shared_optionrrrr"bsN      zCygwinCCompiler.__init__c Cs |dks |dkr'z |dd|d|gWdSty&}zt|d}~wwz||j||d|g|WdStyI}zt|d}~ww)N.rc.resZwindresz-iz-o)Zspawnrr r )r-objsrcextZcc_argsextra_postargsZpp_optsmsgrrr_compiles  zCygwinCCompiler._compileNcCsJ t| pg} t|p g}t|pg}||j|dur||jks*|jdkrtj|d}tjtj |\}}tj ||d}tj |d|d}dtj |dg}|D]}| |q^| t ||fd||jd kr| d |g| d |gn| || s| d t||||||||d| | | | | dS) Nrrz.deflibrz LIBRARY %sZEXPORTSz writing %srz --output-libz--defz-s)copyextendr,Z EXECUTABLEr*ospathdirnamesplitextbasenamejoinappendZexecuterrlink)r-Z target_descZobjectsZoutput_filename output_dirZ librariesZ library_dirsZruntime_library_dirsZexport_symbolsdebugZ extra_preargsr7Z build_tempZ target_langZtemp_dirZdll_nameZ dll_extensionZdef_fileZlib_filecontentsZsymrrrrDsD         zCygwinCCompiler.linkcCs |durd}g}|D]H}tjtj|\}}||jddgvr*td||f|r2tj|}|dvrF|tj||||j q |tj|||j q |S)NrHr2r3z"unknown file type '%s' (from '%s'))r3r2) r=r>r@normcaseZsrc_extensionsr rArCrB obj_extension)r-Zsource_filenamesZ strip_dirrEZ obj_namesZsrc_namebaser6rrrobject_filenamess(    z CygwinCCompiler.object_filenamesrrr) NNNNNrNNNN)rrH)__name__ __module__ __qualname__r)rJZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr"r9rDrLrrrrrWs" ; Nrc@seZdZ dZdddZdS)Mingw32CCompilerZmingw32rc Csxt|||||jdkrd}nd}|jdkrd}nd}tr#td|jdd d d d |j||fd g|_t |_dS)Nrrrr!z--entry _DllMain@12rHz1Cygwin gcc cannot be used with --compiler=mingw32z gcc -O -Wallzgcc -mdll -O -Wallz g++ -O -Wallrz%s %s %sr) rr"r(r' is_cygwingccrr+r*r,r)r-r.r/r0r1Z entry_pointrrrr"s.   zMingw32CCompiler.__init__NrM)rNrOrPr)r"rrrrrQsrQokznot okZ uncertainc Cs ddlm}dtjvrtdfS|}z(t|}zd|vr,td|fW|WSt d|fW|WS|wt yW}zt d||j ffWYd}~Sd}~ww) Nr) sysconfigZGCCzsys.version mentions 'GCC'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '%s': %s) Z distutilsrTrrr$Zget_config_h_filenameopenreadcloseCONFIG_H_NOTOKOSErrorCONFIG_H_UNCERTAINstrerror)rTfnZconfig_hexcrrrr#Fs&       r#s(\d+\.\d+(\.\d+)*)cCsv |d}t|durdSt|dtdj}z |}W|n|wt|}|dur2dSt | d S)NrT)shellstdout) splitr rrr_rVrW RE_VERSIONsearchr groupdecode)cmd executableout out_stringresultrrr_find_exe_versionss    rkcCs gd}tdd|DS)N)zgcc -dumpversionzld -vzdllwrap --versioncSsg|]}t|qSr)rk).0rfrrr sz get_versions..)tuple)Zcommandsrrrr&sr&cCs tddg}|dS)Nrz -dumpmachinescygwin)rstripendswith)rirrrrRs rR)!r=rr; subprocessrrrreZdistutils.unixccompilerrZdistutils.file_utilrZdistutils.errorsrrr r Zdistutils.versionr Zdistutils.spawnr rrrQr$rXrZr#compilerbrkr&rRrrrrs./    ;1 +