
Y.                @   s  d  d l  Z  d  d l Z d  d l Z d  d l m 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 m Z d d l
 m Z m Z m Z m Z d d	 l
 m Z m Z d d
 l m Z m Z m Z d d l m Z m Z m Z m Z i! d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d d! 6d d" 6d d# 6d d$ 6d d% 6d d& 6d d' 6d d( 6d d) 6d d* 6d d+ 6d d, 6d d- 6Z e j    Z e j i	 d d. 6d d/ 6d d0 6d d1 6d d2 6d d3 6d d4 6d d5 6d d6 6 e j    Z e j i d d7 6 Gd8 d9   d9 e  Z Gd: d;   d;  Z  Gd< d=   d=  Z! Gd> d?   d?  Z" Gd@ dA   dA  Z# GdB dC   dC  Z$ GdD dE   dE e$  Z% GdF dG   dG  Z& GdH dI   dI  Z' GdJ dK   dK e%  Z( GdL dM   dM e%  Z) GdN dO   dO e%  Z* GdP dQ   dQ e*  Z+ GdR dS   dS e$  Z, GdT dU   dU e$  Z- GdV dW   dW e%  Z. GdX dY   dY  Z/ GdZ d[   d[  Z0 Gd\ d]   d]  Z1 Gd^ d_   d_ e2  Z3 Gd` da   da  Z4 db dc   Z5 d S)d    N)OrderedDict   )environment)dependencies)mlog)FileMesonException)flattentypeslistifystringlistifyclassify_unity_sources)get_filenames_templates_dictsubstitute_values)for_windows
for_darwin
for_cygwin)	is_objectclike_langs
sort_clikelang_suffixesTinstallc_pchcpp_pchc_args	objc_argsobjcpp_argscpp_argscs_args	vala_argsfortran_argsd_args	java_args	rust_args	link_argslink_depends	link_with
link_wholeimplicit_include_directoriesinclude_directoriesr   install_dir
main_classname_suffixgui_appextra_filesinstall_rpathbuild_rpath	resourcessourcesobjectsnativebuild_by_defaultoverride_optionsversion	soversionname_prefixvs_module_defsvala_header	vala_vapivala_girpicrust_crate_typeimplibc               @   s   e  Z d  Z d S)InvalidArgumentsN)__name__
__module____qualname__ rD   rD   L/mnt/raid6/a/bak/reczko/tools/protein/utils/meson-0.42.1/mesonbuild/build.pyr@   T   s   r@   c               @   s   e  Z d  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 d   Z d d   Z d d   Z d d   Z d d   Z d  S)!BuildzYA class that holds the status of one build including
    all dependencies and so on.
    c             C   s   d |  _  d  |  _ | |  _ i  |  _ t   |  _ t   |  _ t   |  _ i  |  _ i  |  _	 i  |  _
 i  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ d  |  _ d  |  _ i  |  _ g  |  _ g  |  _ g  |  _ d  |  _ i  |  _ i  |  _ i  |  _ d  S)Nzname of master project)project_nameproject_versionr   projectsr   targets	compilerscross_compilersglobal_argsprojects_argsglobal_link_argsprojects_link_argstests
benchmarksheadersmandatastatic_linkerstatic_cross_linkersubprojectsinstall_scriptspostconf_scriptsinstall_dirsdep_manifest_namedep_manifestcross_stdlibstest_setups)selfr   rD   rD   rE   __init__\   s4    																						zBuild.__init__c             C   sb   |  j  d  k r3 | j   r3 |  j j |  |  _  n  | j   } | |  j k r^ | |  j | <n  d  S)N)rV   needs_static_linkerr   detect_static_linkerget_languagerK   )r`   compilerlangrD   rD   rE   add_compilerx   s
    zBuild.add_compilerc             C   sP   |  j  s! |  j j |  |  _ n  | j   } | |  j  k rL | |  j  | <n  d  S)N)rL   r   rc   rW   rd   )r`   re   rf   rD   rD   rE   add_cross_compiler   s
    	zBuild.add_cross_compilerc             C   s   |  j  d S)N )rI   )r`   rD   rD   rE   get_project   s    zBuild.get_projectc             C   s   |  j  S)N)rJ   )r`   rD   rD   rE   get_targets   s    zBuild.get_targetsc             C   s   |  j  S)N)rQ   )r`   rD   rD   rE   	get_tests   s    zBuild.get_testsc             C   s   |  j  S)N)rR   )r`   rD   rD   rE   get_benchmarks   s    zBuild.get_benchmarksc             C   s   |  j  S)N)rS   )r`   rD   rD   rE   get_headers   s    zBuild.get_headersc             C   s   |  j  S)N)rT   )r`   rD   rD   rE   get_man   s    zBuild.get_manc             C   s   |  j  S)N)rU   )r`   rD   rD   rE   get_data   s    zBuild.get_datac             C   s   |  j  S)N)r[   )r`   rD   rD   rE   get_install_subdirs   s    zBuild.get_install_subdirsc             C   s   |  j  j | j   g   S)N)rM   getrd   )r`   re   rD   rD   rE   get_global_args   s    zBuild.get_global_argsc             C   s2   |  j  j |  } | s g  S| j | j   g   S)N)rN   rr   rd   )r`   re   projectargsrD   rD   rE   get_project_args   s    zBuild.get_project_argsc             C   s   |  j  j | j   g   S)N)rO   rr   rd   )r`   re   rD   rD   rE   get_global_link_args   s    zBuild.get_global_link_argsc             C   s2   |  j  j |  } | s g  S| j | j   g   S)N)rP   rr   rd   )r`   re   rt   r#   rD   rD   rE   get_project_link_args   s    zBuild.get_project_link_argsN)rA   rB   rC   __doc__ra   rg   rh   rj   rk   rl   rm   rn   ro   rp   rq   rs   rv   rw   rx   rD   rD   rD   rE   rF   W   s    rF   c               @   sO   e  Z d  Z d d d  Z d d   Z d d   Z d d	   Z d
 d   Z d S)IncludeDirsNc             C   s@   | |  _  | |  _ | |  _ | d  k r3 g  |  _ n	 | |  _ d  S)N)curdirincdirs	is_systemextra_build_dirs)r`   r{   dirsr}   r~   rD   rD   rE   ra      s    			zIncludeDirs.__init__c             C   s%   d } | j  |  j j |  j |  j  S)Nz
<{} {}/{}>)format	__class__rA   r{   r|   )r`   rrD   rD   rE   __repr__   s    zIncludeDirs.__repr__c             C   s   |  j  S)N)r{   )r`   rD   rD   rE   
get_curdir   s    zIncludeDirs.get_curdirc             C   s   |  j  S)N)r|   )r`   rD   rD   rE   get_incdirs   s    zIncludeDirs.get_incdirsc             C   s   |  j  S)N)r~   )r`   rD   rD   rE   get_extra_build_dirs   s    z IncludeDirs.get_extra_build_dirs)rA   rB   rC   ra   r   r   r   r   rD   rD   rD   rE   rz      s
   rz   c               @   s:   e  Z d  Z d Z d d   Z d d   Z d d   Z d S)	ExtractedObjectszI
    Holds a list of sources for which the objects must be extracted
    c             C   s)   | |  _  | |  _ | r% |  j   n  d  S)N)targetsrclistcheck_unity_compatible)r`   r   r   is_unityrD   rD   rE   ra      s    		zExtractedObjects.__init__c             C   s(   d } | j  |  j j |  j j |  j  S)Nz<{0} {1!r}: {2}>)r   r   rA   r   namer   )r`   r   rD   rD   rE   r      s    zExtractedObjects.__repr__c             C   s   t  |  j  } | t  |  j j  k r+ d  St |  j j j   |  j j  } x* | j   D] } | t  |  k rY d  SqY Wd } t |   d  S)NzlSingle object files can not be extracted in Unity builds. You can only extract all the object files at once.)setr   r   r1   r   rK   valuesr   )r`   Zsrclist_setZcompsrcsZsrcsmsgrD   rD   rE   r      s    z'ExtractedObjects.check_unity_compatibleN)rA   rB   rC   ry   ra   r   r   rD   rD   rD   rE   r      s   r   c               @   sd   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 S)EnvironmentVariablesc             C   s   g  |  _  d  S)N)envvars)r`   rD   rD   rE   ra      s    zEnvironmentVariables.__init__c             C   s   d } | j  |  j j |  j  S)Nz
