� ,�Re�<���dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z ddlmZmZmZmZddlmZdd lmZd �Zd �Zd �ZGd �de ��ZdS)a9distutils.unixccompiler Contains the UnixCCompiler class, a subclass of CCompiler that handles the "typical" Unix-style command-line C compiler: * macros defined with -Dname[=value] * macros undefined with -Uname * include search directories specified with -Idir * libraries specified with -lllib * library search directories specified with -Ldir * compile handled by 'cc' (or similar) executable with -c option: compiles .c to .o * link static library handled by 'ar' command (possibly with 'ranlib') * link shared library handled by 'cc -shared' �N�)� sysconfig)�newer)� CCompiler�gen_preprocess_options�gen_lib_options)�DistutilsExecError� CompileError�LibError� LinkError)�log)�compiler_fixupc��d}tj�|d��dkrd}d||vr|dz }d||v�|d|�||d�fS)z� For macOS, split command into 'env' portion (if any) and the rest of the linker command. >>> _split_env(['a', 'b', 'c']) ([], ['a', 'b', 'c']) >>> _split_env(['/usr/bin/env', 'A=3', 'gcc']) (['/usr/bin/env', 'A=3'], ['gcc']) r�envr�=N��os�path�basename��cmd�pivots ��/builddir/build/BUILDROOT/alt-python311-setuptools-65.6.3-2.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/setuptools/_distutils/unixccompiler.py� _split_envr-sq�� �E� �w����A����5�(�(����S��Z��� �Q�J�E��S��Z��� �v��v�;��E�F�F� � #�#�c�|�tj�|d��dk}|d|�||d�fS)a AIX platforms prefix the compiler with the ld_so_aix script, so split that from the linker command. >>> _split_aix(['a', 'b', 'c']) ([], ['a', 'b', 'c']) >>> _split_aix(['/bin/foo/ld_so_aix', 'gcc']) (['/bin/foo/ld_so_aix'], ['gcc']) r� ld_so_aixNrrs r� _split_aixr?s=�� �G� � �S��V� $� $� � 3�E� �v��v�;��E�F�F� � #�#rc�X�t|��}|d|�|kr|nd}||d�S)a The linker command usually begins with the compiler command (possibly multiple elements), followed by zero or more params for shared library building. If the LDSHARED env variable overrides the linker command, however, the commands may not match. Return the best guess of the linker parameters by stripping the linker command. If the compiler command does not match the linker command, assume the linker command is just the first element. >>> _linker_params('gcc foo bar'.split(), ['gcc']) ['foo', 'bar'] >>> _linker_params('gcc foo bar'.split(), ['other']) ['foo', 'bar'] >>> _linker_params('ccache gcc foo bar'.split(), 'ccache gcc'.split()) ['foo', 'bar'] >>> _linker_params(['gcc'], ['gcc']) [] Nr)�len)� linker_cmd� compiler_cmd�c_lenrs r�_linker_paramsr$Ms<��. � � � �E�����'�<�7�7�E�E�Q�E� �e�f�f� �rc �$�eZdZdZddgdgdgddgdgddgdd�Zejdd�d krd ged <gd �Zd Zd Z dZ dZ dZ dxZ xZZeZejdkrdZ dd�Zd�Z d d�Z d!d�Zd�Zd�Zd�Zd�Zed���Zd"d�ZdS)#� UnixCCompiler�unixN�ccz-shared�arz-cr)� preprocessor�compiler� compiler_so� compiler_cxx� linker_so� linker_exe�archiver�ranlib��darwinr1)z.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%s�cygwinz.exec�$�|�d||��}|\}}}t||��} |j| z} |r| �d|g��|r|| dd�<|r| �|��| �|��|jp|dupt ||��} | sdS|r2|�tj � |���� |� | ��dS#t$r} t| ���d} ~ wwxYw)N�-or)�_fix_compile_argsrr*�extend�append�forcer�mkpathrr�dirname�spawnr r ) �self�source� output_file�macros� include_dirs� extra_preargs�extra_postargs� fixed_args�ignore�pp_opts�pp_args� preprocess�msgs rrIzUnixCCompiler.preprocess�sD���+�+�D�&�,�G�G� �'1�$��� �(���>�>���#�g�-�� � 0� �N�N�D�+�.� /� /� /� � (�'�G�B�Q�B�K� � +� �N�N�>� *� *� *����v���� �Z�T�;�$�#6�T�%�� �:T�:T� �� � �F� � 6� �K�K����� �4�4� 5� 5� 5� $� �J�J�w� � � � � ��!� $� $� $��s�#�#� #����� $���s�C1�1 D�;D � Dc��t|j||z��} |�||z|d|gz|z��dS#t$r}t |���d}~wwxYw)Nr6)rr,r=r r ) r>�obj�src�ext�cc_argsrDrGr,rJs r�_compilezUnixCCompiler._compile�sy��$�T�%5�w��7O�P�P� � $� �J�J�{�W�,��T�3�/?�?�.�P� Q� Q� Q� Q� Q��!� $� $� $��s�#�#� #����� $���s�!=� A�A�Arc��|�||��\}}|�||���}|�||��r�|�tj�|����|�|j|gz|z|j z��|j rB |�|j |gz��dS#t$r}t|���d}~wwxYwdStjd|��dS)N)� output_dir�skipping %s (up-to-date))�_fix_object_args�library_filename� _need_linkr;rrr<r=r0�objectsr1r r r �debug)r>rW�output_libnamerRrX� target_lang�output_filenamerJs r�create_static_libzUnixCCompiler.create_static_lib�s��#�3�3�G�Z�H�H�����/�/��:�/�V�V�� �?�?�7�O� 4� 4� C� �K�K������8�8� 9� 9� 9� �J�J�t�}��'8�8�7�B�T�\�Q� R� R� R��{� (�(��J�J�t�{�o�->�>�?�?�?�?�?��)�(�(�(�"�3�-�-�'�����(���� (� (� �I�0�/� B� B� B� B� Bs�*C � C(�C#�#C(c�P�|�||��\}}|�|||��}|\}}}t||||��}t|tt d��f��st d���|� tj� ||��}|� ||���r\||j z|zd|gz}| rdg|dd�<| r| |dd�<| r|� | ��|� tj�|���� |tjk}|r|jn|jdd�}| dkrt|jrmt)|��\}}t+|��\}}t)|j��\}}t)|j��\}}t-||��}||z|z|z}t/||��}|�||z��dS#t2$r}t5|���d}~wwxYwt7jd|��dS)Nz%'output_dir' must be a string or Noner6z-grzc++rS)rT� _fix_lib_argsr� isinstance�str�type� TypeErrorrr�joinrVrWr8r;r<r� EXECUTABLEr/r.r-rrr$rr=r r r rX)r>� target_descrWr[rR� libraries� library_dirs�runtime_library_dirs�export_symbolsrXrCrD� build_temprZrE�lib_opts�ld_args� building_exe�linkerr� linker_ne�aix� linker_na�_�compiler_cxx_ne� linker_exe_ne�paramsrJs r�linkzUnixCCompiler.link�sX�� #�3�3�G�Z�H�H�����'�'� �<�AU�V�V� �8B�5� �<�!5�"�4��7K�Y�W�W���*�s�D��J�J�&7�8�8� E��C�D�D� D� � !� �g�l�l�:��G�G�O� �?�?�7�O� 4� 4� C��� �,�x�7�4��:Q�Q�G�� %�#�f����� �� ,�+����� �� /����~�.�.�.� �K�K������8�8� 9� 9� 9� %� +�i�.B�B� �-9�M�$�/�/�t�~�q�q�q�Q���%�'�'�D�,=�'�%/��%7�%7�N�C��%/� �%:�%:�N�C��)3�D�4E�)F�)F�&�A��'1�$�/�'B�'B�$�A�}�+�I�}�E�E�F� �3�Y��8�6�A�F�'���8�8��� � �6�G�+�,�,�,�,�,��%� %� %� %���n�n�$����� %���� �I�0�/� B� B� B� B� Bs�$C G0�0 H�:H � Hc� �d|zS)N�-L�)r>�dirs r�library_dir_optionz UnixCCompiler.library_dir_option� ���c�z�rc��tjd��}tj�t j|��d��}d|vpd|vS)N�CCr�gcczg++)r�get_config_varrrr�shlex�split)r>�cc_varr+s r�_is_gcczUnixCCompiler._is_gccsK���)�$�/�/���7�#�#�E�K��$7�$7��$:�;�;���� �5�E�X�$5�5rc�x�tjdd�dkr/ddlm}m}|��}|r||��ddgkrd|zSd|zStjdd �d krd |zStjdd�d kr|���rd ndd|zgSt jd��dkrd|zSd|zS)Nr2r3r)�get_macosx_target_ver� split_version� �z -Wl,-rpath,rx��freebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+s�GNULD�yesz-Wl,--enable-new-dtags,-Rz-Wl,-R)�sys�platform�distutils.utilr�r�r�rr�)r>rzr�r��macosx_target_vers r�runtime_library_dir_optionz(UnixCCompiler.runtime_library_dir_options�� �<���� �x� '� '� K� K� K� K� K� K� K� K� 5� 5� 7� 7� � � "�]�]�3D�%E�%E�"�a��%P�%P�$�s�*�*��c�z�!� �\�"�1�"� �� *� *� �3�&� &� �\�"�1�"� �� (� (� �L�L�N�N�4�����s� �� � � #�G� ,� ,�� 5� 5�/��4� 4��c�>� !rc� �d|zS)Nz-lry)r>�libs r�library_optionzUnixCCompiler.library_optionEr|rc�v�tjd��}tjd|��}tjdkoA|o?|�d��p*|�d��o|�d�� }|r;tj� |� d��|dd���n|S) a� macOS users can specify an alternate SDK using'-isysroot'. Calculate the SDK root if it is specified. Note that, as of Xcode 7, Apple SDKs may contain textual stub libraries with .tbd extensions rather than the normal .dylib shared libraries installed in /. The Apple compiler tool chain handles this transparently but it can cause problems for programs that are being built with an SDK and searching for specific libraries. Callers of find_library_file need to keep in mind that the base filename of the returned SDK library file might have a different extension from that of the library file installed on the running system, for example: /Applications/Xcode.app/Contents/Developer/Platforms/ MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ usr/lib/libedit.tbd vs /usr/lib/libedit.dylib �CFLAGSz-isysroot\s*(\S+)r3z/System/z/usr/z /usr/local/rN) rr��re�searchr�r�� startswithrrrc�group)rz�cflags�match� apply_roots r� _library_rootzUnixCCompiler._library_rootHs���*�)�(�3�3��� �.��7�7�� �L�H� $� �� ����z�*�*�S��N�N�7�+�+�Q�C�N�N�=�4Q�4Q�0Q� �9C�K�r�w�|�|�E�K�K��N�N�C����G�4�4�4��Krc������fd�d���D��}t�j|��}d�tj||��D��}t t jj|��}t|d��S)a/ Second-guess the linker with not much hard data to go on: GCC seems to prefer the shared library, so assume that *all* Unix C compilers do, ignoring even GCC's "-static" option. >>> compiler = UnixCCompiler() >>> compiler._library_root = lambda dir: dir >>> monkeypatch = getfixture('monkeypatch') >>> monkeypatch.setattr(os.path, 'exists', lambda d: 'existing' in d) >>> dirs = ('/foo/bar/missing', '/foo/bar/existing') >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/') '/foo/bar/existing/libabc.dylib' >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/') '/foo/bar/existing/libabc.dylib' >>> monkeypatch.setattr(os.path, 'exists', ... lambda d: 'existing' in d and '.a' in d) >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/') '/foo/bar/existing/libabc.a' >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/') '/foo/bar/existing/libabc.a' c3�F�K�|]}���|���V��dS))�lib_typeN)rU)�.0rar�r>s ��r� z2UnixCCompiler.find_library_file..�sJ����� � �� � !� !�#�� !� 5� 5� � � � � � rzdylib xcode_stub shared staticc3�\K�|]'\}}tj�||��V��(dS)N)rrrc)r��root�lib_names rr�z2UnixCCompiler.find_library_file..�sJ���� � ���h� �G�L�L��x� (� (� � � � � � rN) r��mapr�� itertools�product�filterrr�exists�next)r>�dirsr�rX� lib_names�roots�searched�founds` ` r�find_library_filezUnixCCompiler.find_library_fileks�����. � � � � �8�>�>�@�@� � � � � �D�&��-�-�� � �"+�"3�E�9�"E�"E� � � �� �r�w�~�x�0�0���E�4� � � r)NNNNN)NrN) NNNNNrNNNN)r)�__name__� __module__� __qualname__� compiler_type� executablesr�r��src_extensions� obj_extension�static_lib_extension�shared_lib_extension�dylib_lib_extension�xcode_stub_lib_extension�static_lib_format�shared_lib_format�dylib_lib_format�xcode_stub_lib_format� exe_extensionrIrPr\rvr{r�r�r�� staticmethodr�r�ryrrr&r&is��������M���F��v����I�&��f��5�M�� � �K� �|�B�Q�B��8�#�#�!)� � �H��?�>�>�N��M��� ��"��%��?H�H��H�)�,<�,�� �|�x���� � �����#$�#$�#$�#$�J$�$�$�NR�C�C�C�C�:���!�������9C�9C�9C�9C�~���6�6�6� &"�&"�&"�P���� L� L��\� L�D&!�&!�&!�&!�&!�&!rr&)�__doc__rr�r�r�r��r�dep_utilr� ccompilerrrr�errorsr r r r �_logr � _macos_compatrrrr$r&ryrr�r�s6�� � � � � � � � � � � � � � � � � � �����������������I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�������)�)�)�)�)�)�$$�$�$�$ $� $� $����8h!�h!�h!�h!�h!�I�h!�h!�h!�h!�h!r