ó
è¾bc           @   s    d  Z  d Z d d l Z d d l m Z m Z m Z m Z m Z d d l	 m
 Z
 m Z d d l m Z d d l m Z d d l m Z d	 e
 f d
 „  ƒ  YZ d S(   sƒ   distutils.bcppcompiler

Contains BorlandCCompiler, an implementation of the abstract CCompiler class
for the Borland C++ compiler.
s   $Id$iÿÿÿÿN(   t   DistutilsExecErrort   CompileErrort   LibErrort	   LinkErrort   UnknownFileError(   t	   CCompilert   gen_preprocess_options(   t
   write_file(   t   newer(   t   logt   BCPPCompilerc           B   sú   e  Z d  Z d Z i  Z d g Z d d d g Z e e Z d Z d Z	 d Z
 d	 Z Z d
 Z d d d d „ Z d d d d d d d d „ Z d d d d „ Z d d d d d d d d d d d „
 Z d d „ Z d d d „ Z d d d d d d „ Z RS(   s   Concrete class that implements an interface to the Borland C/C++
    compiler, as defined by the CCompiler abstract class.
    t   bcpps   .cs   .ccs   .cpps   .cxxs   .objs   .libs   .dlls   %s%ss   .exei    c         C   sÂ   t  j |  | | | ƒ d |  _ d |  _ d |  _ d  |  _ d d d d g |  _ d d d d g |  _ d	 d
 d d g |  _	 d	 d
 d d g |  _
 g  |  _ d
 d d g |  _ d
 d d d g |  _ d  S(   Ns	   bcc32.exes   ilink32.exes   tlib.exes   /tWMs   /O2s   /qs   /g0s   /Ods   /Tpds   /Gns   /xs   /r(   R   t   __init__t   cct   linkert   libt   Nonet   preprocess_optionst   compile_optionst   compile_options_debugt   ldflags_sharedt   ldflags_shared_debugt   ldflags_statict   ldflags_exet   ldflags_exe_debug(   t   selft   verboset   dry_runt   force(    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyR   5   s    					c	         C   sß  |  j  | | | | | | ƒ \ } }	 } }
 } | p6 g  } | j d ƒ | r_ | j |  j ƒ n | j |  j ƒ xi|	 D]a} y | | \ } } Wn t k
 r¦ qv n Xt j j | ƒ } t j j | ƒ } |  j	 t j j
 | ƒ ƒ | d k rö qv n  | d k rDy |  j d d | | g ƒ Wqv t k
 r=} t | ‚ qv Xqv n  | |  j k r\d } n | |  j k rtd } n d } d | } y4 |  j |  j g | |
 | | g | | g ƒ Wqv t k
 rÖ} t | ‚ qv Xqv W|	 S(	   Ns   -cs   .ress   .rct   brcc32s   -fot    s   -Ps   -o(   t   _setup_compilet   appendt   extendR   R   t   KeyErrort   ost   patht   normpatht   mkpatht   dirnamet   spawnR    R   t   _c_extensionst   _cpp_extensionsR   (   R   t   sourcest
   output_dirt   macrost   include_dirst   debugt   extra_preargst   extra_postargst   dependst   objectst   pp_optst   buildt   compile_optst   objt   srct   extt   msgt	   input_optt
   output_opt(    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyt   compileQ   sF    		
.c   	      C   s©   |  j  | | ƒ \ } } |  j | d | ƒ} |  j | | ƒ r• | d g | } | rX n  y |  j |  j g | ƒ Wq¥ t k
 r‘ } t | ‚ q¥ Xn t j d | ƒ d  S(   NR,   s   /us   skipping %s (up-to-date)(	   t   _fix_object_argst   library_filenamet
   _need_linkR(   R   R    R   R	   R/   (	   R   R3   t   output_libnameR,   R/   t   target_langt   output_filenamet   lib_argsR:   (    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyt   create_static_lib’   s    c          C   s¾  |  j  | | ƒ \ } } |  j | | | ƒ \ } } } | rU t j d t | ƒ ƒ n  | d  k	 ry t j j | | ƒ } n  |  j	 | | ƒ rª| t
 j k rÀ d } |	 r³ |  j } qã |  j } n# d } |	 rÙ |  j } n
 |  j } | d  k rø d } n³ t j j | ƒ \ } } t j j | ƒ \ } } t j j | d ƒ } t j j | d | ƒ } d g } x+ | plg  D] } | j d | | f ƒ qmW|  j t | | f d	 | ƒ t t j j | ƒ } | g } g  } x[ | D]S } t j j t j j | ƒ ƒ \ } } | d
 k r| j | ƒ qÖ| j | ƒ qÖWx+ | D]# } | j d t j j | ƒ ƒ q4W| j d ƒ | j | ƒ | j d | g ƒ | j d ƒ xL | D]D } |  j | | |	 ƒ } | d  k rÓ| j | ƒ qœ| j | ƒ qœW| j d ƒ | j d ƒ | j d | g ƒ | j d ƒ | j | ƒ |
 r>|
 | d *n  | rT| j | ƒ n  |  j t j j | ƒ ƒ y |  j |  j g | ƒ Wqºt k
 r¦} t | ‚ qºXn t j  d | ƒ d  S(   Ns7   I don't know what to do with 'runtime_library_dirs': %st   c0w32t   c0d32R   i    s   %s.deft   EXPORTSs     %s=_%ss
   writing %ss   .ress   /L%ss   /L.t   ,s   ,,t   import32t   cw32mts   skipping %s (up-to-date)(!   R>   t   _fix_lib_argsR	   t   warnt   strR   R#   R$   t   joinR@   R   t
   EXECUTABLER   R   R   R   t   splitt   splitextR'   R    t   executeR   t   mapR%   t   normcaseR!   t   find_library_fileR&   R(   R   R    R   R/   (    R   t   target_descR3   RC   R,   t	   librariest   library_dirst   runtime_library_dirst   export_symbolsR/   R0   R1   t
   build_tempRB   t   startup_objt   ld_argst   def_filet   headt   tailt   modnameR9   t   temp_dirt   contentst   symt   objects2t	   resourcest   filet   baset   lR   t   libfileR:   (    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyt   link«   s|    	
			$!c   	      C   s›   | r- | d } | d | d | | f } n | d | f } xW | D]K } xB | D]: } t  j j | |  j | ƒ ƒ } t  j j | ƒ rQ | SqQ WqD Wd  Sd  S(   Nt   _dt   _bcpp(   R#   R$   RO   R?   t   existsR   (	   R   t   dirsR   R/   t   dlibt	   try_namest   dirt   nameRk   (    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyRV   4  s    

R   c         C   s  | d  k r d } n  g  } xý | D]õ } t j j t j j | ƒ ƒ \ } } | |  j d d g k r{ t d | | f ‚ n  | r– t j j | ƒ } n  | d k rÅ | j t j j	 | | | ƒ ƒ q" | d k rô | j t j j	 | | d ƒ ƒ q" | j t j j	 | | |  j
 ƒ ƒ q" W| S(   NR   s   .rcs   .ress"   unknown file type '%s' (from '%s')(   R   R#   R$   RR   RU   t   src_extensionsR   t   basenameR    RO   t   obj_extension(   R   t   source_filenamest	   strip_dirR,   t	   obj_namest   src_nameRi   R9   (    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyt   object_filenamesN  s$     	$##c         C   s  |  j  d  | | ƒ \ } } } t | | ƒ } d g | }	 | d  k	 rZ |	 j d | ƒ n  | rm | |	 d *n  | rƒ |	 j | ƒ n  |	 j | ƒ |  j s´ | d  k s´ t | | ƒ r| rÖ |  j t j	 j
 | ƒ ƒ n  y |  j |	 ƒ Wqt k
 r
}
 |
 GHt |
 ‚ qXn  d  S(   Ns	   cpp32.exes   -oi    (   t   _fix_compile_argsR   R   R    R!   R   R   R&   R#   R$   R'   R(   R    R   (   R   t   sourcet   output_fileR-   R.   R0   R1   t   _R4   t   pp_argsR:   (    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyt
   preprocessj  s$    	$N(   t   __name__t
   __module__t   __doc__t   compiler_typet   executablesR)   R*   Ru   Rw   t   static_lib_extensiont   shared_lib_extensiont   static_lib_formatt   shared_lib_formatt   exe_extensionR   R   R=   RE   Rl   RV   R|   R‚   (    (    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyR
      sJ   	

B|(   R…   t   __revision__R#   t   distutils.errorsR    R   R   R   R   t   distutils.ccompilerR   R   t   distutils.file_utilR   t   distutils.dep_utilR   t	   distutilsR	   R
   (    (    (    s,   /usr/lib/python2.7/distutils/bcppcompiler.pyt   <module>   s   	(