
Y$              
   @   sL  d  d l  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	 d d l m
 Z
 d d l
 m Z m Z m Z m Z d Z d Z d Z i d d 6d d 6d d& 6d d' 6d d) 6d d+ 6d d- 6d d. 6d d0 6d d1 6d d2 6Z e d d Z e d d Z d Z f  Z x e D] Z e e e 7Z q&We d 7Z e j d5  a d6 d7   Z d8 d9   Z d: d;   Z d< d=   Z d> d?   Z d@ dA   Z dB dC   Z  i g  dD 6dE dF g dG 6dH dF g dI 6dJ g dK 6dL dF g dM 6Z! i g  dD 6dN dO dP dQ dR g dG 6dS dT dU dV g dI 6dS dU dW g dK 6dS dT dX dV g dM 6Z" i g  dD 6g  dG 6g  dI 6g  dK 6g  dM 6Z# i g  dD 6g  dG 6g  dI 6dY g dK 6g  dM 6Z$ i g  dD 6g  dG 6g  dI 6g  dK 6dZ g dM 6Z% i g  dD 6dF g dG 6dF g dI 6g  dK 6g  dM 6Z& i g  dD 6d[ d\ g dG 6d[ d\ d[ d] g dI 6d[ d^ g dK 6g  dM 6Z' i g  dD 6dF dE g dG 6dF d_ g dI 6dJ d` g dK 6g  dM 6Z( i g  dD 6dF dE g dG 6dF d_ g dI 6dJ da g dK 6g  dM 6Z) i g  dD 6dF g dG 6dF d_ g dI 6d_ da g dK 6g  dM 6Z* i g  dD 6db g dG 6db dc g dI 6dc g dK 6g  dM 6Z+ i g  dD 6dF g dG 6dF d_ g dI 6d_ g dK 6g  dM 6Z, dd de df dg dh di dj dk dl dm g
 Z- dn do dp dq dr ds dt du dv dw g
 Z. i dx g dy 6dz g d{ 6d| g d} 6Z/ i d~ d g dy 6d~ d g d{ 6d~ d g d} 6Z0 i
 e j1 d d d  d 6e j1 d d d  d 6e j2 d d d d d d d d g d  d 6e j1 d d d  d 6e j1 d d d  d 6e j2 d d d d d g d  d 6e j1 d d d  d 6e j2 d d dy d{ d} g d{  d 6e j1 d d d  d 6e j1 d d d  d 6Z3 i
 d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6Z4 i	 d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d d 6Z5 i
 d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d g d 6d d 6Z6 d d   Z7 d d   Z8 d d   Z9 d d   Z: Gd d   d e  Z; Gd d   d  Z< Gd d   d e=  Z> Gd d   d  Z? d  Z@ d ZA d ZB d ZC d  ZD d ZE d ZF d  ZG d ZH d ZI d d   ZJ d d   ZK d d   ZL d d   ZM Gd d   d  ZN Gd d   d  ZO Gd d   d  ZP d S)    N   )StaticLinker)coredata)mlog)mesonlib)EnvironmentExceptionMesonExceptionversion_compare
Popen_safehhhhpphxxHippmocvapidioobjresalibdlldylibsoccppcccxxc++f90f95f03f08fforftnfppfortrandmobjcmmobjcpprsrustvalagscsswiftjavallsz(.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$c             C   s   |  t  k r d St  j |   S)a"  
    Sorting function to sort the list of languages according to
    reversed(compilers.clike_langs) and append the unknown langs in the end.
    The purpose is to prefer C over C++ for files that can be compiled by
    both such as assembly, C, etc. Also applies to ObjC, ObjC++, etc.
       )clike_langsindex)lang r<   Z/mnt/raid6/a/bak/reczko/tools/protein/utils/meson-0.42.1/mesonbuild/compilers/compilers.py
sort_clike>   s    r>   c             C   s8   t  |  d  r |  j }  n  |  j d  d } | t k S)Nfname.r8   )hasattrr?   splitheader_suffixes)r?   suffixr<   r<   r=   	is_headerI   s    rF   c             C   s>   t  |  d  r |  j }  n  |  j d  d j   } | t k S)Nr?   r@   r8   rA   )rB   r?   rC   lowerclike_suffixes)r?   rE   r<   r<   r=   	is_sourceO   s    rI   c             C   s8   t  |  d  r |  j }  n  |  j d  d j   d k S)Nr?   r@   r8   r7   rA   )rB   r?   rC   rG   )r?   r<   r<   r=   is_assemblyU   s    rJ   c             C   s2   t  |  d  r |  j }  n  |  j d  d d k S)Nr?   r@   r8   r6   rA   )rB   r?   rC   )r?   r<   r<   r=   
is_llvm_irZ   s    rK   c             C   s8   t  |  d  r |  j }  n  |  j d  d } | t k S)Nr?   r@   r8   rA   )rB   r?   rC   obj_suffixes)r?   rE   r<   r<   r=   	is_object_   s    rM   c             C   s8   t  |  d  r |  j }  n  |  j d  d } | t k S)Nr?   r@   r8   rA   )rB   r?   rC   lib_suffixes)r?   rE   r<   r<   r=   
is_librarye   s    rO   plainz-O0z-gdebugz-O2debugoptimizedz-O3releasez-Osminsizez/MDdz/ZIz/Ob0z/Odz/RTC1z/MDz/Ziz/O2z/Ob1z/Ob2z/Osz-Wl,-O1z/INCREMENTAL:NOz-Czdebuginfo=2zopt-level=2zopt-level=3z-Oz	-freleasez-releasez-debugz
-optimize+z
-lkernel32z-luser32z-lgdi32z
-lwinspoolz	-lshell32z-lole32z
-loleaut32z-luuidz
-lcomdlg32z
-ladvapi32zkernel32.libz
user32.libz	gdi32.libzwinspool.libzshell32.libz	ole32.libzoleaut32.libzuuid.libzcomdlg32.libzadvapi32.libz-fdiagnostics-color=autoZautoz-fdiagnostics-color=alwaysalwaysz-fdiagnostics-color=neverZneverz-Xclangz-fcolor-diagnosticsz-fno-color-diagnosticsb_pchzUse precompiled headersTb_ltozUse link time optimizationF
b_sanitizezCode sanitizer to usenoneaddressthreadZ	undefinedZmemoryzaddress,undefinedb_lundefz#Use -Wl,--no-undefined when linking
b_asneededz Use -Wl,--as-needed when linkingb_pgozUse profile guided optimizationoffgenerateuse
b_coveragezEnable coverage tracking.
b_coloroutzUse colored outputb_ndebugzDisable assertsb_staticpicz.Build static libraries as position independentz-mmmxZmmxz-msseZssez-msse2Zsse2z-msse3Zsse3z-mssse3Zssse3z-msse4.1Zsse41z-msse4.2Zsse42z-mavxZavxz-mavx2Zavx2z
-mfpu=neonZneonz	/arch:SSEz
/arch:SSE2z	/arch:AVXz
/arch:AVX2c             C   s=   |  d k r g  Sd |  g } |  d k r9 | j  d  n  | S)NrY   z-fsanitize=rZ   z-fno-omit-frame-pointer)append)valueargsr<   r<   r=   sanitizer_compile_args  s    ri   c             C   s!   |  d k r g  Sd |  g } | S)NrY   z-fsanitize=r<   )rg   rh   r<   r<   r=   sanitizer_link_args  s    rj   c          3   C   sp  g  } y! |  d j  r& | j d  n  Wn t k
 r; Yn Xy | | j |  d j   7} Wn t k
 rn Yn Xy | t |  d j   7} Wn t k
 r Yn XyI |  d j  } | d k r | j d  n | d k r | j d	  n  Wn t k
 r Yn Xy$ |  d
 j  r | | j   7} n  Wn t k
 r5Yn Xy! |  d j  rV| d g 7} n  Wn t k
 rkYn X| S)NrW   z-fltorc   rX   r^   r`   z-fprofile-generatera   z-fprofile-userb   rd   z-DNDEBUG)rg   rf   KeyErrorget_colorout_argsri   Zget_coverage_args)optionscompilerrh   pgo_valr<   r<   r=   get_base_compile_args  sB    rp   c          3   C   s  g  } y! |  d j  r& | j d  n  Wn t k
 r; Yn Xy | t |  d j   7} Wn t k
 rk Yn XyI |  d j  } | d k r | j d  n | d k r | j d  n  Wn t k
 r Yn Xy7 | r d	 | j k r |  d	 j  r | j d
  n  Wn t k
 rYn Xy0 d | j k rE|  d j  rE| j d  n  Wn t k
 rZYn Xy$ |  d j  r~| | j   7} n  Wn t k
 rYn X| S)NrW   z-fltorX   r^   r`   z-fprofile-generatera   z-fprofile-user\   z-Wl,--no-undefinedr]   z-Wl,--as-neededrb   )rg   rf   rk   rj   base_optionsget_coverage_link_args)rm   linkeris_shared_modulerh   ro   r<   r<   r=   get_base_link_argsA  sD    #ru   c               @   s   e  Z d  Z d S)CrossNoRunExceptionN)__name__
__module____qualname__r<   r<   r<   r=   rv   f  s   rv   c               @   s%   e  Z d  Z d d d d d  Z d S)	RunResulti  Z	UNDEFINEDc             C   s(   | |  _  | |  _ | |  _ | |  _ d  S)N)compiled
returncodestdoutstderr)selfr{   r|   r}   r~   r<   r<   r=   __init__j  s    			zRunResult.__init__N)rw   rx   ry   r   r<   r<   r<   r=   rz   i  s   rz   c                   s-  e  Z d  Z d Z d1 Z d2 Z f  Z f  Z d3 Z d4 Z	 e
 j d  Z d5 Z d Z d d   Z   f d d   Z e d d    Z e d d    Z d d   Z   f d d   Z   f d d    Z d! d"   Z   f d# d$   Z d% d&   Z d' d(   Z d) d*   Z d+ d,   Z d- d.   Z d/ d0   Z   S)6CompilerArgsa  
    Class derived from list() that manages a list of compiler arguments. Should
    be used while constructing compiler arguments from various sources. Can be
    operated with ordinary lists, so this does not need to be used everywhere.

    All arguments must be inserted and stored in GCC-style (-lfoo, -Idir, etc)
    and can converted to the native type of each compiler by using the
    .to_native() method to which you must pass an instance of the compiler or
    the compiler class.

    New arguments added to this class (either with .append(), .extend(), or +=)
    are added in a way that ensures that they override previous arguments.
    For example:

    >>> a = ['-Lfoo', '-lbar']
    >>> a += ['-Lpho', '-lbaz']
    >>> print(a)
    ['-Lpho', '-Lfoo', '-lbar', '-lbaz']

    Arguments will also be de-duped if they can be de-duped safely.

    Note that because of all this, this class is not commutative and does not
    preserve the order of arguments if it is safe to not. For example:
    >>> ['-Ifoo', '-Ibar'] + ['-Ifez', '-Ibaz', '-Werror']
    ['-Ifez', '-Ibaz', '-Ifoo', '-Ibar', '-Werror']
    >>> ['-Ifez', '-Ibaz', '-Werror'] + ['-Ifoo', '-Ibar']
    ['-Ifoo', '-Ibar', '-Ifez', '-Ibaz', '-Werror']

    -I-L-D-U-l.lib.dll.so.dylib.az6([\/\\]|\A)lib.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$-c-S-E-pipe-pthreadNc             C   s  g  } t  |  d k r' t d   n | s1 | St  |  d k r{ t | d t t f  rl | d |  _ qt d   n t  |  d k rt | d t t f  r | d |  _ | d } qt | d t t f  r | d } | d |  _ qt d   n t d   | S)Nr   z]CompilerArgs() only accepts at most 2 arguments: The compiler, and optionally an initial listr8   r   z9you must pass a Compiler instance as one of the argumentsz=you must pass a Compiler instance as one of the two argumentszNot reached)len	TypeError
isinstanceCompilerr   rn   AssertionError)r   rh   Zcargsr<   r<   r=   _check_args  s&    
zCompilerArgs._check_argsc                s   t    j |  j |   d  S)N)superr   r   )r   rh   )	__class__r<   r=   r     s    zCompilerArgs.__init__c             C   s   | |  j  k r d S| |  j k sF | j |  j   sF | j |  j  rJ d S| |  j k s | j |  j  s | j |  j  s t j	 |  j
 |  r d Sd S)a  
        Returns whether the argument can be safely de-duped. This is dependent
        on three things:

        a) Whether an argument can be 'overriden' by a later argument.  For
           example, -DFOO defines FOO and -UFOO undefines FOO. In this case, we
           can safely remove the previous occurance and add a new one. The same
           is true for include paths and library paths with -I and -L. For
           these we return `2`. See `dedup2_prefixes` and `dedup2_args`.
        b) Arguments that once specified cannot be undone, such as `-c` or
           `-pipe`. New instances of these can be completely skipped. For these
           we return `1`. See `dedup1_prefixes` and `dedup1_args`.
        c) Whether it matters where or how many times on the command-line
           a particular argument is present. This can matter for symbol
           resolution in static or shared libraries, so we cannot de-dup or
           reorder them. For these we return `0`. This is the default.

        In addition to these, we handle library arguments specially.
        With GNU ld, we surround library arguments with -Wl,--start/end-group
        to recursively search for symbols in the libraries. This is not needed
        with other linkers.
        r   r   r8   )dedup2_prefixesdedup2_args
startswithendswithdedup2_suffixesdedup1_argsdedup1_prefixesdedup1_suffixesresearchdedup1_regex)clsargr<   r<   r=   
_can_dedup  s    !zCompilerArgs._can_dedupc             C   s   | j  |  j  r d Sd S)NTF)r   prepend_prefixes)r   r   r<   r<   r=   _should_prepend  s    zCompilerArgs._should_prependc             C   s   t  |  j  r d } xh |  D]` } | j d  rX | j d  rX t j |  rX q n  |  j |  } | d k  r | } q q W| d k r |  j | d d  |  j | d  q n  |  j j |   S)Nr8   z-lz.ar   z-Wl,--end-groupz-Wl,--start-grouprA   )	get_compiler_uses_gnuldrn   r   r   soregexmatchr:   insertunix_args_to_native)r   Zgroup_starteachir<   r<   r=   	to_native  s     zCompilerArgs.to_nativec                s   t    j |  d S)zP
        Append the specified argument without any reordering or de-dup
        N)r   rf   )r   r   )r   r<   r=   append_direct	  s    zCompilerArgs.append_directc                s   t    j |  d S)zn
        Extend using the elements in the specified iterable without any
        reordering or de-dup
        N)r   extend)r   iterable)r   r<   r=   extend_direct  s    zCompilerArgs.extend_directc             C   s    t  |  |  j  } | | 7} | S)N)r   rn   )r   rh   newr<   r<   r=   __add__  s    
