o
    NZŽhº  ã                   @   s¦   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ g d	¢g d
¢g d¢dœZg d	¢g d
¢g d¢dœZ	g d¢g g dœZ
g ddgddgdœZG dd„ dejƒZdS )aœ  distutils.zosccompiler

Contains the selection of the c & c++ compilers on z/OS. There are several
different c compilers on z/OS, all of them are optional, so the correct
one needs to be chosen based on the users input. This is compatible with
the following compilers:

IBM C/C++ For Open Enterprise Languages on z/OS 2.0
IBM Open XL C/C++ 1.1 for z/OS
IBM XL C/C++ V2.4.1 for z/OS 2.4 and 2.5
IBM z/OS XL C/C++
é    Né   )Ú	sysconfig)ÚDistutilsExecErroré   )Úunix)ÚCompileError)z-m64z-fvisibility=defaultz-fzos-le-char-mode=asciiz-fno-short-enums)
ú-q64ú-qexportallú-qasciiú-qstrictú	-qnocsectú-Wa,asa,goffú
-Wa,xplinkú
-qgonumberú
-qenum=intú-Wc,DLL)r   r	   r
   r   r   r   r   r   r   r   z-qlanglvl=extc99)ú
ibm-openxlúibm-xlclangúibm-xlc)r   r	   r
   r   r   r   r   r   r   r   z-qlanglvl=extended0x)z-fasmz-fno-integrated-asz	-Wa,--ASAz
-Wa,--GOFFz-Wl,dllr   c                       sn   e Zd Zg d¢Zg d¢ZdgZdd„ Zd‡ fdd„	Zd	d
„ Zdd„ Z											d‡ fdd„	Z
‡  ZS )ÚCompiler)z.cú.Cú.ccú.cxxú.cppz.mú.s)r   r   r   r   r   c                    sl   ‡ fdd„dD ƒ}t |ƒdkrdS i }dD ]}d||< qdD ]}d||< qd	D ]}d
||< q'| |d d¡S )Nc                    s*   g | ]}t j |d ¡ ‰ rt j ˆ ¡‘qS ©N)ÚosÚenvironÚgetÚpathÚbasename)Ú.0Zenvvar©Úbinary© úT/var/www/auris/lib/python3.10/site-packages/setuptools/_distutils/compilers/C/zos.pyÚ
<listcomp>o   s    ý
ÿz3Compiler._get_zos_compiler_name.<locals>.<listcomp>)ÚCCÚCXXÚLDSHAREDr   r   )z	ibm-clangzibm-clang64zibm-clang++zibm-clang++64Zclangzclang++zclang-14)Zxlclangz	xlclang++Znjscznjsc++r   )ZxlcZxlCzxlc++r   )Úlenr   )ÚselfZzos_compiler_namesZzos_compilersÚcompilerr$   r"   r%   Ú_get_zos_compiler_namen   s   
þ
	

zCompiler._get_zos_compiler_nameFc                    s(   t ƒ  |||¡ |  ¡ | _t | ¡ d S r   )ÚsuperÚ__init__r-   Úzos_compilerr   Zcustomize_compiler)r+   ÚverboseÚdry_runÚforce©Ú	__class__r$   r%   r/   ‹   s   
zCompiler.__init__c           
   
   C   s¼   g }|| j v r| j}| t| j ¡ n$|| jv r,| j}| t| j ¡ | t| j ¡ n| j}| t| j ¡ | |¡ z|  	|| |d|g | ¡ W d S  t
y] }	 zt|	ƒ‚d }	~	ww )Nz-o)Ú_cpp_extensionsZcompiler_cxxÚextendÚ	_cxx_argsr0   Ú_asm_extensionsZcompiler_soÚ_cc_argsÚ	_asm_argsZspawnr   r   )
r+   ÚobjÚsrcÚextZcc_argsÚextra_postargsZpp_optsZ
local_argsr,   Úmsgr$   r$   r%   Ú_compile   s"   


"€ÿzCompiler._compilec                 C   s   d| S )Nz-Lr$   )r+   Údirr$   r$   r%   Úruntime_library_dir_option£   s   z#Compiler.runtime_library_dir_optionNc                    s  t  d¡}t jrtj t  d¡d|› d¡}ntj t  d¡t  d¡d|› d¡}tj |¡r:|r7| |¡ n|g}|rf|D ]'}|d d … D ]}tj ||› d¡}tj |¡rd| |¡ | |¡  nqFq>| 	t
| j ¡ tƒ  |||||||||	|
|||¡ d S )NÚ	LDVERSIONÚabs_builddirZ	libpythonz.xÚinstalled_baseÚ
platlibdir)r   Úget_config_varÚpython_buildr   r   ÚjoinÚexistsÚappendÚremover7   Ú_ld_argsr0   r.   Úlink)r+   Ztarget_descÚobjectsZoutput_filenameÚ
output_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsÚdebugZextra_preargsr?   Z
build_tempZtarget_langÚ	ldversionZside_deck_pathrB   ZlibraryZlibrary_side_deckr4   r$   r%   rO   ¦   sR   

þ
ý

ý€ózCompiler.link)FFF)
NNNNNFNNNN)Ú__name__Ú
__module__Ú__qualname__Zsrc_extensionsr6   r9   r-   r/   rA   rC   rO   Ú__classcell__r$   r$   r4   r%   r   i   s&    òr   )Ú__doc__r   Ú r   Úerrorsr   r   r   r:   r8   r;   rN   r   r$   r$   r$   r%   Ú<module>   s.    í#í#ýý
