MINI MINI MANI MO
3
  \7                 @   s   d Z ddlZddlZddlZddlT ddlmZ ddlmZ ddl	m
Z
 ddlmZm
Z
 ddlmZmZ dd	lmZ G d
d dZd-Zd.ddZd/d0d1d2d3d!Zd"d# Zd4d$d%Zd&d' Zd(d) ZdS )5zdistutils.ccompiler
Contains CCompiler, an abstract base class that defines the interface
for the Distutils compiler abstraction model.    N)*)spawn)	move_file)mkpath)newer_pairwisenewer_group)split_quotedexecute)logc            
   @   s  e Zd ZdZdZdZdZdZdZdZ	dZ
dZddddddZdddgZ
dqdd	Zd
d Zdd
 Zdd Zdd ZdrddZdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Z d.d/ Z!dsd0d1Z"d2d3 Z#d4d5 Z$d6d7 Z%d8d9 Z&dtd:d;Z'dud<d=Z(d>d? Z)dvd@dAZ*dBZ+dCZ,dDZ-dwdEdFZ.dxdGdHZ/dydIdJZ0dzdKdLZ1dMdN Z2dOdP Z3dQdR Z4d{dSdTZ5d|dUdVZ6d}dXdYZ7d~dZd[Z8dd\d]Z9dd_d`Z:ddbdcZ;ddde Z<dfdg Z=ddhdiZ>djdk Z?dldm Z@ddodpZAdS )	CCompilera  Abstract base class to define the interface that must be implemented
    by real compiler classes.  Also has some utility methods used by
    several compiler classes.
    The basic idea behind a compiler abstraction class is that each
    instance can be used for all the compile/link steps in building a
    single project.  Thus, attributes common to all of those compile and
    link steps -- include directories, macros to define, libraries to link
    against, etc. -- are attributes of the compiler instance.  To allow for
    variability in how individual files are treated, most of those
    attributes may be varied on a per-compilation or per-link basis.
    Nczc++Zobjc)z.cz.ccz.cppz.cxxz.mr   c             C   sf   || _ || _|| _d | _g | _g | _g | _g | _g | _g | _	x$| j
j D ]}| j|| j
|  qHW d S )N)
dry_runforceverbose
output_dirmacrosinclude_dirs	librarieslibrary_dirsruntime_library_dirsobjectsexecutableskeysset_executable)selfr   r
   r   key r   +/usr/lib64/python3.6/distutils/ccompiler.py__init__U   s    zCCompiler.__init__c             K   s@   x:|D ]2}|| j kr(td|| jjf | j|||  qW dS )a  Define the executables (and options for them) that will be run
        to perform the various stages of compilation.  The exact set of
        executables that may be specified here depends on the compiler
        class (via the 'executables' class attribute), but most will have:
          compiler      the C/C++ compiler
          linker_so     linker used to create shared objects and libraries
          linker_exe    linker used to create binary executables
          archiver      static library creator
        On platforms with a command-line (Unix, DOS/Windows), each of these
        is a string that will be split into executable name and (optional)
        list of arguments.  (Splitting the string is done similarly to how
        Unix shells operate: words are delimited by spaces, but quotes and
        backslashes can override this.  See
        'distutils.util.split_quoted()'.)
        z$unknown executable '%s' for class %sN)r   
ValueError	__class____name__r   )r   kwargsr   r   r   r   set_executablesy   s
    
zCCompiler.set_executablesc             C   s,   t |trt| |t| nt| || d S )N)
isinstancestrsetattrr   )r   r   valuer   r   r   r      s    
zCCompiler.set_executablec             C   s0   d}x&| j D ]}|d |kr |S |d7 }qW d S )Nr      )r   )r   nameidefnr   r   r   _find_macro   s    zCCompiler._find_macroc             C   sd   x^|D ]V}t |toFt|dkoFt |d ts:|d dkoFt |d tstd| d d qW dS )	zEnsures that every element of 'definitions' is a valid macro
        definition, ie. either (name,value) 2-tuple or a (name,) tuple.  Do
        nothing if all definitions are OK, raise TypeError otherwise.
        r(      Nr   zinvalid macro definition '%s': z.must be tuple (string,), (string, string), or z(string, None))r(   r-   )r$   tuplelenr%   	TypeError)r   Zdefinitionsr+   r   r   r   _check_macro_definitions   s    
z"CCompiler._check_macro_definitionsc             C   s.   | j |}|dk	r| j|= | jj||f dS )a_  Define a preprocessor macro for all compilations driven by this
        compiler object.  The optional parameter 'value' should be a
        string; if it is not supplied, then the macro will be defined
        without an explicit value and the exact outcome depends on the
        compiler used (XXX true? does ANSI say anything about this?)
        N)r,   r   append)r   r)   r'   r*   r   r   r   define_macro   s    	
