o
    ug8                     @   s   d Z ddlZddl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mZ ddlmZmZmZmZ ddlmZ ejdkrCddlZG d	d
 d
e
ZdS )a9  distutils.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darwinc                	   @   s   e Zd ZdZddgdgdgddgdgddgddZejdd d	kr'd
ged
< g dZdZdZ	dZ
dZdZd Z ZZeZejdkrDdZ		d'ddZdd Z	d(ddZ				d)ddZdd Zdd  Zd!d" Zd#d$ Zd*d%d&ZdS )+UnixCCompilerunixNccz-sharedarz-cr)preprocessorcompilercompiler_socompiler_cxx	linker_so
linker_exearchiverranlib   r   r   )z.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%scygwinz.exec              
   C   s   |  d ||}|\}}}t||}	| j|	 }
|r|
d|g |r'||
d d< |r.|
| |
| | js?|d u s?t||rc|rJ| tj	
| z| |
 W d S  tyb } zt|d }~ww d S )N-or   )_fix_compile_argsr   r   extendappendforcer   mkpathospathdirnamespawnr   r   )selfsourceoutput_filemacrosinclude_dirsextra_preargsextra_postargs
fixed_argsignorepp_optspp_argsmsg r1   e/var/www/html/ecg_monitoring/venv/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py
preprocessU   s*   




zUnixCCompiler.preprocessc           	   
   C   sd   | j }tjdkrt||| }z| || |d|g |  W d S  ty1 } zt|d }~ww )Nr   r   )r   sysplatform_osx_supportcompiler_fixupr$   r   r   )	r%   objsrcextcc_argsr+   r.   r   r0   r1   r1   r2   _compileo   s   
zUnixCCompiler._compiler   c              
   C   s   |  ||\}}| j||d}| ||rN| tj| | | j|g | | j	  | j
rLz| | j
|g  W d S  tyK } zt|d }~ww d S td| d S )N)
output_dirskipping %s (up-to-date))_fix_object_argslibrary_filename
_need_linkr    r!   r"   r#   r$   r   objectsr   r   r	   r   debug)r%   rB   output_libnamer=   rC   target_langoutput_filenamer0   r1   r1   r2   create_static_libz   s*   	zUnixCCompiler.create_static_libc              
   C   s  |  ||\}}| |||}|\}}}t| |||}t|ttd fs(td|d ur3tj	||}| 
||r|| j | d|g }|	rMdg|d d< |
rU|
|d d< |r\|| | tj| zf|tjkrs| jd d  }n| jd d  }|dkr| jrd}tj|d dkrd}d|| v r|d7 }d|| v stj|| d	krd}nd}| j| ||| < tjd
krt||}| ||  W d S  ty } zt|d }~ww td| d S )Nz%'output_dir' must be a string or Noner   z-gr   zc++env   =	ld_so_aixr   r>   )r?   _fix_lib_argsr   
isinstancestrtype	TypeErrorr!   r"   joinrA   rB   r   r    r#   r   
EXECUTABLEr   r   r   basenamer4   r5   r6   r7   r$   r   r
   r   rC   )r%   target_descrB   rF   r=   	librarieslibrary_dirsruntime_library_dirsexport_symbolsrC   r*   r+   
build_temprE   r,   lib_optsld_argslinkerioffsetr0   r1   r1   r2   link   s`   



zUnixCCompiler.linkc                 C      d| S )N-Lr1   )r%   dirr1   r1   r2   library_dir_option      z UnixCCompiler.library_dir_optionc                 C   s   d|v pd|v S )Ngcczg++r1   )r%   compiler_namer1   r1   r2   _is_gcc   s   zUnixCCompiler._is_gccc                 C   s   t jttdd }tjd d dkr4ddl	m
}m} | }|r0||ddgkr0d| S d	| S tjd d
 dkrAd| S tjd d dkr[| |rUdd	| gS dd	| gS tddkrfd| S d| S )NCCr   r   r   )get_macosx_target_versplit_version
      z-Wl,-rpath,ra      freebsdz-Wl,-rpath=zhp-uxz-Wl,+sz+sGNULDyesz-Wl,--enable-new-dtags,-Rz-Wl,-R)r!   r"   rS   shlexsplitr   get_config_varr4   r5   distutils.utilri   rj   rg   )r%   rb   r   ri   rj   macosx_target_verr1   r1   r2   runtime_library_dir_option   s    
z(UnixCCompiler.runtime_library_dir_optionc                 C   r`   )Nz-lr1   )r%   libr1   r1   r2   library_option  rd   zUnixCCompiler.library_optionc                 C   s  | j |dd}| j |dd}| j |dd}| j |dd}tjdkr8td}td|}	|	d u r3d	}
n|	d
}
|D ]}tj	
||}tj	
||}tj	
||}tj	
||}tjdkr|dsl|dr|dstj	
|
|d
d  |}tj	
|
|d
d  |}tj	
|
|d
d  |}tj	
|
|d
d  |}tj	|r|  S tj	|r|  S tj	|r|  S tj	|r|  S q:d S )Nshared)lib_typedylib
xcode_stubstaticr   CFLAGSz-isysroot\s*(\S+)/rI   z/System/z/usr/z/usr/local/)r@   r4   r5   r   rs   researchgroupr!   r"   rQ   
startswithexists)r%   dirsrw   rC   shared_fdylib_fxcode_stub_fstatic_fcflagsmsysrootrb   ry   r{   r}   r|   r1   r1   r2   find_library_file  sH   



zUnixCCompiler.find_library_file)NNNNN)Nr   N)
NNNNNr   NNNN)r   )__name__
__module____qualname__compiler_typeexecutablesr4   r5   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_extensionr3   r<   rG   r_   rc   rg   rv   rx   r   r1   r1   r1   r2   r   -   sN    





B'r   )__doc__r!   r4   r   rq   	distutilsr   distutils.dep_utilr   distutils.ccompilerr   r   r   distutils.errorsr   r   r	   r
   r   r5   r6   r   r1   r1   r1   r2   <module>   s     
