a
    ɉxdh9                     @   s   d 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r~d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rNd
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rd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 |rN||
d d< |r\|
| |
| | js~|d u s~t||r|r| tj	
| z| |
 W n, ty } zt|W Y d }~n
d }~0 0 d S )N-or   )Z_fix_compile_argsr   r   extendappendforcer   mkpathospathdirnamespawnr   r   )selfsourceZoutput_fileZmacrosinclude_dirsextra_preargsextra_postargs
fixed_argsignorepp_optsZpp_argsmsg r-   [/var/www/html/Ranjet/env/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py
preprocessU   s$    




zUnixCCompiler.preprocessc           	   
   C   sr   | j }tjdkr t||| }z | || |d|g |  W n, tyl } zt|W Y d }~n
d }~0 0 d S )Nr   r   )r   sysplatform_osx_supportcompiler_fixupr#   r   r   )	r$   objsrcextZcc_argsr(   r+   r   r,   r-   r-   r.   _compileo   s    

zUnixCCompiler._compiler   c              
   C   s   |  ||\}}| j||d}| ||r| tj| | | j|g | | j	  | j
rz| | j
|g  W q ty } zt|W Y d }~qd }~0 0 n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$   r=   Zoutput_libnamer8   r>   target_langoutput_filenamer,   r-   r-   r.   create_static_libz   s$    	 zUnixCCompiler.create_static_libc              
   C   s  |  ||\}}| |||}|\}}}t| |||}t|ttd fsPtd|d urftj	||}| 
||r|| j | d|g }|	rdg|d d< |
r|
|d d< |r|| | tj| z|tjkr| jd d  }n| jd d  }|dkrr| jrrd}tj|d dkr@d}d|| v r@|d7 }q&tj|| d	kr\d}nd}| j| ||| < tjd
krt||}| ||  W n. ty } zt|W Y d }~n
d }~0 0 ntd| d S )Nz%'output_dir' must be a string or Noner   z-gr   zc++env   =Z	ld_so_aixr   r9   )r:   Z_fix_lib_argsr   
isinstancestrtype	TypeErrorr    r!   joinr<   r=   r   r   r"   r   Z
EXECUTABLEr   r   r   basenamer0   r1   r2   r3   r#   r   r
   r   r>   )r$   Ztarget_descr=   r@   r8   	librarieslibrary_dirsruntime_library_dirsexport_symbolsr>   r'   r(   
build_tempr?   r)   Zlib_optsZld_argsZlinkerioffsetr,   r-   r-   r.   link   sZ    


 zUnixCCompiler.linkc                 C   s   d| S )N-Lr-   )r$   dirr-   r-   r.   library_dir_option   s    z UnixCCompiler.library_dir_optionc                 C   s   d|v pd|v S )NZgcczg++r-   )r$   Zcompiler_namer-   r-   r.   _is_gcc   s    zUnixCCompiler._is_gccc                 C   s   t jtd}tjd d dkr,d| S tjd d dkrFd| S tjd d d	krz| |rnd
d| gS dd| gS | |rtddkrd| S d| S nd| S d S )NCCr   r   rS      Zfreebsdz-Wl,-rpath=   zhp-uxz-Wl,+sz+sGNULDyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r    r!   rJ   r   get_config_varr0   r1   rV   )r$   rT   r   r-   r-   r.   runtime_library_dir_option   s    


z(UnixCCompiler.runtime_library_dir_optionc                 C   s   d| S )Nz-lr-   )r$   libr-   r-   r.   library_option  s    zUnixCCompiler.library_optionc                 C   s  | j |dd}| j |dd}| j |dd}| j |dd}tjdkrptd}td|}	|	d u rfd	}
n
|	d
}
|D ] }tj	
||}tj	
||}tj	
||}tj	
||}tjdkr@|ds|dr@|ds@tj	
|
|d
d  |}tj	
|
|d
d  |}tj	
|
|d
d  |}tj	
|
|d
d  |}tj	|rV|  S tj	|rl|  S tj	|r|  S tj	|rt|  S qtd S )Nshared)Zlib_typedylib
xcode_stubstaticr   CFLAGSz-isysroot\s*(\S+)/rC   z/System/z/usr/z/usr/local/)r;   r0   r1   r   r\   researchgroupr    r!   rI   
startswithexists)r$   dirsr^   r>   Zshared_fZdylib_fZxcode_stub_fZstatic_fcflagsmZsysrootrT   r`   ra   rc   rb   r-   r-   r.   find_library_file	  sF    




zUnixCCompiler.find_library_file)NNNNN)Nr   N)
NNNNNr   NNNN)r   )__name__
__module____qualname__compiler_typeZexecutablesr0   r1   Zsrc_extensionsZobj_extensionZstatic_lib_extensionshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZexe_extensionr/   r7   rA   rR   rU   rV   r]   r_   rn   r-   r-   r-   r.   r   -   sL   


  
 
    
B*r   )__doc__r    r0   rf   	distutilsr   distutils.dep_utilr   distutils.ccompilerr   r   r   distutils.errorsr   r   r	   r
   r   r1   r2   r   r-   r-   r-   r.   <module>   s   
