o
    Zh                     @   s   d Z ddlZddlmZ ddlmZ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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)CompileErrorDistutilsExecError)UnixCCompiler)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 )zOSCCompiler)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 Y/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/_distutils/zosccompiler.py
<listcomp>n   s    
z7zOSCCompiler._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_namem   s   

	

z#zOSCCompiler._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zOSCCompiler.__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_argsr/   _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zOSCCompiler._compilec                 C   s   d| S )Nz-Lr#   )r*   dirr#   r#   r$   runtime_library_dir_option   s   z'zOSCCompiler.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remover6   _ld_argsr/   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_pathrA   ZlibraryZlibrary_side_deckr3   r#   r$   rN      sR   




zzOSCCompiler.link)FFF)
NNNNNFNNNN)__name__
__module____qualname__Zsrc_extensionsr5   r8   r,   r.   r@   rB   rN   __classcell__r#   r#   r3   r$   r   h   s&    r   )__doc__r    r   errorsr   r   Zunixccompilerr   r9   r7   r:   rM   r   r#   r#   r#   r$   <module>   s,    ##