<{0}: {1}>)r   r   rA   r   )r`   repr_strrD   rD   rE   r      s    zEnvironmentVariables.__repr__c             C   sM   | j  d t j  } d } x | D] } | | | 7} q" W| | j |  f S)N	separatorri   )rr   ospathsepstrip)r`   r   kwargsr   valuevarrD   rD   rE   	get_value   s
    zEnvironmentVariables.get_valuec             C   s   |  j  | |  d S)Nr   )r   )r`   envr   r   r   rD   rD   rE   r      s    zEnvironmentVariables.setc             C   s8   |  j  | |  \ } } | | k r4 | | | | S| S)N)r   )r`   r   r   r   r   sepr   rD   rD   rE   append  s    zEnvironmentVariables.appendc             C   s8   |  j  | |  \ } } | | k r4 | | | | S| S)N)r   )r`   r   r   r   r   r   r   rD   rD   rE   prepend	  s    zEnvironmentVariables.prependc             C   sC   i  } x6 |  j  D]+ \ } } } } | | | | |  | | <q W| S)N)r   )r`   Zfull_envr   methodr   r   r   rD   rD   rE   get_env  s    zEnvironmentVariables.get_envN)
rA   rB   rC   ra   r   r   r   r   r   r   rD   rD   rD   rE   r      s   r   c               @   sL   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d S)Targetc             C   sf   d | k s d | k r, t  j d |  n  | |  _ | |  _ | |  _ d |  _ d |  _ i  |  _ d  S)N/\zTarget "%s" has a path separator in its name.
This is not supported, it can cause unexpected failures and will become
a hard error in the future.F)r   warningr   subdirr4   r   build_alwaysoption_overrides)r`   r   r   r4   rD   rD   rE   ra     s    					zTarget.__init__c             C   s   |  j  S)N)r   )r`   rD   rD   rE   get_basename$  s    zTarget.get_basenamec             C   s   |  j  S)N)r   )r`   rD   rD   rE   
get_subdir'  s    zTarget.get_subdirc             C   sS   d | k r= | d |  _  t |  j  t  s= t d   q= n  |  j |  |  _ d  S)Nr4   z)build_by_default must be a boolean value.)r4   
isinstanceboolr@   parse_overridesr   )r`   r   rD   rD   rE   process_kwargs*  s
    zTarget.process_kwargsc             C   s   i  } t  | j d g    } xc | D][ } d | k rF t d   n  | j d d  \ } } | j   } | j   } | | | <q% W| S)Nr5   =z%Overrides must be of form "key=value"r   )r   rr   r@   splitr   )r`   r   resultZ	overridesokvrD   rD   rE   r   1  s    zTarget.parse_overridesN)rA   rB   rC   ra   r   r   r   r   rD   rD   rD   rE   r     s
   r   c                   sJ  e  Z 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 e 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   f d+ d,   Z d- d.   Z d/ d0   Z d1 d2   Z d3 d4   Z d5 d6   Z d7 d8   Z d9 d:   Z  d; d<   Z! d= d>   Z" d? d@   Z# 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, dS dT   Z- dU dV   Z. dW dX   Z/ dY dZ   Z0 d[ d\   Z1   S)]BuildTargetc	       
         s  t    j | | d  | |  _ | |  _ | j j d  }	 |	 d k p[ |	 d k o[ | d k |  _ | |  _ g  |  _ t	   |  _
 g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ d |  _ d |  _ d |  _ |  j g |  _ d |  _ i  |  _ i  |  _ g  |  _ g  |  _ |  j |  |  j |  |  j | |  |  j |  |  j rt|  j rt|  j rtt d |   n  |  j   |  j    |  j! |  d  S)	NTunityonrX   ri   FZno_namezBuild target %s has no sources.)"superra   
subprojectis_crosscoredataget_builtin_optionr   r   r1   r   rK   r2   external_depsinclude_dirslink_targetslink_whole_targetsr$   name_prefix_setname_suffix_setfilenameoutputsneed_installpch
extra_args	generatedr-   process_sourcelistprocess_objectlistr   check_unknown_kwargsr@   process_compilersvalidate_sourcesvalidate_cross_install)
r`   r   r   r   r   r1   r2   r   r   Z	unity_opt)r   rD   rE   ra   ?  s@    		'																

zBuildTarget.__init__c             C   s   |  j    | j    k  S)N)get_id)r`   otherrD   rD   rE   __lt__j  s    zBuildTarget.__lt__c             C   s(   d } | j  |  j j |  j   |  j  S)Nz<{0} {1}: {2}>)r   r   rA   r   r   )r`   r   rD   rD   rE   r   m  s    zBuildTarget.__repr__c             C   s2   | j    r. |  j r. |  j r. t d   n  d  S)Nz:Tried to install a natively built target in a cross build.)is_cross_buildr   r   r@   )r`   r   rD   rD   rE   r   q  s    z"BuildTarget.validate_cross_installc             C   s5   |  j  |  j   } |  j d k r& | S|  j d | S)Nri   z@@)r   type_suffixr   )r`   baserD   rD   rE   r   u  s    zBuildTarget.get_idc             C   s   |  j  | t  d  S)N)check_unknown_kwargs_intknown_basic_kwargs)r`   r   rD   rD   rE   r   ~  s    z BuildTarget.check_unknown_kwargsc             C   so   g  } x* | D]" } | | k r | j  |  q q Wt |  d k rk t j d |  j d j |  f  n  d  S)Nr   z-Unknown keyword argument(s) in target %s: %s.z, )r   lenr   r   r   join)r`   r   known_kwargsunknownsr   rD   rD   rE   r     s    	z$BuildTarget.check_unknown_kwargs_intc             C   s   t  | t  s t  x | D] } t | d  r= | j } n  t  | t t t f  rh |  j j	 |  q t  | t
 t f  r d d j |  j  d d } t |   q d j t |  j |  j  } t |   q Wd  S)Nheld_objectz7Generated files are not allowed in the 'objects' kwarg z&for target {!r}.