zCompilerArgs.__add__c                s?  g  } g  } t  | t  s3 t d j |    n  x | D] } |  j |  } | d k r | |  k s: | | k s: | | k r q: q n  | d k r | |  k r |  j |  n  | | k r | j |  n  | | k r | j |  q n  |  j |  r
| j |  q: | j |  q: W| |  d d  <t   j	 |  |  S)z
        Add two CompilerArgs while taking into account overriding of arguments
        and while preserving the order of arguments as much as possible
        z,can only concatenate list (not "{}") to listr8   r   Nr   )
r   listr   formatr   remover   rf   r   __iadd__)r   rh   preZpostr   Zdedup)r   r<   r=   r     s,    $	zCompilerArgs.__iadd__c             C   s    t  | |  j  } | |  7} | S)N)r   rn   )r   rh   r   r<   r<   r=   __radd__?  s    
zCompilerArgs.__radd__c             C   s   t  d   d  S)Nz!can't multiply compiler arguments)r   )r   rh   r<   r<   r=   __mul__D  s    zCompilerArgs.__mul__c             C   s   t  d   d  S)Nz!can't multiply compiler arguments)r   )r   rh   r<   r<   r=   __imul__G  s    zCompilerArgs.__imul__c             C   s   t  d   d  S)Nz!can't multiply compiler arguments)r   )r   rh   r<   r<   r=   __rmul__J  s    zCompilerArgs.__rmul__c             C   s   |  j  | g  d  S)N)r   )r   r   r<   r<   r=   rf   M  s    zCompilerArgs.appendc             C   s   |  j  |  d  S)N)r   )r   rh   r<   r<   r=   r   P  s    zCompilerArgs.extend)r   r   )r   r   r   r   )r   )r   r   r   r   r   )r   r   r   r   r   )rw   rx   ry   __doc__r   r   r   r   r   r   r   compiler   r   rn   r   r   classmethodr   r   r   r   r   r   r   r   r   r   r   rf   r   r<   r<   )r   r=   r   p  s2   .$r   c               @   s  e  Z d  Z f  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z	 d d   Z
 d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d    Z d! d"   Z d# d$   Z d% d&   Z d' d(   Z d) d*   Z d+ d,   Z d- d.   Z d/ d0   Z e d1 d2    Z d3 d4   Z d5 d6   Z d7 d8   Z  d9 d:   Z! d; d<   Z" d= d>   Z# e$ j% d? d@ dA dB   Z& dC dD   Z' dE dF   Z( dG dH   Z) dI dJ   Z* dK dL   Z+ dM dN   Z, dO dP   Z- dQ dR   Z. d? S)Sr   c             C   s   t  | t  r | g |  _ n' t  | t  r9 | |  _ n t d   t |  d  sg t |  j |  _ n  t |  d  s t	 |  j  |  _
 n  |  j d |  _ | |  _ g  |  _ d  S)NzUnknown argument to Compilerfile_suffixescan_compile_suffixesr   )r   strexelistr   r   rB   lang_suffixeslanguager   setr   default_suffixversionrq   )r   r   r   r<   r<   r=   r   X  s    	zCompiler.__init__c             C   s.   d } | j  |  j j |  j d j |  j   S)Nz<{0}: v{1} `{2}`> )r   r   rw   r   joinr   )r   repr_strr<   r<   r=   __repr__h  s    zCompiler.__repr__c             C   s^   t  | d  r | j } n  t j j |  d j   } | rZ | d d   |  j k rZ d Sd S)Nr?   r8   TF)rB   r?   ospathsplitextrG   r   )r   srcrE   r<   r<   r=   can_compilem  s    zCompiler.can_compilec             C   s   |  j  S)N)id)r   r<   r<   r=   get_idu  s    zCompiler.get_idc             C   s   |  j  S)N)r   )r   r<   r<   r=   get_languagex  s    zCompiler.get_languagec             C   s   |  j  j   S)N)r   
