
    e.                    $   U d dl mZ d dlZddlmZmZmZ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mZmZ dd
lmZmZmZmZ ddlmZ ej2                  r;d dlmZ ddlmZ ddlmZ ddlmZm Z   G d de      Z! G d de      Z" G d de      Z# ed ee$e%e
jL                  f      dg       Z'de(d<    G d dejR                        Z* G d dejR                        Z+ G d d       Z, G d! d"e,e      Z- G d# d$e      Z. G d% d&e      Z/d(d'Z0y))    )annotationsN   )ExtensionModuleModuleObjectMutableModuleObject
ModuleInfo   )build)dependencies)mesonlib)	noPosargsnoKwargsInterpreterExceptionInvalidArgumentsInvalidCode
FeatureNew)ContainerTypeInfo	KwargInfotyped_kwargstyped_pos_args)
OrderedSet)	TypedDict)ModuleState)Interpreter)TYPE_varTYPE_kwargsc                  ,    e Zd ZU ded<   ded<   ded<   y)	AddKwargs-T.List[T.Union[str, dependencies.Dependency]]whenzUT.List[T.Union[mesonlib.FileOrString, build.GeneratedTypes, dependencies.Dependency]]if_true<T.List[T.Union[mesonlib.FileOrString, build.GeneratedTypes]]if_falseN__name__
__module____qualname____annotations__     >/usr/lib/python3/dist-packages/mesonbuild/modules/sourceset.pyr   r   $   s    ;;ffNNr*   r   c                  "    e Zd ZU ded<   ded<   y)AddAllKwr   r    T.List[SourceSetImpl]r!   Nr$   r)   r*   r+   r-   r-   *   s    ;;&&r*   r-   c                      e Zd ZU ded<   y)ApplyKwboolstrictNr$   r)   r*   r+   r0   r0   /   s    r*   r0   r    Tlistifydefaultz8KwargInfo[T.List[T.Union[str, dependencies.Dependency]]]_WHEN_KWc                  T    e Zd ZU ded<   	 ded<   	 ded<   	 ded<   	 ded	<   	 ded
<   y)SourceSetRulezT.List[str]keysT.List[dependencies.Dependency]depsr"   sources
extra_depsr.   
sourcesetsr#   Nr$   r)   r*   r+   r8   r8   <   s=    
:
))4IIA//B &%EJJBr*   r8   c                  "    e Zd ZU ded<   ded<   y)SourceFilesz@OrderedSet[T.Union[mesonlib.FileOrString, build.GeneratedTypes]]r<   z#OrderedSet[dependencies.Dependency]r;   Nr$   r)   r*   r+   r@   r@   Q   s    MM
--r*   r@   c                      e Zd ZdZy)	SourceSetzBase class to avoid circular references.

    Because of error messages, this class is called SourceSet, and the actual
    implementation is an Impl.
    N)r%   r&   r'   __doc__r)   r*   r+   rB   rB   V   s    r*   rB   c                  6    e Zd Zd fdZ	 	 ddZ	 	 ddZ edeej                  e
j                  e
j                  e
j                  ej                  f       ede ed eeeej                  e
j                  e
j                  e
j                  ej                  f      dg        ed	 eeeej                  e
j                  e
j                  e
j                  f      dg             	 	 	 	 	 	 dd
              Z ede       ede ed eee      dg             	 	 	 	 dd              Z	 d	 	 	 	 	 ddZee	 	 dd              Zee edd      	 	 dd                     Z ede
j<                  ef       ed ede d            dd              Z! xZ"S ) SourceSetImplc                J   t         |           g | _        |j                  | _        |j                  | _        |j
                  | _        d| _        | j                  j                  | j                  | j                  | j                  | j                  | j                  d       y )NF)addadd_allall_sourcesall_dependenciesapply)super__init__rules
subprojectenvironmentsubdirfrozenmethodsupdate
add_methodadd_all_methodall_sources_methodall_dependencies_methodapply_methodselfinterpreter	__class__s     r+   rM   zSourceSetImpl.__init___   s    ,.
%00&22!((??**22 $ < <&&
 	r*   c                   g }g }|D ]?  }t        |t        j                        r|j                  |       /|j                  |       A g }|D ]y  }t        |t              r|j                  |       %t        |t
        j                        r|j                  |j                         [|j                  |j                                { t        j                  |       ||fS N)
isinstancer   
Dependencyappendstrr   Filefnameextendget_outputscheck_direntry_issues)r[   argsr<   r;   xto_checkss          r+   check_source_filesz SourceSetImpl.check_source_filesn   s    PR02 	"A!\445Aq!		"
 !#  	1A!S!"Ax}}-(0	1 	&&x0}r*   c                    g }g }|D ]5  }t        |t              r|j                  |       %|j                  |       7 ||fS r_   )r`   rc   rb   )r[   ri   r9   r;   rj   s        r+   check_conditionszSourceSetImpl.check_conditions   sG    02 	A!S!AA		
 Tzr*   zsourceset.add)varargsr!   Tr3   r#   c           
     b   | j                   rt        d      |d   }|d   }|d   }t        |||g      s|d   }n|d   rt        d      | j	                  |      \  }}| j                  |      \  }	}