It is meant only for z8pre-built object files that are shipped with the
source z+tree. Try adding it in the list of sources.z'Bad object of type {!r} in target {!r}.)r   listAssertionErrorhasattrr   strr   r   r2   r   GeneratedListCustomTargetr   r   r@   typerA   )r`   r2   sr   rD   rD   rE   r     s    zBuildTarget.process_objectlistc             C   s   t  | t  s | g } n  i  } x | D] } t | d  rI | j } n  t  | t  r | | k r |  j j |  d | | <q q( t  | t t f  r |  j	 j |  q( d j
 t |  j |  j  } t |   q( Wd  S)Nr   Tz'Bad source of type {!r} in target {!r}.)r   r   r   r   r   r1   r   r   r   r   r   r   rA   r   r@   )r`   r1   Zadded_sourcesr   r   rD   rD   rE   r     s    zBuildTarget.process_sourcelistc             C   sJ   d } x= | d  d   D]+ } |  j  |  r | j |  d } q q W| S)NFT)can_compileremove)re   r1   Zremovedr   rD   rD   rE   can_compile_remove_sources  s    z&BuildTarget.can_compile_remove_sourcesc             C   s  |  j  r" |  j r" |  j r" d S|  j r= |  j j j } n |  j j j } t |  j   } xD |  j D]9 } x0 | j	   D]" } t
 |  sx | j |  qx qx Wqe Wx] |  j D]R } t | t  s q n  x4 | j D]) } | j t d  s | j |  q q Wq W| rx] | D]U } xL | j   D]> \ } } | j |  r"| |  j k r\| |  j | <n  Pq"q"WqWt t |  j j   d d d    |  _ n2 x/ t D]' } | | k r| | |  j | <PqqWd |  j k rd |  j k r| d |  j d <n  d S)z
        Populate self.compilers, which is the list of compilers that this
        target will use for compiling all its sources.
        We also add compilers that were used by extracted objects to simplify
        dynamic linker determination.
        Nvalakeyc             S   s   t  |  d  S)Nr   )r   )trD   rD   rE   <lambda>  s    z/BuildTarget.process_compilers.<locals>.<lambda>c)r1   r   r2   r   r   r   rL   rK   r   get_outputsr   r   r   r   r   endswithr   itemsr   r   sortedr   )r`   rK   r1   Zgensrcr   r   rf   re   rD   rD   rE   r     s>    	zBuildTarget.process_compilersc             C   s   |  j  s d  Sx d	 D] } | |  j k r t |  j   } |  j | } |  j | |  s{ d j | |  j  } t |   n  | r d j | j    } | d j d d   | D  7} t |   n  t	 |  j  d k s t
  d  Sq Wd  S)
Ncsjavaz"No {} sources found in target {!r}z({0} targets can only contain {0} files:

c             S   s   g  |  ] } t  |   q SrD   )repr).0r   rD   rD   rE   
<listcomp>  s   	 z0BuildTarget.validate_sources.<locals>.<listcomp>r   )zcszjava)r1   rK   r   r   r   r   r@   
capitalizer   r   r   )r`   rf   Zcheck_sourcesre   mrD   rD   rE   r     s    	 zBuildTarget.validate_sourcesc                s   t  | t  s | g } n  x | D]   t   d  rC   j   n  t    t  re |  j j    q" t    t  r |  j j t j | j	 |  j
     q" t   d  r |  j j   f d d     j   D  q" t d   q" Wd S)a}  Process the link_depends keyword argument.

        This is designed to handle strings, Files, and the output of Custom
        Targets. Notably it doesn't handle generator() returned objects, since
        adding them as a link depends would inherently cause them to be
        generated twice, since the output needs to be passed to the ld_args and
        link_depends.
        r   r   c                s%   g  |  ] } t  j   j |   q SrD   )r   from_built_filer   )r   p)r   rD   rE   r     s   	 z4BuildTarget.process_link_depends.<locals>.<listcomp>zTLink_depends arguments must be strings, Files, or a Custom Target, or lists thereof.N)r   r   r   r   r   r$   r   r   from_source_file
source_dirr   extendr   r@   )r`   r1   r   rD   )r   rE   process_link_depends  s    			#z BuildTarget.process_link_dependsc             C   s   |  j  S)N)r   )r`   rD   rD   rE   get_original_kwargs#  s    zBuildTarget.get_original_kwargsc          	   C   s   t  | t  s | g } n  g  } x | D] } t  | t  rO |  j |  } n t | d  rj | j } n  xN d d d d g D]: } t | |  r} t | | |  j t | |    q} q} W| j |  q( W| S)Nr   r   r%   r(   r1   )r   r   unpack_holderr   r   setattrgetattrr   )r`   dZnewdir   rD   rD   rE   r   &  s    )zBuildTarget.unpack_holderc             C   s   t  j  |  |  _ xg |  j j   D]V \ } } t | t  rV |  j |  |  j | <n  t | d  r" | j |  j | <q" q" WxI d d d d g D]5 } | |  j k r |  j |  j |  |  j | <q q Wd  S)Nr   r   r%   r(   r1   )copyr   r   r   r   r   r   r   )r`   r   r   r   r   rD   rD   rE   copy_kwargs5  s    zBuildTarget.copy_kwargsc             C   s   g  } xp | D]h } t  | t  s1 t d   n  t d |  j |  } | |  j k rh t d |   n  | j |  q Wt |  | |  j  S)Nz,Object extraction arguments must be strings.Fz#Tried to extract unknown source %s.)	r   r   r   r   r   r1   r   r   r   )r`   r   Zobj_srcsrcrD   rD   rE   extract_objectsC  s    zBuildTarget.extract_objectsc             C   s   t  |  |  j |  j  S)N)r   r1   r   )r`   rD   rD   rE   extract_all_objectsN  s    zBuildTarget.extract_all_objectsc             C   s
   |  j    S)N)get_transitive_link_deps)r`   rD   rD   rE   get_all_link_depsQ  s    zBuildTarget.get_all_link_depsc             C   s.   g  } x! |  j  D] } | | j   7} q W| S)N)r   r	  )r`   r   r  rD   rD   rE   r  T  s    z$BuildTarget.get_transitive_link_depsc             C   s   |  j  S)N)r)   )r`   rD   rD   rE   get_custom_install_dirZ  s    z"BuildTarget.get_custom_install_dirc                sn	  t    j |  |  j |  | j d g   | j d |  j  |  _ | j d g   } t | t  sr | g } n  x6 | D]. } t | d  r | j } n  |  j	 |  qy W| j d g   } t | t  s | g } n  x6 | D]. } t | d  r | j } n  |  j
 |  q W| j d g   } t | t  s>| g } n  |  j d |  | j d g   } t | t  s{| g } n  |  j d	 |  | j d
 g   } t | t  s| g } n  |  j d |  | j d g   }	 t |	 t  s|	 g }	 n  |  j d	 |	  | j d g   }
 t |
 t  s2|
 g }
 n  |  j d |
  | j d g   } t | t  so| g } n  |  j d |  | j d g   } t | t  s| g } n  |  j d |  | j d g   } t | t  s| g } n  |  j d |  | j d g   } t | t  s&| g } n  |  j d |  | j d g   } t | t  sc| g } n  |  j d |  t |  t  s| j d |  j d  |  _ | j d |  j d  |  _ | j d d   |  _ n  t | j d g    } |  j d |  t | j d g    |  _ x/ |  j D]$ } t | t  st d    qqWx< |  j D]1 } d! | k sr| j d"  rQt j d#  qQqQW|  j | j d$ g   |  | j d% g   } t | t  s| g } n  |  j |  | j d& g   } t | t  s	| g } n  |  j |  t | j d' d  g  t t f  |  _ | j d( d)  } t | t  smt d*   n  | |  _  t |  t  r| j d+ d,  |  _! t |  j! t  st d-   qn d+ | k rt d.   n  | j d/ g   } t | t  s| g } n  xl | D]d } t | t"  s(t#  t$ j% j& | j'   | j( | j)  } t$ j% j* |  st d0 |   qqW| |  _+ | j d1 d)  |  _, t |  j, t  st d2   n  | j d3 d)  |  _- t |  j- t  st d4   n  | j d5 g   } t | t  s| g } n  xr | D]j } t | t  sBt d6   n  t$ j% j& | j'   |  j( |  } t$ j% j* |  st d7 |   qqW| |  _. d8 | k r| d8 } t | t  r| rt d9   qn t | t  st d:   n  | |  _/ d; |  _0 n  d< | k ru| d< } t | t  rB| rrt d=   qrqut | t  s`t d>   n  | |  _1 d; |  _2 n  t |  t3  r4	t4 |  j5 |  j6  st7 |  j5 |  j6  rd; |  _8 q4	d? | |	 k rt j d@ j9 |  j   d; |  _8 q4	| j dA d,  |  _8 t |  j8 t  s4	t dB j9 |  j    q4	n  | j dC d;  |  _: t |  j: t  sj	t dD   n  d  S)ENmodulesr   r%   r   r&   r   r   r   cppr   r   r   r   r   r   r   objcr   objcppr   fortranr"   rustr:   z.hr;   z.vapir<   r    r  r#   z$Link_args arguments must be strings.z
