509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ct„jˆ:  ã               @   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
< ddddddgZdZdZ	dZ
dZdZd Z ZZeZejdkr�dZ‡ fdd„Zd.dd„Zdd„ Zd/d d!„Zd0d"d#„Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd1d,d-„Z‡  ZS )2ÚUnixCCompilerZunixNZ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                s@   t ƒ j|||ƒ\}}}tjdƒ}|r6||kr6|j|ƒ |||fS )z'Remove standard library path from rpathÚLIBDIR)ÚsuperÚ_fix_lib_argsr   Úget_config_varÚremove)ÚselfÚ	librariesÚlibrary_dirsÚruntime_library_dirsZlibdir)Ú	__class__© ú//usr/lib64/python3.6/distutils/unixccompiler.pyr   U   s    

zUnixCCompiler._fix_lib_argsc             C   sÒ   | j d ||ƒ}|\}}}t||ƒ}	| j|	 }
|r>|
jd|gƒ |rN||
d d…< |r\|
j|ƒ |
j|ƒ | js~|d ks~t||ƒrÎ|r”| jtj	j
|ƒƒ y| j|
ƒ W n* tk
rÌ } zt|ƒ‚W Y d d }~X nX d S )Nz-or   )Z_fix_compile_argsr   r   ÚextendÚappendZforcer   ÚmkpathÚosÚpathÚdirnameÚspawnr   r   )r   ÚsourceZoutput_fileZmacrosZinclude_dirsÚextra_preargsÚextra_postargsÚ
fixed_argsÚignoreÚpp_optsZpp_argsÚmsgr#   r#   r$   Ú
preprocess^   s$    




zUnixCCompiler.preprocessc       	      C   sp   | j }tjdkr tj||| ƒ}y | j|| |d|g | ƒ W n* tk
rj } zt|ƒ‚W Y d d }~X nX d S )Nr   z-o)r   ÚsysÚplatformÚ_osx_supportÚcompiler_fixupr+   r   r   )	r   ÚobjÚsrcZextZcc_argsr.   r1   r   r2   r#   r#   r$   Ú_compilex   s    

zUnixCCompiler._compiler   c             C   s²   | j ||ƒ\}}| j||d�}| j||ƒr¢| jtjj|ƒƒ | j| j|g | | j	 ƒ | j
r®y| j| j
|g ƒ W q® tk
rž } zt|ƒ‚W Y d d }~X q®X ntjd|ƒ d S )N)Ú
output_dirz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_libnamer;   r@   Útarget_langÚoutput_filenamer2   r#   r#   r$   Úcreate_static_libƒ   s    zUnixCCompiler.create_static_libc             C   sº  | j ||ƒ\}}| j|||ƒ}|\}}}t| |||ƒ}t|ttd ƒfƒsPtdƒ‚|d k	rftjj	||ƒ}| j
||ƒ�rª|| j | d|g }|	rœdg|d d…< |
r¬|
|d d…< |rº|j|ƒ | jtjj|ƒƒ y®|tjkrè| jd d … }n| jd d … }|dk�rR| j�rRd}tjj|d ƒdk�rDd}xd|| k�rB|d7 }�q(W | j| ||< tjd	k�rjtj||ƒ}| j|| ƒ W n, tk
�r¦ } zt|ƒ‚W Y d d }~X nX ntjd
|ƒ d S )Nz%'output_dir' must be a string or Nonez-oz-gr   zc++Úenvé   ú=r   zskipping %s (up-to-date))r<   r   r   Ú
isinstanceÚstrÚtypeÚ	TypeErrorr(   r)   Újoinr>   r?   r%   r'   r*   r   Z
EXECUTABLEr   r   r   Úbasenamer4   r5   r6   r7   r+   r   r
   r   r@   )r   Ztarget_descr?   rB   r;   r   r    r!   Zexport_symbolsr@   r-   r.   Z
build_temprA   r/   Zlib_optsZld_argsZlinkerÚir2   r#   r#   r$   Úlink�   sH    


zUnixCCompiler.linkc             C   s   d| S )Nz-Lr#   )r   Údirr#   r#   r$   Úlibrary_dir_option×   s    z UnixCCompiler.library_dir_optionc             C   s   d|kpd|kS )NÚgcczg++r#   )r   Zcompiler_namer#   r#   r$   Ú_is_gccÚ   s    zUnixCCompiler._is_gccc             C   sÜ   t jjtj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| j|ƒrnd
d| gS dd| gS tjd d… dksžtjd d… dkr¦d|gS | j|ƒrÐtjdƒdkrÆd| S d| S nd| S d S )NÚCCr   r   z-Lé   Zfreebsdz-Wl,-rpath=é   zhp-uxz-Wl,+sz+sZirix646Zosf1V5z-rpathÚGNULDÚyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r(   r)   rL   r   r   r4   r5   rR   )r   rO   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jdƒ}tjd|ƒ}	|	d krfd	}
n
|	jd
ƒ}
�x|D �]}tj	j
||ƒ}tj	j
||ƒ}tj	j
||ƒ}tj	j
||ƒ}tjdkoÞ|jdƒsâ|jdƒoÞ|jdƒ �rBtj	j
|
|d
d … |ƒ}tj	j
|
|d
d … |ƒ}tj	j
|
|d
d … |ƒ}tj	j
|
|d
d … |ƒ}tj	j|ƒ�rT|S tj	j|ƒ�rf|S tj	j|ƒ�rx|S tj	j|ƒrx|S qxW d S )NÚshared)Zlib_typeÚdylibÚ
xcode_stubÚstaticr   ÚCFLAGSz-isysroot\s+(\S+)ú/rE   z/System/z/usr/z/usr/local/)r=   r4   r5   r   r   ÚreÚsearchÚgroupr(   r)   rK   Ú
startswithÚexists)r   ÚdirsrY   r@   Zshared_fZdylib_fZxcode_stub_fZstatic_fZcflagsÚmZsysrootrO   r[   r\   r^   r]   r#   r#   r$   Úfind_library_file  s>    




zUnixCCompiler.find_library_file)NNNNN)Nr   N)
NNNNNr   NNNN)r   )Ú__name__Ú
__module__Ú__qualname__Zcompiler_typeZexecutablesr4   r5   Zsrc_extensionsZobj_extensionZstatic_lib_extensionZ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   r3   r:   rC   rN   rP   rR   rX   rZ   rh   Ú__classcell__r#   r#   )r"   r$   r   -   sF   

	 

   
6,r   )Ú__doc__r(   r4   ra   Z	distutilsr   Zdistutils.dep_utilr   Zdistutils.ccompilerr   r   r   Zdistutils.errorsr   r   r	   r
   r   r5   r6   r   r#   r#   r#   r$   Ú<module>   s   
