�
���c�. � �@ � d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m
Z
ddlmZ ddl
mZmZmZmZ ddlmZmZ dd lmZ ej d
gdgdgd
gdgdgdgddgej d� � � Zd� ZdZ G d� de
� � Z G d� de� � ZdZdZdZ d� Z!d� Z"dZ#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)�check_output� )�
UnixCCompiler)�
write_file)�DistutilsExecError�DistutilsPlatformError�CCompilerError�CompileError)�LooseVersion�suppress_known_deprecation)�RangeMap�msvcr70�msvcr71�msvcr80�msvcr90�msvcr100�msvcr110�msvcr120�ucrt�vcruntime140) i i ix i� i@ i� i il i� c � � t j dt j � � } t | � d� � � � }n# t $ r Y dS w xY w t | S # t $ r t d|z � � �w xY w)zaInclude the appropriate MSVC runtime library if Python was built
with MSVC 7.0 or later.
zMSC v\.(\d{4})r NzUnknown MS Compiler version %s )
�re�search�sys�version�int�group�AttributeError�
_msvcr_lookup�KeyError�
ValueError)�match�msc_vers �G/usr/lib/python3/dist-packages/setuptools/_distutils/cygwinccompiler.py� get_msvcrr% 4 s� � �
�I�'���5�5�E���e�k�k�!�n�n�%�%����� � � ��������F��W�%�%��� F� F� F��:�W�D�E�E�E�F���s �"A �
A�A�A# �#B zxUnable to set runtime library search path on Windows, usually indicated by `runtime_library_dirs` parameter to Extensionc � � � e Zd ZdZdZdZdZdZdZdZ dZ
dZd Zd� fd� Z
ed� � � Zd
� Z dd�Zd� Z� fd�Ze� fd�� � Z� xZS )�CygwinCCompilerz9Handles the Cygwin port of the GNU C compiler to Windows.�cygwinz.oz.az.dll.az.dllzlib%s%szcyg%s%sz.exer c
� �� t � � � |||� � t � � \ }}| � d� ||� � � � |t
ur| � d|z � � t j � dd� � | _
t j � dd� � | _ | j
| _ d}| �
d| j
z d | j
z d| j z d
| j
z d� | j |� � �� � t � � | _ d S )
Nz%Python's GCC status: {} (details: {})z�Python's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.�CC�gcc�CXXzg++�-sharedz%s -mcygwin -O -Wallz%s -mcygwin -mdll -O -Wallz%s -mcygwinz{} -mcygwin {}��compiler�compiler_so�compiler_cxx�
linker_exe� linker_so)�super�__init__�check_config_h�debug_print�format�CONFIG_H_OK�warn�os�environ�get�cc�cxx�
linker_dll�set_executablesr% �
dll_libraries)�self�verbose�dry_run�force�status�details�
shared_option� __class__s �r$ r5 zCygwinCCompiler.__init__V s7 �� �
������'�5�1�1�1�(�*�*�������3�:�:�6�7�K�K�
�
�
� ��$�$��I�I�O�QX�Y�
�
�
� �*�.�.��u�-�-����:�>�>�%��/�/����'���!�
����+�d�g�5�4�t�w�>�/�$�(�:�$�t�w�.�'�.�.�t��
�N�N� �
�
�
� '�[�[����� c � � t j dt d�� � t � � 5 t d� � cd d d � � S # 1 swxY w Y d S )Nz�gcc_version attribute of CygwinCCompiler is deprecated. Instead of returning actual gcc version a fixed value 11.2.0 is returned.� )�
stacklevelz11.2.0)�warningsr: �DeprecationWarningr r )rC s r$ �gcc_versionzCygwinCCompiler.gcc_versionw s� � � �
�
X���
�
�
�
� (�
)�
)� *� *���)�)� *� *� *� *� *� *� *� *� *� *� *� *���� *� *� *� *� *� *s �A�A�Ac �* � |dk s|dk r> | � dd|d|g� � dS # t $ r}t |� � �d}~ww xY w | � | j |z |d|gz |z � � dS # t $ r}t |� � �d}~ww xY w)z:Compiles the source by spawning GCC and windres if needed.�.rc�.res�windresz-iz-oN)�spawnr r
r0 )rC �obj�src�ext�cc_args�extra_postargs�pp_opts�msgs r$ �_compilezCygwinCCompiler._compile� s� � ��%�<�<�3�&�=�=�
(��
�
�I�t�S�$��<�=�=�=�=�=��%�
(�
(�
(�"�3�'�'�'�����
(����
(��
�
��$�w�.�#�t�S�1A�A�N�R�� � � � �� &�
(�
(�
(�"�3�'�'�'�����
(���s, �* �
A�A�A�&A4 �4
B�>B
�
BNc � � t j |
pg � � }
t j |pg � � }t j |pg � � }|r| � t � � |� | j � � |��|| j k s| j dk r�t j � |d � � }t j �
t j � |� � � � \ }}t j � ||dz � � }dt j � |� � z dg}|D ]}|�
|� � �| � t ||fd|z � � |�
|� � | s|
�
d� � t! j | |||||||d| |
|||
� � dS ) zLink the objects.Nr+ r z.defz
LIBRARY %s�EXPORTSz
writing %sz-s)�copyr: �_runtime_library_dirs_msg�extendrB �
EXECUTABLEr@ r; �path�dirname�splitext�basename�join�append�executer r �link)rC �target_desc�objects�output_filename�
output_dir� libraries�library_dirs�runtime_library_dirs�export_symbols�debug�
extra_preargsr[ �
build_temp�target_lang�temp_dir�dll_name�
dll_extension�def_file�contents�syms r$ rl zCygwinCCompiler.link� s� � �$ � �-�"5�2�6�6�
��I�i�o�2�.�.� ��)�G�M�r�*�*��� 1��I�I�/�0�0�0� ����+�,�,�,�
�&��4�?�*�*�d�o��.F�.F� �w���w�q�z�2�2�H�(*��(8�(8��� � ��1�1�)� )�%�X�}�
�w�|�|�H�h��.?�@�@�H� %�r�w�'7�'7��'H�'H�H�)�T�H�%�
%�
%������$�$�$�$��L�L��h��%9�<�(�;R�S�S�S�
�N�N�8�$�$�$� � '�� � ��&�&�&���������� �������
�
�
�
�
rK c �: � | � t � � g S �N)r: rb �rC �dirs r$ �runtime_library_dir_optionz*CygwinCCompiler.runtime_library_dir_option� s � �
� � �+�,�,�,�� rK c � �� t j � |� � }t � � � |||� � S r� )r; re �normcaser4 �_make_out_path)rC rp � strip_dir�src_name�
norm_src_namerJ s �r$ r� zCygwinCCompiler._make_out_path� s4 �� ���(�(��2�2�
��w�w�%�%�j�)�]�K�K�KrK c �L �� � i t � � j �� fd�dD � � �S )z3
Add support for rc and res files.
c �& |