-Wl,-rpathz-rpathzPlease do not define rpath with a linker argument, use install_rpath or build_rpath properties instead.
This will become a hard error in a future Meson release.r$   r(   r   r)   r*   ri   zMain class must be a stringr,   Fz!Argument gui_app must be boolean.z1Argument gui_app can only be used on executables.r-   z(Tried to add non-existing extra file %s.r.   zInstall_rpath is not a string.r/   zBuild_rpath is not a string.r0   z"Resource argument is not a string.z&Tried to add non-existing resource %s.r8   z0name_prefix array must be empty to signify null.zname_prefix must be a string.Tr+   z0name_suffix array must be empty to signify null.zname_suffix must be a string.z-fPICzLUse the 'pic' kwarg instead of passing -fPIC manually to static library {!r}r=   z3Argument pic to static library {!r} must be booleanr'   z/Implicit_include_directories must be a boolean.);r   r   r  rr   r   r   r   r   r   linkr&   add_pchadd_compiler_args
Executabler   r:   r;   r<   r   r	   r#   r   r@   
startswithr   r   r   add_include_dirsadd_depsr
   r   r)   r*   r,   r   r   r   pathr   get_source_dirr   fnameisfiler-   r.   r/   r0   prefixr   suffixr   StaticLibraryr   r   r   r   r=   r   r'   )r`   r   r   ZllistZ
linktargetZlwholeZ	c_pchlistZcpp_pchlistclistZcpplistZcslistZvalalistZobjclistZ
objcpplistZfortranlistZrustlistZdlistr  lZinclistZdeplistr*   r-   trialr0   r   r8   r+   )r   rD   rE   r   ]  s(   	$	!	
	
	*zBuildTarget.process_kwargsc             C   s   |  j  S)N)r   )r`   rD   rD   rE   get_filename  s    zBuildTarget.get_filenamec             C   s   |  j  S)N)r   )r`   rD   rD   rE   r     s    zBuildTarget.get_outputsc             C   s   |  j  j | g   S)N)r   rr   )r`   languagerD   rD   rE   get_extra_args  s    zBuildTarget.get_extra_argsc             C   sT   g  } xG |  j  |  j D]5 } | j |  t | t  r | | j   7} q q W| S)N)r   r   r   r   r  get_dependencies)r`   Ztransitive_depsr   rD   rD   rE   r%  
  s    zBuildTarget.get_dependenciesc             C   s   |  j  S)N)r   )r`   rD   rD   rE   get_source_subdir  s    zBuildTarget.get_source_subdirc             C   s   |  j  S)N)r1   )r`   rD   rD   rE   get_sources  s    zBuildTarget.get_sourcesc             C   s   |  j  S)N)r2   )r`   rD   rD   rE   get_objects  s    zBuildTarget.get_objectsc             C   s   |  j  S)N)r   )r`   rD   rD   rE   get_generated_sources  s    z!BuildTarget.get_generated_sourcesc             C   s   |  j  S)N)r   )r`   rD   rD   rE   should_install  s    zBuildTarget.should_installc             C   s   t  |  j  d k S)Nr   )r   r   )r`   rD   rD   rE   has_pch!  s    zBuildTarget.has_pchc             C   s,   y |  j  | SWn t k
 r' g  SYn Xd  S)N)r   KeyError)r`   r#  rD   rD   rE   get_pch$  s    zBuildTarget.get_pchc             C   s   |  j  S)N)r   )r`   rD   rD   rE   get_include_dirs*  s    zBuildTarget.get_include_dirsc          	   C   s  t  | t  s | g } n  xg| D]_} t | d  rC | j } n  t  | t j  r |  j | j  |  j | j	  x | j
 D] } |  j |  q Wt j d g  | j | j g  g  g   } |  j j |  |  j | j  q" t  | t j  r|  j j |  |  j | j    q" t  | t  r6t d   q" t | d  sTt | d  rct d   n  t d j t |  j    q" Wd  S)Nr   	undefinedz]Tried to use a build target as a dependency.
You probably should put it in link_with instead.project_args_frozenglobal_args_frozenzTried to use subproject object as a dependency.
You probably wanted to use a dependency declared in it instead.
Access it by calling get_variable() on the subproject object.zArgument is of an unacceptable type {!r}.
Must be either an external dependency (returned by find_library() or dependency()) or an internal dependency (returned by declare_dependency()).)r   r   r   r   r   InternalDependencyr   r1   r  r(   	librariesr  compile_argsr#   r   r   r  ext_depsExternalDependencyr'  r   r@   r   r   rA   )r`   depsdepr   ZextpartrD   rD   rE   r  -  s6    	zBuildTarget.add_depsc             C   s   |  j  S)N)r   )r`   rD   rD   rE   get_external_depsU  s    zBuildTarget.get_external_depsc             C   s   x t  |  D] } t | d  r. | j } n  | j   sR t d j |    n  t |  t  r t | t  r | j	 r d j | j
 |  j
  } | d 7} t |   n  |  j | j k r t d j |  j
    n  |  j j |  q Wd  S)Nr   z!Link target {!r} is not linkable.zACan't link non-PIC static library {!r} into shared library {!r}. z9Use the 'pic' option to static_library to build with PIC.z<Tried to mix cross built and native libraries in target {!r})r	   r   r   is_linkable_targetr@   r   r   SharedLibraryr  r=   r   r   r   r   )r`   r   r   r   rD   rD   rE   r  X  s    (
zBuildTarget.linkc             C   s   x t  |  D] } t | d  r. | j } n  t | t  sU t d j |    n  t |  t  r | j r d j | j	 |  j	  } | d 7} t |   n  |  j
 | j
 k r t d j |  j	    n  |  j j |  q Wd  S)Nr   z{!r} is not a static library.zACan't link non-PIC static library {!r} into shared library {!r}. z9Use the 'pic' option to static_library to build with PIC.z<Tried to mix cross built and native libraries in target {!r})r	   r   r   r   r  r@   r   r;  r=   r   r   r   r   )r`   r   r   r   rD   rD   rE   r&   f  s    
