o
     zqfF9  ã                   @   s„   d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZmZmZmZmZ ddlmZ e d	e¡ G d
d„ deƒZdS )zƒdistutils.bcppcompiler

Contains BorlandCCompiler, an implementation of the abstract CCompiler class
for the Borland C++ compiler.
é    Né   )Úlog)Únewer)Ú	CCompilerÚgen_preprocess_options)ÚCompileErrorÚDistutilsExecErrorÚLibErrorÚ	LinkErrorÚUnknownFileError)Ú
write_filez˜bcppcompiler is deprecated and slated to be removed in the future. Please discontinue use or file an issue with pypa/distutils describing your use case.c                       sÂ   e Zd ZdZdZi ZdgZg d¢Zee ZdZ	dZ
dZd ZZd	Zd‡ fdd„	Z				
			ddd„Z	ddd„Z						
				ddd„Zddd„Zd dd„Z					d!dd„Z‡  ZS )"ÚBCPPCompilerzConcrete class that implements an interface to the Borland C/C++
    compiler, as defined by the CCompiler abstract class.
    Úbcppz.c)z.ccz.cppz.cxxz.objz.libz.dllz%s%sz.exer   c                    sn   t ƒ  |||¡ d| _d| _d| _d | _g d¢| _g d¢| _g d¢| _g d¢| _	g | _
g d¢| _g d¢| _d S )	Nz	bcc32.exezilink32.exeztlib.exe)ú/tWMz/O2ú/qú/g0)r   z/Odr   r   )z/Tpdú/Gnr   ú/x)r   r   r   )r   r   r   z/r)ÚsuperÚ__init__ÚccÚlinkerÚlibÚpreprocess_optionsÚcompile_optionsÚcompile_options_debugÚldflags_sharedÚldflags_shared_debugÚldflags_staticÚldflags_exeÚldflags_exe_debug)ÚselfÚverboseÚdry_runÚforce©Ú	__class__© úa/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/_distutils/bcppcompiler.pyr   @   s   




zBCPPCompiler.__init__Nc	                 C   sn  |   ||||||¡\}}	}}
}|pg }| d¡ |r!| | j¡ n| | j¡ |	D ]‹}z|| \}}W n	 ty<   Y q)w tj |¡}tj |¡}|  	tj 
|¡¡ |dkrWq)|dkrxz|  dd||g¡ W n tyv } zt|ƒ‚d }~ww q)|| jv r€d}n
|| jv rˆd}nd}d| }z|  | jg| |
 ||g | |g ¡ W q) ty´ } zt|ƒ‚d }~ww |	S )	Nz-cú.resú.rcÚbrcc32z-foÚ z-Pú-o)Ú_setup_compileÚappendÚextendr   r   ÚKeyErrorÚosÚpathÚnormpathÚmkpathÚdirnameÚspawnr   r   Ú_c_extensionsÚ_cpp_extensionsr   )r!   ÚsourcesÚ
output_dirÚmacrosÚinclude_dirsÚdebugÚextra_preargsÚextra_postargsÚdependsÚobjectsÚpp_optsÚbuildÚcompile_optsÚobjÚsrcÚextÚmsgÚ	input_optÚ
output_optr'   r'   r(   ÚcompileW   sh   ÿ
ÿ€ÿ

ÿþýüûÿ€ÿzBCPPCompiler.compilec           	   
   C   s†   |   ||¡\}}| j||d}|  ||¡r;|dg| }|r	 z|  | jg| ¡ W d S  ty: } zt|ƒ‚d }~ww t d|¡ d S )N)r;   z/uúskipping %s (up-to-date))	Ú_fix_object_argsÚlibrary_filenameÚ
_need_linkr7   r   r   r	   r   r>   )	r!   rB   Úoutput_libnamer;   r>   Útarget_langÚoutput_filenameÚlib_argsrI   r'   r'   r(   Úcreate_static_lib£   s   €ÿzBCPPCompiler.create_static_libc               
   C   sÌ  |   ||¡\}}|  |||¡\}}}|rt dt|ƒ¡ |d ur'tj ||¡}|  ||¡r^|t	j