zCCompiler.define_macroc             C   s0   | j |}|dk	r| j|= |f}| jj| dS )a  Undefine a preprocessor macro for all compilations driven by
        this compiler object.  If the same macro is defined by
        'define_macro()' and undefined by 'undefine_macro()' the last call
        takes precedence (including multiple redefinitions or
        undefinitions).  If the macro is redefined/undefined on a
        per-compilation basis (ie. in the call to 'compile()'), then that
        takes precedence.
        N)r,   r   r2   )r   r)   r*   Zundefnr   r   r   undefine_macro   s
    
zCCompiler.undefine_macroc             C   s   | j j| dS )zAdd 'dir' to the list of directories that will be searched for
        header files.  The compiler is instructed to search directories in
        the order in which they are supplied by successive calls to
        'add_include_dir()'.
        N)r   r2   )r   dirr   r   r   add_include_dir   s    zCCompiler.add_include_dirc             C   s   |dd | _ dS )ay  Set the list of directories that will be searched to 'dirs' (a
        list of strings).  Overrides any preceding calls to
        'add_include_dir()'; subsequence calls to 'add_include_dir()' add
        to the list passed to 'set_include_dirs()'.  This does not affect
        any list of standard include directories that the compiler may
        search by default.
        N)r   )r   dirsr   r   r   set_include_dirs   s    zCCompiler.set_include_dirsc             C   s   | j j| dS )a  Add 'libname' to the list of libraries that will be included in
        all links driven by this compiler object.  Note that 'libname'
        should *not* be the name of a file containing a library, but the
        name of the library itself: the actual filename will be inferred by
        the linker, the compiler, or the compiler class (depending on the
        platform).
        The linker will be instructed to link against libraries in the
        order they were supplied to 'add_library()' and/or
        'set_libraries()'.  It is perfectly valid to duplicate library
        names; the linker will be instructed to link against libraries as
        many times as they are mentioned.
        N)r   r2   )r   libnamer   r   r   add_library   s    zCCompiler.add_libraryc             C   s   |dd | _ dS )zSet the list of libraries to be included in all links driven by
        this compiler object to 'libnames' (a list of strings).  This does
        not affect any standard system libraries that the linker may
        include by default.
        N)r   )r   Zlibnamesr   r   r   
set_libraries   s    zCCompiler.set_librariesc             C   s   | j j| dS )a'  Add 'dir' to the list of directories that will be searched for
        libraries specified to 'add_library()' and 'set_libraries()'.  The
        linker will be instructed to search for libraries in the order they
        are supplied to 'add_library_dir()' and/or 'set_library_dirs()'.
        N)r   r2   )r   r5   r   r   r   add_library_dir  s    zCCompiler.add_library_dirc             C   s   |dd | _ dS )zSet the list of library search directories to 'dirs' (a list of
        strings).  This does not affect any standard library search path
        that the linker may search by default.
        N)r   )r   r7   r   r   r   set_library_dirs  s    zCCompiler.set_library_dirsc             C   s   | j j| dS )zlAdd 'dir' to the list of directories that will be searched for
        shared libraries at runtime.
        N)r   r2   )r   r5   r   r   r   add_runtime_library_dir  s    z!CCompiler.add_runtime_library_dirc             C   s   |dd | _ dS )zSet the list of directories to search for shared libraries at
        runtime to 'dirs' (a list of strings).  This does not affect any
        standard search path that the runtime linker may search by
        default.
        N)r   )r   r7   r   r   r   set_runtime_library_dirs  s    z"CCompiler.set_runtime_library_dirsc             C   s   | j j| dS )zAdd 'object' to the list of object files (or analogues, such as
        explicitly named library files or the output of "resource
        compilers") to be included in every link driven by this compiler
        object.
        N)r   r2   )r   objectr   r   r   add_link_object   s    zCCompiler.add_link_objectc             C   s   |dd | _ dS )zSet the list of object files (or analogues) to be included in
        every link to 'objects'.  This does not affect any standard object
        files that the linker may include by default (such as system
        libraries).
        N)r   )r   r   r   r   r   set_link_objects(  s    zCCompiler.set_link_objectsc             C   s.  |dkr| j }nt|ts"td|dkr2| j}n"t|trL|| jpFg  }ntd|dkrd| j}n*t|ttfrt|| jpg  }ntd|dkrg }| j|d|d}t	|t	|kst
t||}i }	xRtt	|D ]B}
||
 }||
 }t
jj|d }
| jt
jj| ||
f|	|<