zBuildTarget.link_wholec             C   s(  | s
 d  St  |  d k rI t j | d  st d | d   qn t  |  d k r t j | d  r t j | d  s t d   q qt j | d  r t j | d  s t d   n  | d | d g } qt d | d   n! t  |  d k rt d   n  | |  j | <d  S)Nr   r   z PCH argument %s is not a header.   z>PCH definition must contain one header and at most one source.z#PCH argument %s is of unknown type.z-PCH definition may have a maximum of 2 files.)r   r   	is_headerr@   	is_sourcer   )r`   r#  ZpchlistrD   rD   rE   r  t  s"    zBuildTarget.add_pchc             C   sp   g  } xT | D]L } t  | d  r. | j } n  t | t  sL t d   n  | j |  q W|  j | 7_ d  S)Nr   zAInclude directory to be added is not an include directory object.)r   r   r   rz   r@   r   r   )r`   ru   ZidsarD   rD   rE   r    s    zBuildTarget.add_include_dirsc             C   su   t  |  } x2 | D]* } t | t t f  s t d   q q W| |  j k rd |  j | | 7<n | |  j | <d  S)Nz%A non-string passed to compiler args.)r	   r   r   r   r@   r   )r`   r#  ru   r?  rD   rD   rE   r    s    zBuildTarget.add_compiler_argsc             C   s   i  S)NrD   )r`   rD   rD   rE   get_aliases  s    zBuildTarget.get_aliasesc             C   s   g  } x3 |  j  D]( } | j | k r | j | j  q q WxP t j |  j |  j  D]6 } x- | j D]" } | | k re | j |  qe qe WqU W| S)ar  
        Sometimes you want to link to a C++ library that exports C API, which
        means the linker must link in the C++ stdlib, and we must use a C++
        compiler for linking. The same is also applicable for objc/objc++, etc,
        so we can keep using clike_langs for the priority order.

        See: https://github.com/mesonbuild/meson/issues/1653
        )r   r#  r   	itertoolschainr   r   rK   )r`   langsr8  Zlink_targetr#  rD   rD   rE   get_langs_used_by_deps  s    	z"BuildTarget.get_langs_used_by_depsc             C   s   |  j  r |  j j j } n |  j j j } |  j   } xh t D]` } | |  j k s^ | | k r= y | | SWq t k
 r t d j	 |  j
 |    Yq Xq= q= Wd } t | j	 |  j
    d S)a  
        We use the order of languages in `clike_langs` to determine which
        linker to use in case the target has sources compiled with multiple
        compilers. All languages other than those in this list have their own
        linker.
        Note that Vala outputs C code, so Vala sources can use any linker
        that can link compiled C. We don't actually need to add an exception
        for Vala here because of that.
        z~Could not get a dynamic linker for build target {!r}. Requires a linker for language "{}", but that is not a project language.z4Could not get a dynamic linker for build target {!r}N)r   r   r   rL   rK   rD  r   r,  r   r   r   r   )r`   Zall_compilersZ	dep_langsr   r   rD   rD   rE   get_clike_dynamic_linker  s    	$z$BuildTarget.get_clike_dynamic_linkerc             C   s,   |  j    } | r( | j   d k r( d Sd S)a&  
        Check if the dynamic linker is MSVC. Used by Executable, StaticLibrary,
        and SharedLibrary for deciding when to use MSVC-specific file naming
        and debug filenames.

        If at least some code is built with MSVC and the final library is
        linked with MSVC, we can be sure that some debug info will be
        generated. We only check the dynamic linker here because the static
        linker is guaranteed to be of the same type.

        Interesting cases:
        1. The Vala compiler outputs C code to be compiled by whatever
           C compiler we're using, so all objects will still be created by the
           MSVC compiler.
        2. If the target contains only objects, process_compilers guesses and
           picks the first compiler that smells right.
        msvcTF)rE  r   )r`   linkerrD   rD   rE   get_using_msvc  s    zBuildTarget.get_using_msvcc             C   s   d S)NFrD   )r`   rD   rD   rE   r:    s    zBuildTarget.is_linkable_target)2rA   rB   rC   ra   r   r   r   r   r   r   r   r   staticmethodr   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  r9  r  r&   r  r  r  r@  rD  rE  rH  r:  rD   rD   )r   rE   r   >  s\   +			=(
 r   c               @   ss   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	 g  d d  Z
 d S)	Generatorc             C   s   t  |  d k r! t d   n  | d } t | d  rF | j } n  t | t t j f  sm t d   n  | |  _ d  |  _	 |  j
 |  d  S)Nr   zBGenerator requires exactly one positional argument: the executabler   r   z/First generator argument must be an executable.)r   r@   r   r   r   r  r   ExternalProgramexedepfiler   )r`   ru   r   rL  rD   rD   rE   ra     s    
		zGenerator.__init__c             C   s   d } | j  |  j j |  j  S)Nz
<{0}: {1}>)r   r   rA   rL  )r`   r   rD   rD   rE   r     s    zGenerator.__repr__c             C   s   |  j  S)N)rL  )r`   rD   rD   rE   get_exe  s    zGenerator.get_exec             C   s  d | k r t  d   n  | d } t | t  r@ | g } n  t | t  s^ t  d   n  x, | D]$ } t | t  se t  d   qe qe W| |  _ d | k r t  d   n  | d } t | t  s | g } n  xz | D]r } t | t  st  d   n  d | k r(d	 | k r(t  d
   n  d | k s@d | k r t  d   q q Wt |  d k rx, | D]! } d | k rlt  d   qlqlWn  | |  _ d | k r| d } t | t  st  d   n  t j j	 |  d | k rt  d   n  | |  _
 n  d  S)N	argumentsz1Generator must have "arguments" keyword argument.zC"Arguments" keyword argument must be a string or a list of strings.z4A non-string object in "arguments" keyword argument.outputz.Generator must have "output" keyword argument.z""output" may only contain strings.z
@BASENAME@z@PLAINNAME@zAEvery element of "output" must contain @BASENAME@ or @PLAINNAME@.r   r   z1"outputs" must not contain a directory separator.r   z@OUTPUT@z:Tried to use @OUTPUT@ in a rule with more than one output.rM  zDepfile must be a string.z8Depfile must be a plain filename without a subdirectory.)r@   r   r   r   arglistr   r   r   r  r   rM  )r`   r   ru   r?  r   Zruler   rM  rD   rD   rE   r     sF    
	
	
zGenerator.process_kwargsc                sI   t  j j |  d  t  j j   d      f d d   |  j D S)Nr   r   c                s.   g  |  ]$ } | j  d     j  d    q S)z
@BASENAME@z@PLAINNAME@)replace)r   x)basename	plainnamerD   rE   r   -  s   	 z/Generator.get_base_outnames.<locals>.<listcomp>)r   r  r   splitextr   )r`   innamerD   )rT  rU  rE   get_base_outnames*  s    zGenerator.get_base_outnamesc             C   si   |  j  d  k r t d   n  t j j |  d } t j j |  d } |  j  j d |  j d |  S)NzJTried to get dep name for rule that does not have dependency file defined.r   r   z
@BASENAME@z@PLAINNAME@)rM  r@   r   r  r   rV  rR  )r`   rW  rU  rT  rD   rD   rE   get_dep_outname/  s
    zGenerator.get_dep_outnamec             C   s   |  j  S)N)rQ  )r`   rD   rD   rE   get_arglist6  s    zGenerator.get_arglistc             C   s   t  |  d | } xu | D]m } t | t  rO t j | j j | j |  } n* t | t  sy t d j	 | |    n  | j
 |  q W| S)Nr   z/{} arguments must be strings or files not {!r}.)r   r   r   r   r   r   r   r   r@   r   add_file)r`   r   filesstater   rP  frD   rD   rE   process_files9  s    !zGenerator.process_filesN)rA   rB   rC   ra   r   rN  r   rX  rY  rZ  r_  rD   rD   rD   rE   rJ    s   %rJ  c               @   sg   e  Z d  Z g  d d  Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d S)r   c             C   sd   t  | d  r | j } n  | |  _ |  j j |  _ g  |  _ g  |  _ i  |  _ g  |  _ | |  _	 d  S)Nr   )
r   r   	generatorrL  r   
infilelistoutfilelistoutmapextra_dependsr   )r`   r`  r   rD   rD   rE   ra   E  s    					zGeneratedList.__init__c             C   sE   |  j  j |  |  j j | j  } |  j | 7_ | |  j | <d  S)N)ra  r   r`  rX  r  rb  rc  )r`   newfileZoutfilesrD   rD   rE   r[  P  s    zGeneratedList.add_filec             C   s   |  j  S)N)ra  )r`   rD   rD   rE   
get_inputsV  s    zGeneratedList.get_inputsc             C   s   |  j  S)N)rb  )r`   rD   rD   rE   r   Y  s    zGeneratedList.get_outputsc             C   s   |  j  | S)N)rc  )r`   r   rD   rD   rE   get_outputs_for\  s    zGeneratedList.get_outputs_forc             C   s   |  j  S)N)r`  )r`   rD   rD   rE   get_generator_  s    zGeneratedList.get_generatorc             C   s   |  j  S)N)r   )r`   rD   rD   rE   r$  b  s    zGeneratedList.get_extra_argsN)
rA   rB   rC   ra   r[  rf  r   rg  rh  r$  rD   rD   rD   rE   r   D  s   r   c                   s^   e  Z d  Z   f d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z   S)r  c	       
   	      s  t    j | | | | | | | |  t |  d  s@ d |  _ n  t |  d  s t | |  s| t | |  s| d |  j k r d |  _ q d |  _ n  |  j |  _	 |  j r |  j	 d |  j 7_	 n  |  j	 g |  _
 d  |  _ d  |  _ d  |  _ d |  _ d | k r| d r|  j d	 }	 t | d t  s8| d }	 n  d
 |  _ t | |  s_t | |  rd j |	  |  _ d j |	  |  _ |  j   r|  j |  _ q|  j |  _ qn  d  S)Nr  ri   r  r   rL  .Fr?   z.exeTz{0}.libzlib{0}.a)r   ra   r   r  r   r   rK   r  r   r   r   import_filenamevs_import_filenamegcc_import_filenameis_linkwithabler   r   r   rH  )
r`   r   r   r   r   r1   r2   r   r   Zimplib_basename)r   rD   rE   ra   f  s6    %						zExecutable.__init__c             C   s   d S)Nz@exerD   )r`   rD   rD   rE   r     s    zExecutable.type_suffixc             C   s   |  j  | t  d  S)N)r   known_exe_kwargs)r`   r   rD   rD   rE   r     s    zExecutable.check_unknown_kwargsc             C   s   |  j  S)z
        The name of the import library that will be outputted by the compiler

        Returns None if there is no import library required for this platform
        )rj  )r`   rD   rD   rE   get_import_filename  s    zExecutable.get_import_filenamec             C   s   |  j  r |  j |  j g Sg  S)N)rj  rk  rl  )r`   rD   rD   rE   get_import_filenameslist  s    	z#Executable.get_import_filenameslistc             C   s   |  j  S)N)rm  )r`   rD   rD   rE   r:    s    zExecutable.is_linkable_target)	rA   rB   rC   ra   r   r   ro  rp  r:  rD   rD   )r   rE   r  e  s   *r  c                   sX   e  Z d  Z   f d d   Z d d   Z d d   Z   f d d   Z d	 d
   Z   S)r  c	       	   	      s  d | k r8 d | j  j k r8 | j  j d j | d <n  t   j | | | | | | | |  d |  j k r{ t d   n  d |  j k r t |  d  s |  j d k r t	 j
 d  d	 |  _ q |  j d k r t d j |  j    q n  t |  d  s
d |  _ n  t |  d  s}d |  j k rqt |  d  sG|  j d	 k rSd	 |  _ qz|  j d
 k rzd |  _ qzq}d |  _ n  |  j |  j d |  j |  _ |  j g |  _ d  S)Nr=   b_staticpicr   z&Static libraries not supported for C#.r  r>   libz8Defaulting Rust static library target crate type to rlibrlib	staticlibzLCrate type "{0}" invalid for static libraries; must be "rlib" or "staticlib"r  r  r?  ri  )rs  rt  )r   base_optionsr   r   ra   rK   r@   r   r>   r   debugr   r  r  r   r   r   )	r`   r   r   r   r   r1   r2   r   r   )r   rD   rE   ra     s,    %zStaticLibrary.__init__c             C   s   d S)Nz@starD   )r`   rD   rD   rE   r     s    zStaticLibrary.type_suffixc             C   s   |  j  | t  d  S)N)r   known_lib_kwargs)r`   r   rD   rD   rE   r     s    z"StaticLibrary.check_unknown_kwargsc                s`   t    j | |  d | k r\ | d } t | t  rD | |  _ q\ t d j |    n  d  S)Nr>   z0Invalid rust_crate_type "{0}": must be a string.)r   r   r   r   r>   r@   r   )r`   r   r   r>   )r   rD   rE   r     s    
