File: //usr/local/lib/python3.10/distutils/__pycache__/cygwinccompiler.cpython-310.pyc
o
�i�? � @ s� d Z ddlZddlZddlZddlmZmZmZ ddlZddl m
Z
ddlmZ ddl
mZmZmZmZ ddlmZ ddlmZ d d
� ZG dd� de
�ZG d
d� de�ZdZdZdZdd� Ze�d�Zdd� 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)�Popen�PIPE�check_output)�
UnixCCompiler)�
write_file)�DistutilsExecError�CCompilerError�CompileError�UnknownFileError)�LooseVersion)�find_executablec C s� t j�d�} | 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)�sys�version�find�
ValueError)Zmsc_posZmsc_ver� r �6/usr/local/lib/python3.10/distutils/cygwinccompiler.py� get_msvcr= s �r c @ sZ e Zd ZdZdZdZdZdZdZdZ dZ
dd
d�Zdd
� Z ddd�Z
ddd�ZdS )�CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows.
�cygwinz.o�.az.dllzlib%s%sz%s%sz.exer c C s� t �| |||� t� \}}| �d||f � |tur!| �d| � t� \| _| _| _ | �| j
d| j| j| j f � | jdkrCd| _nd| _| jdkrNd}nd }| jd
ddd
d| j|f d� | jdkrodg| _
| �d� d S t� | _
d S )Nz%Python's GCC status: %s (details: %s)z�Python'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.90�gcc�dllwrap�2.13�-shared�
-mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallzgcc -mcygwinz%s -mcygwin %s�Zcompiler�compiler_soZcompiler_cxxZ
linker_exeZ linker_so�2.91.57�msvcrtz,Consider upgrading to a newer version of gcc)r �__init__�check_config_hZdebug_print�CONFIG_H_OK�warn�get_versions�gcc_version�
ld_versionZdllwrap_version�
compiler_type�
linker_dll�set_executables�
dll_librariesr )�self�verbose�dry_run�force�statusZdetails�
shared_optionr r r r# b sN
����
��
��
�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. �obj�src�extZcc_args�extra_postargsZpp_opts�msgr r r �_compile� s �����zCygwinCCompiler._compileNc C sH t � |
pg �}
t � |pg �}t � |pg �}|�| j� |dur�|| jks)| jdkr�tj�|d �}tj�tj� |��\}}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.def�libr z
LIBRARY %sZEXPORTSz
writing %sr z--output-libz--defz-s)�copy�extendr- Z
EXECUTABLEr+ �os�path�dirname�splitext�basename�join�appendZexecuter r �link)r. Ztarget_descZobjectsZoutput_filename�
output_dirZ librariesZlibrary_dirsZruntime_library_dirsZexport_symbols�debugZ
extra_preargsr: Z
build_tempZtarget_langZtemp_dirZdll_nameZ
dll_extensionZdef_fileZlib_file�contentsZsymr r r rG � sB
���
�zCygwinCCompiler.link� c C s� |du rd}g }|D ]H}t j�t 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.NrK r4 r5 z"unknown file type '%s' (from '%s'))r5 r4 )
r@ rA rC �normcaseZsrc_extensionsr
rD rF rE �
obj_extension)r. Zsource_filenamesZ strip_dirrH Z obj_namesZsrc_name�baser9 r r r �object_filenames� s&