o
    ^+)hÅ9  ã                   @   s„   d Z ddlZddlZddlmZmZmZmZmZ ddl	m
Z
mZ ddlmZ ddl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)ÚDistutilsExecErrorÚCompileErrorÚLibErrorÚ	LinkErrorÚUnknownFileError)Ú	CCompilerÚgen_preprocess_options)Ú
write_file)Únewer)Úlogz˜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.
    Z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ÚlibZpreprocess_optionsÚcompile_optionsÚcompile_options_debugÚldflags_sharedÚldflags_shared_debugZldflags_staticÚldflags_exeÚldflags_exe_debug)ÚselfÚverboseÚdry_runÚforce©Ú	__class__© úaC:\Users\User\Downloads\Proyecto_IoT\venv\Lib\site-packages\setuptools/_distutils/bcppcompiler.pyr   B   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ú.rcZbrcc32z-foÚ z-Pú-o)Z_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_postargsZdependsÚobjectsÚpp_optsÚbuildZcompile_optsÚobjÚsrcÚextÚmsgZ	input_optZ
output_optr#   r#   r$   ÚcompileZ   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)r5   z/uúskipping %s (up-to-date))	Ú_fix_object_argsÚlibrary_filenameÚ
_need_linkr1   r   r   r   r   r8   )	r   r;   Zoutput_libnamer5   r8   Útarget_langÚoutput_filenameZlib_argsrA   r#   r#   r$   Úcreate_static_lib§   s   €ÿzBCPPCompiler.create_static_libc               
   C   sÒ  |   ||¡\}}|  |||¡\}}}|rt dt|ƒ¡ |d ur'tj ||¡}|  ||¡ra|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}n?tj |¡\}}tj |¡\}}tj |d ¡}tj |d| ¡}dg}|pˆg 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¡ | d|g¡ | d¡ | |¡ |
r2|
|d d…< |r:| |¡ |  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': %sZc0w32Zc0d32r'   r   z%s.defZEXPORTSz  {}=_{}z
writing %sr%   z/L%sz/L.ú,z,,Zimport32Zcw32mtrC   )!rD   Z_fix_lib_argsr   ÚwarnÚstrr,   r-   ÚjoinrF   r   Z
EXECUTABLEr   r   r   r   ÚsplitÚsplitextr0   r)   ÚformatÚexecuter	   Úmapr.   Únormcaser*   Úfind_library_filer/   r1   r   r   r   r8   ) r   Ztarget_descr;   rH   r5   Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr8   r9   r:   Z
build_temprG   Zstartup_objZld_argsZdef_fileÚheadÚtailÚmodnamer@   Útemp_dirÚcontentsÚsymZobjects2Ú	resourcesÚfileÚbaseZellr   ÚlibfilerA   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Ú_dZ_bcpp)r,   r-   rM   rE   Úexists)	r   Údirsr   r8   ZdlibZ	try_namesÚdirÚnamer^   r#   r#   r$   rT   D  s   
ÿþzBCPPCompiler.find_library_filer'   c                 C   sÆ   |d u rd}g }|D ]V}t j t j |¡¡\}}|| jddg vr)td ||¡ƒ‚|r1t j |¡}|dkrB| t j 	||| ¡¡ q
|dkrS| t j 	||d ¡¡ q
| t j 	||| j
 ¡¡ q
|S )Nr'   r&   r%   z"unknown file type '{}' (from '{}'))r,   r-   rO   rS   Úsrc_extensionsr   rP   Úbasenamer)   rM   Úobj_extension)r   Zsource_filenamesZ	strip_dirr5   Z	obj_namesZsrc_namer]   r@   r#   r#   r$   Úobject_filenames^  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   )Z_fix_compile_argsr   r)   r*   r    r
   r/   r,   r-   r0   r1   r   Úprintr   )r   ÚsourceZoutput_filer6   r7   r9   r:   Ú_r<   Zpp_argsrA   r#   r#   r$   Ú
preprocessw  s*   




€þûzBCPPCompiler.preprocess)r   r   r   )NNNr   NNN)Nr   N)
NNNNNr   NNNN)r   )r   r'   )NNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Zcompiler_typeZexecutablesr2   r3   re   rg   Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZexe_extensionr   rB   rI   r_   rT   rh   rl   Ú__classcell__r#   r#   r!   r$   r   '   sV    
÷N
ÿ
ò 


ùr   )rp   r,   ÚwarningsZdistutils.errorsr   r   r   r   r   Zdistutils.ccompilerr   r   Zdistutils.file_utilr	   Zdistutils.dep_utilr
   Ú	distutilsr   rK   ÚDeprecationWarningr   r#   r#   r#   r$   Ú<module>   s    ü