o
    uJAf.                     @  s  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jrd dlmZ ddlmZ ddlmZ ddlmZm Z  G dd deZ!G dd deZ"G dd deZ#edee$e%e
j&fdg dZ'de(d< G dd dej)Z*G dd dej)Z+G dd  d Z,G d!d" d"e,eZ-G d#d$ d$eZ.G d%d& d&eZ/d,d*d+Z0dS )-    )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                   @  s&   e Zd ZU ded< ded< ded< dS )	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__ r'   r'   A/usr/lib/python3.10/site-packages/mesonbuild/modules/sourceset.pyr   $   s   
 r   c                   @     e Zd ZU ded< ded< dS )AddAllKwr   r   T.List[SourceSetImpl]r   Nr"   r'   r'   r'   r(   r*   *   s   
 r*   c                   @  s   e Zd ZU ded< dS )ApplyKwboolstrictNr"   r'   r'   r'   r(   r,   /   s   
 r,   r   Tlistifydefaultz8KwargInfo[T.List[T.Union[str, dependencies.Dependency]]]_WHEN_KWc                   @  sH   e Zd ZU ded< 	 ded< 	 ded< 	 ded< 	 ded	< 	 ded
< dS )SourceSetRulezT.List[str]keysT.List[dependencies.Dependency]depsr    sources
extra_depsr+   
sourcesetsr!   Nr"   r'   r'   r'   r(   r3   <   s   
 r3   c                   @  r)   )SourceFilesz@OrderedSet[T.Union[mesonlib.FileOrString, build.GeneratedTypes]]r7   z#OrderedSet[dependencies.Dependency]r6   Nr"   r'   r'   r'   r(   r:   Q   s   
 r:   c                   @  s   e Zd ZdZdS )	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'   r(   r;   V   s    r;   c                      sV  e Zd Zd> fddZd?d	d
Zd@ddZedeej	e
je
je
jejfdedeedeeeej	e
je
je
jejfdg dedeeeej	e
je
je
jfdg ddAddZedededeedeeedg ddBd d!Z	"dCdDd*d+ZeedEd/d0Zeeed1d2dFd4d5Zed6e
jefed6ed7e dd8dGd<d=Z!  Z"S )HSourceSetImplinterpreterr   c                   sT   t    g | _|j| _|j| _|j| _d| _| j| j	| j
| j| j| jd d S )NF)addZadd_allall_sourcesZ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selfr>   	__class__r'   r(   rC   _   s   
zSourceSetImpl.__init__argsYT.Sequence[T.Union[mesonlib.FileOrString, build.GeneratedTypes, dependencies.Dependency]]returnfT.Tuple[T.List[T.Union[mesonlib.FileOrString, build.GeneratedTypes]], T.List[dependencies.Dependency]]c                 C  s   g }g }|D ]}t |tjr|| q|| qg }|D ]!}t |tr+|| qt |tjr8||j q||	  qt
| ||fS N)
isinstancer
   
Dependencyappendstrr   Filefnameextendget_outputscheck_direntry_issues)rQ   rT   r7   r6   xZto_checksr'   r'   r(   check_source_filesn   s   

z SourceSetImpl.check_source_files1T.Sequence[T.Union[str, dependencies.Dependency]]5T.Tuple[T.List[str], T.List[dependencies.Dependency]]c                 C  s:   g }g }|D ]}t |tr|| q|| q||fS rX   )rY   r\   r[   )rQ   rT   r4   r6   rb   r'   r'   r(   check_conditions   s   
zSourceSetImpl.check_conditionszsourceset.add)varargsr   Tr/   r!   stater   ^T.Tuple[T.List[T.Union[mesonlib.FileOrString, build.GeneratedTypes, dependencies.Dependency]]]kwargsr   Nonec              	   C  s   | j rtd|d }|d }|d }t|||gs|d }n|d r'td| |\}}| |\}	}
| |\}}| jt|||	|
g | d S )Nz0Tried to use 'add' after querying the source setr   r   r!   r   z5add called with both positional and keyword arguments)	rH   r   anyr   rg   rd   rD   r[   r3   )rQ   ri   rT   rk   r   r   r!   r4   r
   r7   r8   _r'   r'   r(   rK      s   
zSourceSetImpl.add_methodzsourceset.add_allT.Tuple[T.List[SourceSetImpl]]r*   c           	   	   C  s|   | j rtd|d }|d }|s|s|d }n|d r td| |\}}|D ]}d|_ q)| jt||g g |g  d S )Nz4Tried to use 'add_all' after querying the source setr   r   r   z9add_all called with both positional and keyword argumentsT)rH   r   r   rg   rD   r[   r3   )	rQ   ri   rT   rk   r   r   r4   r
   rc   r'   r'   r(   rL      s   
zSourceSetImpl.add_all_methodN
enabled_fnT.Callable[[str], bool]r@   r-   intoT.Optional['SourceFiles']r:   c                   s   |s	t t t }| jD ]D}tdd |jD rIt fdd|jD rI|j|j |j|j |j|j |j	D ]	}|
 || q<|sIq|j|j q|S )Nc                 s  s    | ]}|  V  qd S rX   )found).0rb   r'   r'   r(   	<genexpr>       z(SourceSetImpl.collect.<locals>.<genexpr>c                 3  s    | ]} |V  qd S rX   r'   )ru   keyrp   r'   r(   rv      rw   )r:   r   rD   allr6   r4   r7   rJ   r8   r9   collectr!   )rQ   rp   r@   rr   entryssr'   ry   r(   r{      s   