zStaticLibrary.process_kwargsc             C   s   d S)NTrD   )r`   rD   rD   rE   r:    s    z StaticLibrary.is_linkable_target)rA   rB   rC   ra   r   r   r   r:  rD   rD   )r   rE   r    s
   #	r  c                   s   e  Z 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 d   Z d d   Z   S)r;  c	       	   	      s"  d  |  _  d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ t   j | | | | | | | |  d |  j k r t	 |  d  s |  j
 d k r t j d  d |  _
 q |  j
 d k r t d j |  j
    q n  t	 |  d  s d  |  _ n  t	 |  d	  sd  |  _ n  d
 |  _ |  j | |  d  S)Nr  r>   rr  z<Defaulting Rust dynamic library target crate type to "dylib"dylibcdylibzKCrate type "{0}" invalid for dynamic libraries; must be "dylib" or "cdylib"r  r  z{0.prefix}{0.name}.{0.suffix})zdylibry  )r7   	ltversionr9   rj  rk  rl  r   ra   rK   r   r>   r   rv  r@   r   r  r  basic_filename_tpldetermine_filenames)	r`   r   r   r   r   r1   r2   r   r   )r   rD   rE   ra     s&    						%	zSharedLibrary.__init__c             C   s)  d } d } |  j  |  _ |  j d k	 r9 |  j d k	 r9 nd |  j k r` d } d } d |  _ nkt | |  r d } d j |  j  |  _ d j |  j  |  _	 |  j
   r d } |  j |  _ n d } |  j	 |  _ |  j r d	 |  _ qd |  _ n t | |  rPd } d j |  j  |  _	 d
 } |  j	 |  _ |  j rDd	 |  _ qd |  _ n{ t | |  rd } d } |  j rd |  _ qd |  _ n? d } d } |  j rd |  _ n |  j rd |  _ n	 d |  _ |  j d k r| |  _ n  |  j d k r| |  _ n  |  j j |   |  _ |  j g |  _ d S)a  
        See https://github.com/mesonbuild/meson/pull/417 for details.

        First we determine the filename template (self.filename_tpl), then we
        set the output filename (self.filename).

        The template is needed while creating aliases (self.get_aliases),
        which are needed while generating .so shared libraries for Linux.

        Besides this, there's also the import library name, which is only used
        on Windows since on that platform the linker uses a separate library
        called the "import library" during linking instead of the shared
        library (DLL). The toolchain will output an import library in one of
        two formats: GCC or Visual Studio.

        When we're building with Visual Studio, the import library that will be
        generated by the toolchain is self.vs_import_filename, and with
        MinGW/GCC, it's self.gcc_import_filename. self.import_filename will
        always contain the import library name this target will generate.
        ri   Nr   dllz{0.prefix}{0.name}.{0.suffix}z{0}.libzlib{0}.dll.arr  z+{0.prefix}{0.name}-{0.soversion}.{0.suffix}Zcygrx  z+{0.prefix}{0.name}.{0.soversion}.{0.suffix}soz+{0.prefix}{0.name}.{0.suffix}.{0.ltversion}z+{0.prefix}{0.name}.{0.suffix}.{0.soversion})r{  filename_tplr  r  rK   r   r   r   rk  rl  rH  rj  r7   r   r   rz  r   r   )r`   r   r   r  r  rD   rD   rE   r|    s`    						z!SharedLibrary.determine_filenamesc                s  t    j | |  d | k r | d |  _ t |  j t  s] t d t |  j  j   n  t j	 d |  j  s t d j
 |  j    q n  d | k r | d |  _ t |  j t  r t |  j  |  _ n  t |  j t  st d   qn% |  j r|  j j d  d |  _ n  d	 | k r4| d	 } t | d
  rJ| j } n  t | t  rt j j |  rt j |  |  _ n t j | j |  j |  |  _ |  j j |  j  q4t | t  r| |  _ |  j j |  q4t | d  r%t j | j | j    } | |  _ |  j j |  q4t d   n  d | k r}| d } t | t  re| |  _ q}t d j
 |    n  d  S)Nr6   z1Shared library version needs to be a string, not z[0-9]+(\.[0-9]+){0,2}zrInvalid Shared library version "{0}". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.r7   z4Shared library soversion is not a string or integer.ri  r   r9   r   r"  zWShared library vs_module_defs must be either a string, a file object or a Custom Targetr>   z0Invalid rust_crate_type "{0}": must be a string.)r   r   rz  r   r   r@   r   rA   re	fullmatchr   r7   intr   r   r   r   r  isabsr   from_absolute_filer9   r   r   r   r$   r   r   r"  r>   )r`   r   r   r  r>   )r   rD   rE   r   Y  sL    	
		
