ó
čžbc           @   s{   d  Z  d Z d d l Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d   Z d	 e f d
     YZ d S(   s´   distutils.command.build_clib

Implements the Distutils 'build_clib' command, to build a C/C++ library
that is included in the module distribution and needed by an extension
module.s   $Id$i˙˙˙˙N(   t   Command(   t   DistutilsSetupError(   t   customize_compiler(   t   logc          C   s   d d l  m }  |    d  S(   Ni˙˙˙˙(   t   show_compilers(   t   distutils.ccompilerR   (   R   (    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyR      s    t
   build_clibc           B   s   e  Z d  Z d d d d d g Z d d
 g Z d d d e f g Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z RS(   s/   build C/C++ libraries used by Python extensionss   build-clib=t   bs%   directory to build C/C++ libraries tos   build-temp=t   ts,   directory to put temporary build by-productst   debugt   gs"   compile with debugging informationt   forcet   fs2   forcibly build everything (ignore file timestamps)s	   compiler=t   cs   specify the compiler types   help-compilers   list available compilersc         C   sU   d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d |  _ d  |  _	 d  S(   Ni    (
   t   NoneR   t
   build_tempt	   librariest   include_dirst   definet   undefR	   R   t   compiler(   t   self(    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyt   initialize_options6   s    								c         C   s   |  j  d d d d	 d
 d  |  j j |  _ |  j rG |  j |  j  n  |  j d  k rn |  j j pe g  |  _ n  t |  j t  r |  j j t	 j
  |  _ n  d  S(   Nt   buildR   R   R   R	   R   (   R   R   (   R   R   (   R   R   (   R	   R	   (   R   R   (   t   set_undefined_optionst   distributionR   t   check_library_listR   R   t
   isinstancet   strt   splitt   ost   pathsep(   R   (    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyt   finalize_optionsF   s    		c         C   s˙   |  j  s d  Sd d l m } | d |  j d |  j d |  j  |  _ t |  j  |  j d  k	 rv |  j j	 |  j  n  |  j
 d  k	 rľ x- |  j
 D] \ } } |  j j | |  q Wn  |  j d  k	 rë x$ |  j D] } |  j j |  qÎ Wn  |  j |  j   d  S(   Ni˙˙˙˙(   t   new_compilerR   t   dry_runR   (   R   R   R!   R   R"   R   R   R   R   t   set_include_dirsR   t   define_macroR   t   undefine_macrot   build_libraries(   R   R!   t   namet   valuet   macro(    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyt   run_   s     		c         C   sę   t  | t  s t d  n  xČ | D]Ŕ } t  | t  rV t |  d k rV t d  n  | \ } } t  | t  s t d d  n  d | k sŤ t j d k rĂ t j | k rĂ t d d | d	  n  t  | t  s" t d
 d  q" q" Wd S(   s`  Ensure that the list of libraries is valid.

        `library` is presumably provided as a command option 'libraries'.
        This method checks that it is a list of 2-tuples, where the tuples
        are (library_name, build_info_dict).

        Raise DistutilsSetupError if the structure is invalid anywhere;
        just returns otherwise.
        s+   'libraries' option must be a list of tuplesi   s*   each element of 'libraries' must a 2-tuples+   first element of each tuple in 'libraries' s#   must be a string (the library name)t   /s   bad library name '%s': s$   may not contain directory separatorsi    s,   second element of each tuple in 'libraries' s!   must be a dictionary (build info)N(	   R   t   listR   t   tuplet   lenR   R   t   sept   dict(   R   R   t   libR'   t
   build_info(    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyR   w   s*    
	"	
*c         C   s>   |  j  s d  Sg  } x$ |  j  D] \ } } | j |  q W| S(   N(   R   R   t   append(   R   t	   lib_namest   lib_nameR2   (    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyt   get_library_names   s    	c         C   s   |  j  |  j  g  } xe |  j D]Z \ } } | j d  } | d  k s] t | t t f  rm t d |  n  | j |  q  W| S(   Nt   sourcessf   in 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames(	   R   R   t   getR   R   R,   R-   R   t   extend(   R   t	   filenamesR5   R2   R7   (    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyt   get_source_files§   s    "
c         C   só   xě | D]ä \ } } | j  d  } | d  k sD t | t t f  r\ t d d d |  n  t |  } t j d |  | j  d  } | j  d  } |  j j	 | d |  j
 d | d | d	 |  j } |  j j | | d |  j d	 |  j q Wd  S(
   NR7   s&   in 'libraries' option (library '%s'), s&   'sources' must be present and must be s   a list of source filenamess   building '%s' libraryt   macrosR   t
   output_dirR	   (   R8   R   R   R,   R-   R   R   t   infoR   t   compileR   R	   t   create_static_libR   (   R   R   R5   R2   R7   R<   R   t   objects(    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyR&   ľ   s$    "		(   s   build-clib=R   s%   directory to build C/C++ libraries to(   s   build-temp=R   s,   directory to put temporary build by-products(   R	   R
   s"   compile with debugging information(   R   R   s2   forcibly build everything (ignore file timestamps)(   s	   compiler=R   s   specify the compiler typeN(   t   __name__t
   __module__t   descriptiont   user_optionst   boolean_optionsR   R   t   help_optionsR   R    R*   R   R6   R;   R&   (    (    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyR      s*        					$		(   t   __doc__t   __revision__R   t   distutils.coreR    t   distutils.errorsR   t   distutils.sysconfigR   t	   distutilsR   R   R   (    (    (    s2   /usr/lib/python2.7/distutils/command/build_clib.pyt   <module>   s   	