capitalize)r   r<   r<   r=   get_display_language{  s    zCompiler.get_display_languagec             C   s   |  j  S)N)r   )r   r<   r<   r=   get_default_suffix~  s    zCompiler.get_default_suffixc             C   s   |  j  d  d   S)N)r   )r   r<   r<   r=   get_exelist  s    zCompiler.get_exelistc             O   s   t  d |  j   d  S)Nz'%s does not support get_builtin_define.)r   r   )r   rh   kwargsr<   r<   r=   get_builtin_define  s    zCompiler.get_builtin_definec             O   s   t  d |  j   d  S)Nz'%s does not support has_builtin_define.)r   r   )r   rh   r   r<   r<   r=   has_builtin_define  s    zCompiler.has_builtin_definec             C   s   g  S)Nr<   )r   r<   r<   r=   get_always_args  s    zCompiler.get_always_argsc             C   s   g  S)Nr<   )r   r<   r<   r=   get_linker_always_args  s    zCompiler.get_linker_always_argsc             C   s   g  S)z
        Used only on Windows for libraries that need an import library.
        This currently means C, C++, Fortran.
        r<   )r   Z
implibnamer<   r<   r=   gen_import_library_args  s    z Compiler.gen_import_library_argsc             C   s   i  S)Nr<   )r   r<   r<   r=   get_options  s    zCompiler.get_optionsc             C   s   g  S)Nr<   )r   rm   r<   r<   r=   get_option_compile_args  s    z Compiler.get_option_compile_argsc             C   s   g  S)Nr<   )r   rm   r<   r<   r=   get_option_link_args  s    zCompiler.get_option_link_argsc             O   s   t  d |  j     d  S)Nz+Language %s does not support header checks.)r   r   )r   rh   r   r<   r<   r=   
has_header  s    zCompiler.has_headerc             O   s   t  d |  j     d  S)Nz2Language %s does not support header symbol checks.)r   r   )r   rh   r   r<   r<   r=   has_header_symbol  s    zCompiler.has_header_symbolc             O   s   t  d |  j     d  S)Nz,Language %s does not support compile checks.)r   r   )r   rh   r   r<   r<   r=   compiles  s    zCompiler.compilesc             O   s   t  d |  j     d  S)Nz)Language %s does not support link checks.)r   r   )r   rh   r   r<   r<   r=   links  s    zCompiler.linksc             O   s   t  d |  j     d  S)Nz(Language %s does not support run checks.)r   r   )r   rh   r   r<   r<   r=   run  s    zCompiler.runc             O   s   t  d |  j     d  S)Nz+Language %s does not support sizeof checks.)r   r   )r   rh   r   r<   r<   r=   sizeof  s    zCompiler.sizeofc             O   s   t  d |  j     d  S)Nz.Language %s does not support alignment checks.)r   r   )r   rh   r   r<   r<   r=   	alignment  s    zCompiler.alignmentc             O   s   t  d |  j     d  S)Nz-Language %s does not support function checks.)r   r   )r   rh   r   r<   r<   r=   has_function  s    zCompiler.has_functionc             C   s   | d d  S)z7Always returns a copy that can be independently mutatedNr<   )r   rh   r<   r<   r=   r     s    zCompiler.unix_args_to_nativec             O   s   t  d j |  j      d  S)Nz-Language {} does not support library finding.)r   r   r   )r   rh   r   r<   r<   r=   find_library  s    zCompiler.find_libraryc             C   s   g  S)Nr<   )r   r<   r<   r=   get_library_dirs  s    zCompiler.get_library_dirsc             C   s   |  j  | g |  S)N)has_multi_arguments)r   r   envr<   r<   r=   has_argument  s    zCompiler.has_argumentc             C   s   t  d j |  j      d  S)Nz1Language {} does not support has_multi_arguments.)r   r   r   )r   rh   r   r<   r<   r=   r     s    zCompiler.has_multi_argumentsc             C   s   g  } |  j  r | r d | j j k r | j j d } |  j d } | | j | g   7} |  j d } | r | | j | g   7} q q n  | S)N
properties_argsZ
_link_args)is_cross
cross_infoconfigr   get)r   environmentlinkZextra_flagsZpropsZlang_args_keyZlang_link_args_keyr<   r<   r=   get_cross_extra_flags  s    zCompiler.get_cross_extra_flagsc             C   sB   | d k r d  S| d k r% d } n d } t  j j | d |  S)N
preprocessr   exer   zoutput.)r   r   r   )r   dirnamemoderE   r<   r<   r=   _get_compile_output  s    	zCompiler._get_compile_outputNr   c       
      c   s  | d  k r g  } n  yt  j   } t | t  rz t j j | d |  j  } t | d   } | j	 |  Wd  QXn t | t
 j  r | j } n  |  j | |  } t |   } | j |  | | 7} | |  j   7} | d k r | |  j   7} n  | d k r| |  j   7} n | |  j |  7} |  j   | j   } t j d  t j d |  t j d d j |  d	  t j d
 |  t | d | \ }	 |	 _ |	 _ t j d |	 j  t j d |	 j  | |	 _ | |	 _ |	 VWd  QXWn t t f k
 rYn Xd  S)Nz	testfile.wr   r   zRunning compile:zWorking directory: zCommand line: r   
