o Xai*B @ s d Z ddlZddlZddlZddlmZmZmZ ddlZddl m Z ddlmZ ddl mZmZmZmZ ddlmZ ddlmZ d d ZG dd de ZG d d deZdZdZdZdd ZedZdd Zdd Z dd Z!dS )a distutils.cygwinccompiler Provides the CygwinCCompiler class, a subclass of UnixCCompiler that handles the Cygwin port of the GNU C compiler to Windows. It also contains the Mingw32CCompiler class which handles the mingw32 port of GCC (same as cygwin in no-cygwin mode). N)PopenPIPEcheck_output) UnixCCompiler) write_file)DistutilsExecErrorCCompilerErrorCompileErrorUnknownFileError)LooseVersion)find_executablec C s t jd} | dkr>t j| d | d }|dkrdgS |dkr#dgS |d kr*d gS |dkr1dgS |d kr8dgS td| dS )zaInclude the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. zMSC v. Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100zUnknown MS Compiler version %s N)sysversionfind ValueError)Zmsc_posZmsc_ver r /builddir/build/BUILDROOT/alt-python310-setuptools-58.3.0-4.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/setuptools/_distutils/cygwinccompiler.py get_msvcr? s r c @ sZ e Zd ZdZdZdZdZdZdZdZ dZ dd dZdd Z dddZ dddZdS )CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows. cygwinz.o.az.dllzlib%s%sz%s%sz.exer c C sF t | ||| t \}}| d||f |tur!| d| tjdd| _ tjdd| _ d| j v rgt \| _| _ | _| | jd| j| j | jf | j dkrY| j | _nd | _| j d krdd}n d}n| j | _d}| jd | j d| j d | j d| j d| j|f d d| j v r| jdkrdg| _| d d S t | _d S )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.CCgccCXXzg++z: gcc %s, ld %s, dllwrap %s z2.10.90dllwrap2.13-shared -mdll -staticz%s -mcygwin -O -Wallz%s -mcygwin -mdll -O -Wallz%s -mcygwinz%s -mcygwin %scompilercompiler_socompiler_cxx linker_exe linker_so2.91.57msvcrtz,Consider upgrading to a newer version of gcc)r __init__check_config_hdebug_printCONFIG_H_OKwarnosenvirongetcccxxget_versionsgcc_version ld_versionZdllwrap_version compiler_type linker_dllset_executables dll_librariesr )selfverbosedry_runforcestatusdetails shared_optionr r r r) d sX zCygwinCCompiler.__init__c C s |dks|dkr&z | dd|d|g W dS ty% } zt|d}~ww z| | j| |d|g | W dS tyH } zt|d}~ww )z:Compiles the source by spawning GCC and windres if needed..rc.resZwindresz-iz-oN)spawnr r r# )r: objsrcextZcc_argsextra_postargsZpp_optsmsgr r r _compile s zCygwinCCompiler._compileNc C sH t | pg } t |pg }t |pg }|| j |dur|| jks)| jdkrtj|d }tjtj |\}}tj ||d }tj |d| d }dtj | dg}|D ]}|| q]| t ||fd | | jd kr| d|g | d|g n|| | s| d t| |||||||d| | ||| dS )zLink the objects.Nr r z.deflibr z LIBRARY %sZEXPORTSz writing %sr z--output-libz--defz-s)copyextendr9 Z EXECUTABLEr7 r. pathdirnamesplitextbasenamejoinappendexecuter r link)r: Ztarget_descZobjectsZoutput_filename output_dir librarieslibrary_dirsruntime_library_dirsexport_symbolsdebugZ extra_preargsrG Z build_tempZtarget_langtemp_dirZdll_nameZ dll_extensionZdef_fileZlib_filecontentssymr r r rT sB zCygwinCCompiler.link c C s |du rd}g }|D ]H}t jt j|\}}|| jddg vr)td||f |r1t j|}|dv rE|t j||| | j q |t j||| j q |S )z#Adds supports for rc and res files.Nr^ rA rB z"unknown file type '%s' (from '%s'))rB rA ) r. rM rO normcaseZsrc_extensionsr rP rR rQ obj_extension)r: Zsource_filenamesZ strip_dirrU Z obj_namessrc_namebaserF r r r object_filenames s&