| j                  |      \  }}| j                  j                  t        |||	|
g |             y )Nz0Tried to use 'add' after querying the source setr    r!   r#   r   z5add called with both positional and keyword arguments)	rR   r   anyr   ro   rm   rN   rb   r8   )r[   stateri   kwargsr    r!   r#   r9   r   r<   r=   _s               r+   rU   zSourceSetImpl.add_method   s    ( ;;RSSf~#*%D'8,-1gG!W&'^__!2248l"55g>--h7!

-lGZQSU]^_r*   zsourceset.add_allc           
        | j                   rt        d      |d   }|d   }|s|s|d   }n|d   rt        d      | j                  |      \  }}|D ]	  }d|_          | j                  j                  t        ||g g |g              y )Nz4Tried to use 'add_all' after querying the source setr    r!   r   z9add_all called with both positional and keyword argumentsT)rR   r   r   ro   rN   rb   r8   )	r[   rs   ri   rt   r    r!   r9   r   rl   s	            r+   rV   zSourceSetImpl.add_all_method   s     ;;VWWf~#G1gG!W&'bcc!2248l 	AAH	

-lBGRPQr*   c                P   |st        t               t                     }| j                  D ]  }t        d |j                  D              rt        fd|j
                  D              r|j                  j                  |j                         |j                  j                  |j                         |j                  j                  |j                         |j                  D ]  }|j                  ||        |s|j                  j                  |j                          |S )Nc              3  <   K   | ]  }|j                           y wr_   )found).0rj   s     r+   	<genexpr>z(SourceSetImpl.collect.<locals>.<genexpr>   s     117791s   c              3  .   K   | ]  } |        y wr_   r)   )rz   key
enabled_fns     r+   r{   z(SourceSetImpl.collect.<locals>.<genexpr>   s     9s:c?9s   )r@   r   rN   allr;   r9   r<   rT   r=   r>   collectr#   )r[   r~   rI   intoentrysss    `    r+   r   zSourceSetImpl.collect   s     z|Z\:DZZ 
	0E1ejj119ejj99##EMM2		  ,		  !1!12** >BJJz;=>"LL/
	0 r*   c                `    d| _         | j                  d d      }t        |j                        S )NTc                     yNTr)   rj   s    r+   <lambda>z2SourceSetImpl.all_sources_method.<locals>.<lambda>       r*   )rR   r   listr<   r[   rs   ri   rt   filess        r+   rW   z SourceSetImpl.all_sources_method   s*     ^T2EMM""r*   z$source_set.all_dependencies() methodz0.52.0c                `    d| _         | j                  d d      }t        |j                        S )NTc                     yr   r)   r   s    r+   r   z7SourceSetImpl.all_dependencies_method.<locals>.<lambda>   r   r*   )rR   r   r   r;   r   s        r+   rX   z%SourceSetImpl.all_dependencies_method   s*    
 ^T2EJJr*   zsourceset.applyr2   )r5   c                   	 |d   d| _         |d   	t        t              rd	fd}n