zCode:
cwdzCompiler stdout:
zCompiler stderr:
)tempfileTemporaryDirectoryr   r   r   r   r   r   openwriter   Filer?   r   r   rf   r   Zget_compile_only_argsZget_preprocess_only_argsget_output_argsr   r   r   rQ   r
   stdoZstdeZ
input_nameZoutput_namePermissionErrorOSError)
r   code
extra_argsr   Z
tmpdirnamesrcnameofileoutputcommandspr<   r<   r=   r     sD    	
!		zCompiler.compilec             C   s   g  S)Nr<   )r   	colortyper<   r<   r=   rl     s    zCompiler.get_colorout_argsc             K   s   g  S)Nr<   )r   rel_objr   r<   r<   r=   get_compile_debugfile_args  s    z#Compiler.get_compile_debugfile_argsc             C   s   g  S)Nr<   )r   r  r<   r<   r=   get_link_debugfile_args  s    z Compiler.get_link_debugfile_argsc             C   s   g  S)Nr<   )r   r<   r<   r=   get_std_shared_lib_link_args  s    z%Compiler.get_std_shared_lib_link_argsc             C   s
   |  j    S)N)r  )r   r<   r<   r=   get_std_shared_module_link_args  s    z(Compiler.get_std_shared_module_link_argsc             C   s4   t  | t  r | r g  St d |  j     d  S)Nz4Language %s does not support linking whole archives.)r   r   r   r   )r   rh   r<   r<   r=   get_link_whole_for!  s    zCompiler.get_link_whole_forc             C   s   d  S)Nr<   )r   instruction_setr<   r<   r=   get_instruction_set_args)  s    z!Compiler.get_instruction_set_argsc                sc  | r | r | r g  Sg  } xc | D][ } | | k rA d } n3 t  j j t  j j   |  t  j j   |   } | j |  q& Wd j d d   | D  }	 | d k r |	 d | 7}	 n  t |	  t |  k  rd t |  t |	  }
 |	 s |
 }	 q|	 d |
 }	 n  d |	 g } t |   r_d j   f d d   | D  } | d | g 7} n  | S)	N :c             S   s%   g  |  ] } t  j j d  |   q S)z$ORIGIN)r   r   r   ).0r  r<   r<   r=   