zSourceSetImpl.collectT.List[TYPE_var]r   r    c                 C      d| _ | dd d}t|jS )NTc                 S     dS NTr'   rb   r'   r'   r(   <lambda>       z2SourceSetImpl.all_sources_method.<locals>.<lambda>)rH   r{   listr7   rQ   ri   rT   rk   filesr'   r'   r(   rM      s   
z SourceSetImpl.all_sources_methodz$source_set.all_dependencies() methodz0.52.0r5   c                 C  r   )NTc                 S  r   r   r'   r   r'   r'   r(   r      r   z7SourceSetImpl.all_dependencies_method.<locals>.<lambda>)rH   r{   r   r6   r   r'   r'   r(   rN      s   
z%SourceSetImpl.all_dependencies_methodzsourceset.applyr.   )r1   @T.Tuple[T.Union[build.ConfigurationData, T.Dict[str, TYPE_var]]]r,   SourceFilesObjectc                   s`   |d d| _ |d ttrdfdd	}ni  d fd
d	}| |d}t|}|S )Nr   Tr.   rx   r\   rV   r-   c                   s>   t  ts	J dr|  vrtd|  dt | dS )Nfor mypyzEntry z! not in configuration dictionary.F)rY   dictr   r-   getrx   )config_datar.   r'   r(   _get_from_config_data   s   z9SourceSetImpl.apply_method.<locals>._get_from_config_datac                   sf   t tjs
J d|  vr/| v r!t| d  | <  |  S r+td|  dd | <  |  S )Nr   r   zsourceset.apply: key "z." not in passed configuration, and strict set.F)rY   r	   ConfigurationDatar-   r   r   r   Zconfig_cacher   r.   r'   r(   r      s   F)rx   r\   rV   r-   )rH   rY   r   r{   r   )rQ   ri   rT   rk   r   r   resr'   r   r(   rO      s   
zSourceSetImpl.apply_methodr>   r   )rT   rU   rV   rW   )rT   re   rV   rf   )ri   r   rT   rj   rk   r   rV   rl   )ri   r   rT   ro   rk   r*   rV   rl   rX   )rp   rq   r@   r-   rr   rs   rV   r:   ri   r   rT   r~   rk   r   rV   r    ri   r   rT   r~   rk   r   rV   r5   )ri   r   rT   r   rk   r,   rV   r   )#r#   r$   r%   rC   rd   rg   r   r\   r   r]   r	   GeneratedListCustomTargetCustomTargetIndexr
   rZ   r   r2   r   r   r   rK   r;   rL   r{   r   r   rM   r   rN   r   r   r-   rO   __classcell__r'   r'   rR   r(   r=   ^   s\    

 

r=   c                      sB   e Zd Zd fddZeedddZeedddZ  ZS )r   r   r:   c                   s*   t    || _| j| j| jd d S )N)r7   r
   )rB   rC   r   rI   rJ   sources_methoddependencies_method)rQ   r   rR   r'   r(   rC     s   
zSourceFilesObject.__init__ri   r   rT   r~   rk   r   rV   r    c                 C     t | jjS rX   )r   r   r7   rQ   ri   rT   rk   r'   r'   r(   r        z SourceFilesObject.sources_methodr5   c                 C  r   rX   )r   r   r6   r   r'   r'   r(   r     r   z%SourceFilesObject.dependencies_method)r   r:   r   r   )	r#   r$   r%   rC   r   r   r   r   r   r'   r'   rR   r(   r     s    r   c                      s:   e Zd ZeddZd fddZeedddZ  Z	S )SourceSetModuleZ	sourcesetz0.51.0r>   r   c                   s"   t  | | jd| ji d S )N
source_set)rB   rC   rI   rJ   r   rP   rR   r'   r(   rC   %  s   
zSourceSetModule.__init__ri   r   rT   r~   rk   r   rV   r=   c                 C  s
   t | jS rX   )r=   r>   r   r'   r'   r(   r   +  s   
zSourceSetModule.source_setr   )ri   r   rT   r~   rk   r   rV   r=   )
r#   r$   r%   r   INFOrC   r   r   r   r   r'   r'   rR   r(   r   !  s    
r   interpr   rV   c                 C  s   t | S rX   )r   )r   r'   r'   r(   
initialize0  s   r   )r   r   rV   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_CHECKINGZtyping_extensionsr   r   r>   r   r   r   r   r*   r,   r   r\   rZ   r2   r&   
NamedTupler3   r:   r;   r=   r   r   r   r'   r'   r'   r(   <module>   s>     /