zSharedLibrary.process_kwargsc             C   s   |  j  | t  d  S)N)r   rw  )r`   r   rD   rD   rE   r     s    z"SharedLibrary.check_unknown_kwargsc             C   s   |  j  S)z
        The name of the import library that will be outputted by the compiler

        Returns None if there is no import library required for this platform
        )rj  )r`   rD   rD   rE   ro    s    z!SharedLibrary.get_import_filenamec             C   s   |  j  r |  j |  j g Sg  S)N)rj  rk  rl  )r`   rD   rD   rE   rp    s    	z&SharedLibrary.get_import_filenameslistc             C   s   |  g |  j    S)N)r  )r`   rD   rD   rE   r	    s    zSharedLibrary.get_all_link_depsc             C   s   i  } |  j  d k s |  j r# i  S|  j  d k r |  j r |  j |  j k r |  j j d d  } | j |   } |  j | | <n	 |  j } | | |  j j |   <| S)a#  
        If the versioned library name is libfoo.so.0.100.0, aliases are:
        * libfoo.so.0 (soversion) -> libfoo.so.0.100.0
        * libfoo.so (unversioned; for linking) -> libfoo.so.0
        Same for dylib:
        * libfoo.dylib (unversioned; for linking) -> libfoo.0.dylib
        r~  rx  rz  r7   )zsozdylib)r  r7   rz  r  rR  r   r   r{  )r`   aliasesZ	alias_tplZltversion_filenamerD   rD   rE   r@    s    *	zSharedLibrary.get_aliasesc             C   s   d S)Nz@sharD   )r`   rD   rD   rE   r     s    zSharedLibrary.type_suffixc             C   s   d S)NTrD   )r`   rD   rD   rE   r:    s    z SharedLibrary.is_linkable_target)rA   rB   rC   ra   r|  r   r   ro  rp  r	  r@  r   r:  rD   rD   )r   rE   r;    s   b4r;  c                   s"   e  Z d  Z   f d d   Z   S)SharedModulec	       	   	      sh   d | k r t  d   n  d | k r6 t  d   n  t   j | | | | | | | |  d  |  _ d  S)Nr6   z2Shared modules must not specify the version kwarg.r7   z4Shared modules must not specify the soversion kwarg.)r   r   ra   rj  )	r`   r   r   r   r   r1   r2   r   r   )r   rD   rE   ra     s    %zSharedModule.__init__)rA   rB   rC   ra   rD   rD   )r   rE   r    s   r  c                   s9  e  Z d  Z i d d 6d d 6d d 6d d 6d d 6d d 6d d	 6d d
 6d d 6d d 6d d 6d d 6Z d   f d d  Z d d   Z d d   Z d 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   S)/r   TinputrP  commandFcapturer   r)   r   dependsdepend_filesrM  r4   r5   c                s   t    j | | d  g  |  _ g  |  _ g  |  _ d  |  _ |  j |  g  |  _ | |  _ g  } x- | D]% } | t	 j
 k rf | j |  qf qf Wt |  d k r t j d |  j d j |  f  n  d  S)NFr   z*Unknown keyword arguments in target %s: %sz, )r   ra   r   rd  r  rM  r   r-   absolute_pathsr   r   r   r   r   r   r   r   )r`   r   r   r   r  r   r   )r   rD   rE   ra     s    							zCustomTarget.__init__c             C   s   |  j    | j    k  S)N)r   )r`   r   rD   rD   rE   r     s    zCustomTarget.__lt__c             C   s(   d } | j  |  j j |  j   |  j  S)Nz<{0} {1}: {2}>)r   r   rA   r   r  )r`   r   rD   rD   rE   r     s    zCustomTarget.__repr__c             C   s   |  j  |  j   S)N)r   r   )r`   rD   rD   rE   r     s    zCustomTarget.get_idc             C   sx   |  j  d  d   } | |  j 7} xQ |  j D]F } t | d  rK | j } n  t | t t f  r* | j |  q* q* W| S)Nr   )	r   rd  r1   r   r   r   r   r   r   )r`   r7  r   rD   rD   rE   get_target_dependencies  s    z$CustomTarget.get_target_dependenciesc             C   s  t  | t  s | g } n  g  } xW| D]O} t | d  rI | j } n  t  | t  rh | j |  q( t  | t  r |  j j |  | j |  q( t  | t j	  r| j
   s d } t | j | j    n  |  j j t j | j     | | j   7} q( t  | t t f  r=|  j j |  | j |  q( t  | t  rb| |  j |  7} q( t d j |    q( W| S)Nr   z9Tried to use not-found external program {!r} in "command"z%Argument {!r} in "command" is invalid)r   r   r   r   r   r   r   r  r   rK  foundr@   r   r   r  get_pathget_commandr   r   flatten_command)r`   cmdZ	final_cmdr   r   rD   rD   rE   r    s0    zCustomTarget.flatten_commandc                s  t    j |  t | j d g    } g  |  _ x9 | D]1 } t | d  rY | j } n  |  j j |  q8 Wd | k r t d   n  | d |  _	 t
 |  j	 t  s |  j	 g |  _	 n  t |  j  } t | g   } x |  j	 D] } t
 | t  st d   n  d | k r t d   n  d | k s8d	 | k rMd
 } t |   n  t |  d k r d | k swd | k r d } t |   q q Wt |  j	 |  |  _	 | j d d  |  _ |  j rt |  j	  d k rt d   n  d | k rt d   n  d | k rm| d } t
 | t  s6t d   n  t j j |  d | k rat d   n  | |  _ n  |  j | d  |  _ |  j rx> |  j D]0 }	 t
 |	 t  rd |	 k rt d   qqWn  d | k rM| d |  _ t
 |  j t  st d   n  |  j rbd | k r+t d   n  t | d t t f  |  _ qbn d |  _ d  g |  _ | j d d  |  _ t
 |  j t  st d   n  | j d g   }
 t
 |
 t  s|
 g }
 n  xa |
 D]Y } x t | d  r| j } qWt
 | t t f  st d    n  |  j j |  qW| j d! g   } t
 | t  sV| g } n  xa | D]Y } t
 | t  t f  r|  j! j |  q]t" j# |  t d" j$ t% |  j&    q]Wd  S)#Nr  r   rP  z"Missing keyword argument "output".zOutput argument not a string.r   z'Output must not contain a path segment.z@INPUT@z@INPUT0@zROutput cannot contain @INPUT@ or @INPUT0@, did you mean @PLAINNAME@ or @BASENAME@?r   z@PLAINNAME@z
@BASENAME@znOutput cannot contain @PLAINNAME@ or @BASENAME@ when there is more than one input (we can't know which to use)r  Fz+Capturing can only output to a single file.r  z#Missing keyword argument "command".rM  zDepfile must be a string.z8Depfile must be a plain filename without a subdirectory.z@OUTPUT@z.@OUTPUT@ is not allowed when capturing output.r   z"install" must be boolean.r)   z8"install_dir" must be specified when installing a targetr   z(Argument build_always must be a boolean.r  z\Can only depend on toplevel targets: custom_target or build_target (executable or a library)r  z"Unknown type {!r} in depend_files.)'r   r   r	   rr   r1   r   r   r   r@   r   r   r   get_sources_string_namesr   r   r   r   r  r   r  r   rM  r  r  r   r   r
   r)   r   r   r   rd  r   r  r   rv  r   r   rA   )r`   r   r1   r   inputsr   r  r   rM  r   Z
extra_depsZedr  )r   rD   rE   r     s    	*
		"	zCustomTarget.process_kwargsc             C   s   |  j  S)N)r   )r`   rD   rD   rE   r%  t  s    zCustomTarget.get_dependenciesc             C   s   |  j  S)N)r   )r`   rD   rD   rE   r*  w  s    zCustomTarget.should_installc             C   s   |  j  S)N)r)   )r`   rD   rD   rE   r
  z  s    z#CustomTarget.get_custom_install_dirc             C   s   |  j  S)N)r   )r`   rD   rD   rE   r   }  s    zCustomTarget.get_outputsc             C   s   |  j  d S)Nr   )r   )r`   rD   rD   rE   r"    s    zCustomTarget.get_filenamec             C   s   |  j  S)N)r1   )r`   rD   rD   rE   r'    s    zCustomTarget.get_sourcesc             C   sX   g  } xK |  j  D]@ } t | d  r1 | j } n  t | t  r | j |  q q W| S)Nr   )r1   r   r   r   r   r   )r`   Zgenlistsr   rD   rD   rE   get_generated_lists  s    z CustomTarget.get_generated_listsc             C   s
   |  j    S)N)r  )r`   rD   rD   rE   r)    s    z"CustomTarget.get_generated_sourcesc             C   s   d S)Nz@cusrD   )r`   rD   rD   rE   r     s    zCustomTarget.type_suffix)rA   rB   rC   r   ra   r   r   r   r  r  r   r%  r*  r
  r   r"  r'  r  r)  r   rD   rD   )r   rE   r     s8   