<listcomp>9  s   	 z2Compiler.build_unix_rpath_args.<locals>.<listcomp>Xz-Wl,-rpath,c                s%   g  |  ] } t  j j   |   q Sr<   )r   r   r   )r  r  )	build_dirr<   r=   r  J  s   	 z-Wl,-rpath-link,)r   r   relpathr   rf   r   get_compiler_is_linuxlike)r   r!  from_dirrpath_pathsbuild_rpathinstall_rpathZ
rel_rpathsr  ZrelativepathsZpaddingrh   Zlpathsr<   )r!  r=   build_unix_rpath_args,  s*    	3	"zCompiler.build_unix_rpath_args)/rw   rx   ry   Zignore_libsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
contextlibcontextmanagerr   rl   r  r  r  r  r  r  r)  r<   r<   r<   r=   r   S  sT   ,r   r8      c             C   s   | d  k r d } n
 d | } |  t  t t f k rK d | | | | f g S|  t k r | ra g  Sd t j j | d | d  g St d   d  S)Nr  r@   z-Wl,-soname,%s%s.%s%sz-install_namer   z.dylibzNot implemented yet.)GCC_STANDARD	GCC_MINGW
GCC_CYGWINGCC_OSXr   r   r   RuntimeError)gcc_typeprefix
shlib_namerE   r   	soversionrt   Zsostrr<   r<   r=   get_gcc_soname_args]  s    	
!r6  c             C   sP   t  |  d d   t k sH t  |  d d   t k sH t  |  d d   t k rL d Sd S)Nr2  
clang_typeicc_typeTF)getattrr-  CLANG_STANDARDICC_STANDARD)rn   r<   r<   r=   r#  l  s
    r#  c             C   se   t  |  d d   t t t f k s] t  |  d d   t t f k s] t  |  d d   t t f k ra d Sd S)Nr2  r7  r8  TF)r9  r-  r.  r/  r:  	CLANG_WINr;  ICC_WIN)r   r<   r<   r=   r   s  s
    !r   c             C   s   t  |   r d g Sg  S)zG
    Enable transparent large-file-support for 32-bit UNIX systems
    z-D_FILE_OFFSET_BITS=64)r#  )rn   r<   r<   r=   get_largefile_args|  s    r>  c                   s   e  Z d  Z d d   Z d d   Z   f d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d    Z   S)!GnuCompilerc             C   s   d |  _  | |  _ | p i  |  _ d d d d d d d d	 g |  _ |  j t k rt |  j j d
  |  j j d  n  |  j j d  d  S)NgccrV   rW   r^   rX   rb   rc   rd   re   r\   r]   r7   )r   r2  definesrq   r0  rf   r   add)r   r2  rA  r<   r<   r=   r     s    		zGnuCompiler.__init__c             C   s+   t  j |  j d  r' t | d  d   Sg  S)Nz>=4.9.0)r   r	   r   gnu_color_args)r   r  r<   r<   r=   rl     s    zGnuCompiler.get_colorout_argsc                sM   t    j |  } t j |  j d  rI d | k rI d | | j d  <n  | S)Nz<4.8.0z