i d	fd}| j                  |d      }t	        |      }|S )Nr   Tr2   c                    t        t              sJ d       r| vrt        d|  d      t        j	                  | d            S )Nfor mypyzEntry z! not in configuration dictionary.F)r`   dictr   r1   get)r}   config_datar2   s    r+   _get_from_config_dataz9SourceSetImpl.apply_method.<locals>._get_from_config_data   sM    !+t4@j@4c4.u<]/^__KOOC788r*   c                    t        t        j                        sJ d       | vr?| v r%t        j	                  |       d         | <   |    S rt        d|  d      d| <   |    S )Nr   r   zsourceset.apply: key "z." not in passed configuration, and strict set.F)r`   r
   ConfigurationDatar1   r   r   )r}   config_cacher   r2   s    r+   r   z9SourceSetImpl.apply_method.<locals>._get_from_config_data   s    !+u/F/FGSSGl*k),01Ea1H,IS)
 $C((	  .1GuLz/{||,1S)#C((r*   F)r}   rc   returnr1   )rR   r`   r   r   SourceFilesObject)
r[   rs   ri   rt   r   r   resr   r   r2   s
          @@@r+   rY   zSourceSetImpl.apply_method   s\     1g!k4(9 /1L	) 2E:&
r*   r\   r   )ri   zYT.Sequence[T.Union[mesonlib.FileOrString, build.GeneratedTypes, dependencies.Dependency]]r   zfT.Tuple[T.List[T.Union[mesonlib.FileOrString, build.GeneratedTypes]], T.List[dependencies.Dependency]])ri   z1T.Sequence[T.Union[str, dependencies.Dependency]]r   z5T.Tuple[T.List[str], T.List[dependencies.Dependency]])rs   r   ri   z^T.Tuple[T.List[T.Union[mesonlib.FileOrString, build.GeneratedTypes, dependencies.Dependency]]]rt   r   r   None)rs   r   ri   zT.Tuple[T.List[SourceSetImpl]]rt   r-   r   r   r_   )r~   zT.Callable[[str], bool]rI   r1   r   zT.Optional['SourceFiles']r   r@   rs   r   ri   T.List[TYPE_var]rt   r   r   r"   rs   r   ri   r   rt   r   r   r:   )rs   r   ri   z@T.Tuple[T.Union[build.ConfigurationData, T.Dict[str, TYPE_var]]]rt   r0   r   r   )#r%   r&   r'   rM   rm   ro   r   rc   r   rd   r
   GeneratedListCustomTargetCustomTargetIndexr   ra   r   r6   r   r   r   rU   rB   rV   r   r   r   rW   r   rX   r   r   r1   rY   __classcell__r]   s   @r+   rE   rE   ^   si    !G,	S	 Oc8==%BUBUW\WiWikp  lC  lC  EQ  E\  E\  .]  ^dS(--9L9LeN`N`bgbyby  |H  |S  |S  %T  U		
 	dS(--9L9LeN`N`bgbyby$z{		
 `w`$`)-`! ^"`" ';dI.		
	R'R,0R	 <R" 37!/;F$ # \#  # 6A %D  B    %(?(?'FG#Yxt%LM N Hr*   rE   c                  `     e Zd Zd fdZee	 	 dd              Zee	 	 dd              Z xZS )r   c                    t         |           || _        | j                  j	                  | j
                  | j                  d       y )N)r<   r   )rL   rM   r   rS   rT   sources_methoddependencies_method)r[   r   r]   s     r+   rM   zSourceFilesObject.__init__  s>    
** 44
 	r*   c                @    t        | j                  j                        S r_   )r   r   r<   r[   rs   ri   rt   s       r+   r   z SourceFilesObject.sources_method  s     DJJ&&''r*   c                @    t        | j                  j                        S r_   )r   r   r;   r   s       r+   r   z%SourceFilesObject.dependencies_method  s     DJJOO$$r*   )r   r@   r   r   )	r%   r&   r'   rM   r   r   r   r   r   r   s   @r+   r   r     sP     (X(  ( %!@%  %r*   r   c                  N     e Zd Z edd      Zd fdZeedd              Z xZ	S )SourceSetModule	sourcesetz0.51.0c                r    t         |   |       | j                  j                  d| j                  i       y )N
source_set)rL   rM   rS   rT   r   rZ   s     r+   rM   zSourceSetModule.__init__%  s0    %$//
 	r*   c                ,    t        | j                        S r_   )rE   r\   r   s       r+   r   zSourceSetModule.source_set+  s     T--..r*   r   )rs   r   ri   r   rt   r   r   rE   )
r%   r&   r'   r   INFOrM   r   r   r   r   r   s   @r+   r   r   !  s0    k8,D /  /r*   r   c                    t        |       S r_   )r   )interps    r+   
initializer   0  s    6""r*   )r   r   r   r   )1
__future__r   typingT r   r   r   r   r
   r   r   interpreterbaser   r   r   r   r   r   interpreterbase.decoratorsr   r   r   r   r   TYPE_CHECKINGtyping_extensionsr   r   r\   r   r   r   r   r-   r0   r   rc   ra   r6   r(   
NamedTupler8   r@   rB   rE   r   r   r   r)   r*   r+   <module>r      s    #  L L     d c !??+)7OI O'9 '
) 
 FO
dS,"9"9:;	F
B CALL C*.!,, .
 lI2 l\% %*/o /#r*   