krGd}|	r?| jd d … }n| jd d … }nd}|	rS| jd d … }n| jd d … }|d u rad}nAtj |¡\}}tj |¡\}}tj |d ¡}tj |d| ¡}dg}|pˆg D ]}| d|› d	|› ¡ q‰|  t||fd
| ¡ ttjj|ƒ}|g}g }|D ]}tj tj |¡¡\}}|dkrÈ| |¡ q°| |¡ q°|D ]}| dtj |¡ ¡ qÐ| d¡ | |¡ | d|g¡ | d¡ |D ]}|  |||	¡}|d u r
| |¡ qö| |¡ qö| d¡ | d|g¡ | d¡ | |¡ |
r/|
|d d…< |r7| |¡ |  tj |¡¡ z|  | jg| ¡ W d S  ty] } zt|ƒ‚d }~ww t d|¡ d S )Nz7I don't know what to do with 'runtime_library_dirs': %sÚc0w32Úc0d32r,   r   z%s.defÚEXPORTSz  z=_z
writing %sr)   z/L%sz/L.ú,z,,)Úimport32Úcw32mtrM   ) rN   Ú_fix_lib_argsr   ÚwarningÚstrr2   r3   ÚjoinrP   r   Ú
EXECUTABLEr    r   r   r   ÚsplitÚsplitextr6   r/   Úexecuter   Úmapr4   Únormcaser0   Úfind_library_filer5   r7   r   r   r
   r>   ) r!   Útarget_descrB   rS   r;   Ú	librariesÚlibrary_dirsÚruntime_library_dirsÚexport_symbolsr>   r?   r@   Ú
build_temprR   Ústartup_objÚld_argsÚdef_fileÚheadÚtailÚmodnamerH   Útemp_dirÚcontentsÚsymÚobjects2Ú	resourcesÚfileÚbaseÚellr   ÚlibfilerI   r'   r'   r(   Úlink¶   s„   
ÿþ








€ÿzBCPPCompiler.linkc           	      C   sr   |r|d }|d |d ||f}n|d |f}|D ]}|D ]}t j ||  |¡¡}t j |¡r5|    S qqd S )NÚ_dÚ_bcpp)r2   r3   r_   rO   Úexists)	r!   Údirsr   r>   ÚdlibÚ	try_namesÚdirÚnamer{   r'   r'   r(   rf   <  s   
ÿþzBCPPCompiler.find_library_filer,   c                 C   sÌ   |d u rd}g }|D ]Y}t j t j |¡¡\}}|| jddg vr,td|› d|› dƒ‚|r4t j |¡}|dkrE| t j ||| ¡¡ q
|dkrV| t j ||d ¡¡ q
| t j ||| j	 ¡¡ q
|S )Nr,   r*   r)   zunknown file type 'z	' (from 'z'))
r2   r3   rb   re   Úsrc_extensionsr   Úbasenamer/   r_   Úobj_extension)r!   Úsource_filenamesÚ	strip_dirr;   Ú	obj_namesÚsrc_namery   rH   r'   r'   r(   Úobject_filenamesV  s   zBCPPCompiler.object_filenamesc              
   C   sÒ   |   d ||¡\}}}t||ƒ}dg| }	|d ur|	 d| ¡ |r'||	d d…< |r.|	 |¡ |	 |¡ | js?|d u s?t||ƒrg|rJ|  tj 	|¡¡ z|  
|	¡ W d S  tyf }
 zt|
ƒ t|
ƒ‚d }
~
ww d S )Nz	cpp32.exer-   r   )Ú_fix_compile_argsr   r/   r0   r$   r   r5   r2   r3   r6   r7   r   Úprintr   )r!   ÚsourceÚoutput_filer<   r=   r?   r@   Ú_rC   Úpp_argsrI   r'   r'   r(   Ú
preprocessm  s*   	



€þûzBCPPCompiler.preprocess)r   r   r   )NNNr   NNN)Nr   N)
NNNNNr   NNNN)r   )r   r,   )NNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcompiler_typeÚexecutablesr8   r9   r…   r‡   Ústatic_lib_extensionÚshared_lib_extensionÚstatic_lib_formatÚshared_lib_formatÚexe_extensionr   rL   rU   r|   rf   rŒ   r“   Ú__classcell__r'   r'   r%   r(   r   %   sV    
÷M
ÿ
ò 

ùr   )r—   r2   ÚwarningsÚ_logr   Ú	_modifiedr   Ú	ccompilerr   r   Úerrorsr   r   r	   r
   r   Ú	file_utilr   ÚwarnÚDeprecationWarningr   r'   r'   r'   r(   Ú<module>   s    ü