-Wpedanticz	-pedantic)r   get_warn_argsr   r	   r   r:   )r   levelrh   )r   r<   r=   rD    s    !zGnuCompiler.get_warn_argsc             C   s   | |  j  k S)N)rA  )r   definer<   r<   r=   r     s    zGnuCompiler.has_builtin_definec             C   s   | |  j  k r |  j  | Sd  S)N)rA  )r   rF  r<   r<   r=   r     s    zGnuCompiler.get_builtin_definec             C   s#   |  j  t t t f k r g  Sd g S)Nz-fPIC)r2  r/  r.  r0  )r   r<   r<   r=   get_pic_args  s    zGnuCompiler.get_pic_argsc             C   s   t  | S)N)gnulike_buildtype_args)r   	buildtyper<   r<   r=   get_buildtype_args  s    zGnuCompiler.get_buildtype_argsc             C   s   |  j  t k r t | St | S)N)r2  r0  apple_buildtype_linker_argsgnulike_buildtype_linker_args)r   rI  r<   r<   r=   get_buildtype_linker_args  s    z%GnuCompiler.get_buildtype_linker_argsc             C   s   d S)NZgchr<   )r   r<   r<   r=   get_pch_suffix  s    zGnuCompiler.get_pch_suffixc             C   s   t  j j |  d | f S)Nr   )r   r   rC   )r   r?   r<   r<   r=   split_shlib_to_parts  s    z GnuCompiler.split_shlib_to_partsc             C   s   t  |  j | | | | | |  S)N)r6  r2  )r   r3  r4  rE   r   r5  rt   r<   r<   r=   get_soname_args  s    zGnuCompiler.get_soname_argsc             C   s   d g S)Nz-sharedr<   )r   r<   r<   r=   r    s    z(GnuCompiler.get_std_shared_lib_link_argsc             C   s   d g | d g S)Nz-Wl,--whole-archivez-Wl,--no-whole-archiver<   )r   rh   r<   r<   r=   r    s    zGnuCompiler.get_link_whole_forc             C   s>   t  | t  s t d   n  |  j t t f k r: | g Sg  S)Nz%Module definitions file should be str)r   r   r1  r2  r/  r.  )r   Zdefsfiler<   r<   r=   gen_vs_module_defs_args  s
    z#GnuCompiler.gen_vs_module_defs_argsc             C   s    |  j  t t f k r d g Sg  S)Nz	-mwindows)r2  r/  r.  )r   r<   r<   r=   get_gui_app_args  s    zGnuCompiler.get_gui_app_argsc             C   s   t  j | d   S)N)gnulike_instruction_set_argsr   )r   r  r<   r<   r=   r    s    z$GnuCompiler.get_instruction_set_args)rw   rx   ry   r   rl   rD  r   r   rG  rJ  rM  rN  rO  rP  r  r  rQ  rR  r  r<   r<   )r   r=   r?    s    