U	r   c                   s   e  Z 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   S)	RunTargetc                s5   t    j | | d  | |  _ | |  _ | |  _ d  S)NF)r   ra   r  ru   r   )r`   r   r  ru   r   r   )r   rD   rE   ra     s    		zRunTarget.__init__c             C   s   |  j    | j    k  S)N)r   )r`   r   rD   rD   rE   r     s    zRunTarget.__lt__c             C   s(   d } | j  |  j j |  j   |  j  S)Nz<{0} {1}: {2}>)r   r   rA   r   r  )r`   r   rD   rD   rE   r     s    zRunTarget.__repr__c             C   s   |  j  |  j   S)N)r   r   )r`   rD   rD   rE   r     s    zRunTarget.get_idc             C   s   |  j  S)N)r   )r`   rD   rD   rE   r%    s    zRunTarget.get_dependenciesc             C   s   g  S)NrD   )r`   rD   rD   rE   r)    s    zRunTarget.get_generated_sourcesc             C   s   g  S)NrD   )r`   rD   rD   rE   r'    s    zRunTarget.get_sourcesc             C   s   d S)NFrD   )r`   rD   rD   rE   r*    s    zRunTarget.should_installc             C   s   |  j  S)N)r   )r`   rD   rD   rE   r"    s    zRunTarget.get_filenamec             C   s   d S)Nz@runrD   )r`   rD   rD   rE   r     s    zRunTarget.type_suffix)rA   rB   rC   ra   r   r   r   r%  r)  r'  r*  r"  r   rD   rD   )r   rE   r    s   r  c                   sR   e  Z d  Z   f d d   Z d d   Z d d   Z d d   Z d	 d
   Z   S)Jarc	       
   	      s   t    j | | | | | | | |  x3 |  j D]( }	 |	 j d  s/ t d |	   q/ q/ W|  j d |  _ |  j g |  _ | j d g   |  _	 d  S)Nz.javaz!Jar source %s is not a java file.z.jarr!   )
r   ra   r1   r   r@   r   r   r   rr   r!   )
r`   r   r   r   r   r1   r2   r   r   r   )r   rD   rE   ra     s    %zJar.__init__c             C   s   |  j  S)N)r*   )r`   rD   rD   rE   get_main_class  s    zJar.get_main_classc             C   s   d S)Nz@jarrD   )r`   rD   rD   rE   r     s    zJar.type_suffixc             C   s   |  j  S)N)r!   )r`   rD   rD   rE   get_java_args  s    zJar.get_java_argsc             C   s   d  S)NrD   )r`   r   rD   rD   rE   r     s    zJar.validate_cross_install)rA   rB   rC   ra   r  r   r  r   rD   rD   )r   rE   r    s
   	r  c               @   sX   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d S)ConfigureFilec             C   s(   | |  _  | |  _ | |  _ | |  _ d  S)N)r   
sourcename
targetnameconfiguration_data)r`   r   r  r  r  rD   rD   rE   ra     s    			zConfigureFile.__init__c             C   sU   d } t  j j |  j |  j  } t  j j |  j |  j  } | j |  j j | |  S)Nz<{0}: {1} -> {2}>)	r   r  r   r   r  r  r   r   rA   )r`   r   r  dstrD   rD   rE   r     s    zConfigureFile.__repr__c             C   s   |  j  S)N)r  )r`   rD   rD   rE   get_configuration_data  s    z$ConfigureFile.get_configuration_datac             C   s   |  j  S)N)r   )r`   rD   rD   rE   r     s    zConfigureFile.get_subdirc             C   s   |  j  S)N)r  )r`   rD   rD   rE   get_source_name  s    zConfigureFile.get_source_namec             C   s   |  j  S)N)r  )r`   rD   rD   rE   get_target_name  s    zConfigureFile.get_target_nameN)	rA   rB   rC   ra   r   r  r   r  r  rD   rD   rD   rE   r    s   r  c                   sR   e  Z d  Z   f d d   Z d d   Z d d   Z d d   Z d	 d
   Z   S)ConfigurationDatac                s   t    j   i  |  _ d  S)N)r   ra   r   )r`   )r   rD   rE   ra     s    zConfigurationData.__init__c             C   s   t  |  j  S)N)r   r   )r`   rD   rD   rE   r     s    zConfigurationData.__repr__c             C   s   | |  j  k S)N)r   )r`   r   rD   rD   rE   __contains__  s    zConfigurationData.__contains__c             C   s   |  j  | S)N)r   )r`   r   rD   rD   rE   rr     s    zConfigurationData.getc             C   s   |  j  j   S)N)r   keys)r`   rD   rD   rE   r    s    zConfigurationData.keys)rA   rB   rC   ra   r   r  rr   r  rD   rD   )r   rE   r    s
   r  c               @   s   e  Z d  Z d d d  Z d S)DataNc             C   sl   | |  _  | |  _ | |  _ t |  j  t  s? |  j  g |  _  n  x& |  j  D] } t | t  sI t  qI Wd  S)N)r1   r)   install_moder   r   r   r   )r`   r1   r)   r  r   rD   rD   rE   ra     s    			zData.__init__)rA   rB   rC   ra   rD   rD   rD   rE   r    s   r  c                   s"   e  Z d  Z   f d d   Z   S)	RunScriptc                sO   t    j   t | t  s" t  t | t  s7 t  | |  d <| |  d <d  S)NrL  ru   )r   ra   r   r   r   )r`   scriptru   )r   rD   rE   ra     s
    
zRunScript.__init__)rA   rB   rC   ra   rD   rD   )r   rE   r    s   r  c            
   @   s4   e  Z d  Z d d d d d d d d d d  Z d S)	TestSetupexe_wrapperNgdbtimeout_multiplierr   c            C   s(   | |  _  | |  _ | |  _ | |  _ d  S)N)r  r  r  r   )r`   r  r  r  r   rD   rD   rE   ra     s    			zTestSetup.__init__)rA   rB   rC   ra   rD   rD   rD   rE   r    s   r  c             C   s   g  } x |  D] } t  | d  r. | j } n  t | t  rM | j |  q t | t t t f  rx | | j   7} q t | t	  r | j | j
  q t d j |    q W| S)zw
    For the specified list of @sources which can be strings, Files, or targets,
    get all the output basenames.
    r   zUnknown source type: {!r})r   r   r   r   r   r   r   r   r   r   r  r   r   )r1   namesr   rD   rD   rE   r    s    r  )6r  r   r  collectionsr   rA  ri   r   r   r   mesonlibr   r   r	   r
   r   r   r   r   r   r   r   rK   r   r   r   r   r   rw  updatern  r@   rF   rz   r   r   r   r   rJ  r   r  r  r;  r  r   r  r  r  r  r  dictr  r  r  rD   rD   rD   rE   <module>   s   $""

Z&&(  S!A6	#