r?  c                   s   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
   f d d   Z d d   f d d  Z d d   Z d d   Z d d   Z   S)ClangCompilerc             C   s   d |  _  | |  _ d d d d d d d d	 g |  _ |  j t k re |  j j d
  |  j j d  n  |  j j d d g  d  S)NclangrV   rW   r^   rX   rb   rd   re   rc   r\   r]   r6   r7   )r   r7  rq   	CLANG_OSXrf   r   update)r   r7  r<   r<   r=   r     s    		zClangCompiler.__init__c             C   s    |  j  t t f k r g  Sd g S)Nz-fPIC)r7  r<  rV  )r   r<   r<   r=   rG    s    zClangCompiler.get_pic_argsc             C   s   t  | d  d   S)N)clang_color_args)r   r  r<   r<   r=   rl     s    zClangCompiler.get_colorout_argsc             C   s   t  | S)N)rH  )r   rI  r<   r<   r=   rJ    s    z ClangCompiler.get_buildtype_argsc             C   s   |  j  t k r t | St | S)N)r7  rV  rK  rL  )r   rI  r<   r<   r=   rM    s    z'ClangCompiler.get_buildtype_linker_argsc             C   s   d S)NZpchr<   )r   r<   r<   r=   rN    s    zClangCompiler.get_pch_suffixc             C   s"   d t  j j | |  j |   g S)Nz-include-pch)r   r   r   get_pch_name)r   pch_dirheaderr<   r<   r=   get_pch_use_args  s    zClangCompiler.get_pch_use_argsc             C   sp   |  j  t k r t } n< |  j  t k r0 t } n$ |  j  t k rH t } n t d   t | | | | | | |  S)Nz8Unreachable code when converting clang type to gcc type.)	r7  r:  r-  rV  r0  r<  r.  r   r6  )r   r3  r4  rE   r   r5  rt   r2  r<   r<   r=   rP    s    			zClangCompiler.get_soname_argsc                sH   d d g } t  j |  j d  r1 | j d  n  t   j | | |  S)Nz-Werror=unknown-warning-optionz$-Werror=unused-command-line-argumentz>=3.6.0z%-Werror=ignored-optimization-argument)r   r	   r   rf   r   r   )r   rh   r   Zmyargs)r   r<   r=   r     s    	z!ClangCompiler.has_multi_argumentsNc                sb   | d  k r g  } n  |  j  t k rF t |  j d  rF | j d  n  t   j | | | | |  S)Nz>=8.0z-Wl,-no_weak_imports)r7  rV  r	   r   rf   r   r   )r   Zfuncnamer3  r   r  Zdependencies)r   r<   r=   r     s
    	!zClangCompiler.has_functionc             C   s    |  j  t k r d d g Sd g S)Nz-bundlez-Wl,-undefined,dynamic_lookupz-shared)r7  rV  )r   r<   r<   r=   r  &  s    
z-ClangCompiler.get_std_shared_module_link_argsc             C   sL   |  j  t k r: g  } x | D] } | d | g 7} q W| Sd g | d g S)Nz-Wl,-force_loadz-Wl,--whole-archivez-Wl,--no-whole-archive)r7  rV  )r   rh   resultr   r<   r<   r=   r  +  s    z ClangCompiler.get_link_whole_forc             C   s   t  j | d   S)N)rS  r   )r   r  r<   r<   r=   r  3  s    z&ClangCompiler.get_instruction_set_args)rw   rx   ry   r   rG  rl   rJ  rM  rN  r\  rP  r   r   r  r  r  r<   r<   )r   r=   rT    s   rT  c               @   s   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d d   Z d d   Z d S)IntelCompilerc          
   C   sV   d |  _  | |  _ d |  _ d d d d d d d	 d
 d d g
 |  _ |  j j d  d  S)NZintelrY   rV   rW   r^   rX   rb   rc   rd   re   r\   r]   r7   )r   r8  lang_headerrq   r   rB  )r   r8  r<   r<   r=   r   9  s    			zIntelCompiler.__init__c             C   s   d g S)Nz-fPICr<   )r   r<   r<   r=   rG  B  s    zIntelCompiler.get_pic_argsc             C   s   t  | S)N)rH  )r   rI  r<   r<   r=   rJ  E  s    z IntelCompiler.get_buildtype_argsc             C   s   t  | S)N)rL  )r   rI  r<   r<   r=   rM  H  s    z'IntelCompiler.get_buildtype_linker_argsc             C   s   d S)NZpchir<   )r   r<   r<   r=   rN  K  s    zIntelCompiler.get_pch_suffixc          	   C   s.   d d t  j j |  d |  j d | d d g	 S)Nz-pchz-pch_dirz-xz-includerY   )r   r   r   r_  )r   rZ  r[  r<   r<   r=   r\  N  s    zIntelCompiler.get_pch_use_argsc             C   s"   t  j j |  d d |  j   S)Nr8   r@   rA   )r   r   rC   rN  )r   Zheader_namer<   r<   r=   rY  R  s    zIntelCompiler.get_pch_namec             C   s   t  j j |  d | f S)Nr   )r   r   rC   )r   r?   r<   r<   r=   rO  U  s    z"IntelCompiler.split_shlib_to_partsc             C   sp   |  j  t k r t } n< |  j  t k r0 t } n$ |  j  t k rH t } n t d   t | | | | | | |  S)Nz6Unreachable code when converting icc type to gcc type.)	r8  r;  r-  ICC_OSXr0  r=  r.  r   r6  )r   r3  r4  rE   r   r5  rt   r2  r<   r<   r=   rP  X  s    			zIntelCompiler.get_soname_argsc             C   s   d g S)Nz-sharedr<   )r   r<   r<   r=   r  c  s    z*IntelCompiler.get_std_shared_lib_link_argsN)rw   rx   ry   r   rG  rJ  rM  rN  r\  rY  rO  rP  r  r<   r<   r<   r=   r^  8  s   	r^  )	r   hhr   r   r   r   r   r   r   )r   zobjzres)r   zlibzdllr   zso)r   )cppzccr   r    ra  r   r   r   )zf90zf95r#   r$   r%   zforr'   r(   )r*   r   )r+   )zmm)r/   )zvalar   r2   )zcs)zswift)zjava)r   )r   )zobjcppzobjcr*   rb  r   zfortran)r   zllr7   )Qr*  os.pathr   r   r  linkersr   r  r   r   r   r   r   r	   r
   rD   rL   rN   r   cpp_suffixes
c_suffixesr9   rH   Z_lr   r   r>   rF   rI   rJ   rK   rM   rO   rH  Zmsvc_buildtype_argsrK  rL  Zmsvc_buildtype_linker_argsZjava_buildtype_argsZrust_buildtype_argsZd_gdc_buildtype_argsZd_ldc_buildtype_argsZd_dmd_buildtype_argsZmono_buildtype_argsZswift_buildtype_argsZgnu_winlibsZmsvc_winlibsrC  rX  UserBooleanOptionUserComboOptionrq   rS  Zvs32_instruction_set_argsZvs64_instruction_set_argsri   rj   rp   ru   rv   rz   r   r   r   r-  r0  r.  r/  r:  rV  r<  r;  r`  r=  r6  r#  r   r>  r?  rT  r^  r<   r<   r<   r=   <module>   sn  0"































	
	

	

	
	
























$%	QU