o
    8cD/                     @  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'   {home/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/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Z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(   r2   <   s   
 r2   c                   @  r)   )SourceFilesz@OrderedSet[T.Union[mesonlib.FileOrString, build.GeneratedTypes]]r6   z#OrderedSet[dependencies.Dependency]r5   Nr"   r'   r'   r'   r(   r9   Q   s   
 r9   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__rulesZ
subprojectenvironmentZsubdirfrozenmethodsupdate
add_methodadd_all_methodall_sources_methodall_dependencies_methodapply_methodselfr=   	__class__r'   r(   rB   _   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_outputsZcheck_direntry_issues)rN   rQ   r6   r5   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 rU   )rV   rY   rX   )rN   rQ   r3   r5   r^   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)	rE   r   anyr   rc   r`   rC   rX   r2   )rN   re   rQ   rg   r   r   r!   r3   r
   r6   r7   _r'   r'   r(   rH      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 ]}t|ts4t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 argumentsz:Arguments to 'add_all' after the first must be source setsT)	rE   r   r   rc   rV   r<   rC   rX   r2   )	rN   re   rQ   rg   r   r   r3   r
   r_   r'   r'   r(   rI      s   

zSourceSetImpl.add_all_methodN
enabled_fnT.Callable[[str], bool]r?   r-   intoT.Optional['SourceFiles']r9   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 rU   )found).0r^   r'   r'   r(   	<genexpr>       z(SourceSetImpl.collect.<locals>.<genexpr>c                 3  s    | ]} |V  qd S rU   r'   )rq   keyrl   r'   r(   rr      rs   )r9   r   rC   allr5   r3   r6   rG   r7   r8   collectr!   )rN   rl   r?   rn   entryssr'   ru   r(   rw      s   

zSourceSetImpl.collectT.List[TYPE_var]r   r    c                 C      d| _ | dd d}t|jS )NTc                 S     dS NTr'   r^   r'   r'   r(   <lambda>       z2SourceSetImpl.all_sources_method.<locals>.<lambda>)rE   rw   listr6   rN   re   rQ   rg   filesr'   r'   r(   rJ      s   
z SourceSetImpl.all_sources_methodz$source_set.all_dependencies() methodz0.52.0r4   c                 C  r{   )NTc                 S  r|   r}   r'   r~   r'   r'   r(   r      r   z7SourceSetImpl.all_dependencies_method.<locals>.<lambda>)rE   rw   r   r5   r   r'   r'   r(   rK      s   
z%SourceSetImpl.all_dependencies_methodzsourceset.applyr.   )r0   @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.   rt   rY   rS   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)rV   dictr   r-   getrt   )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)rV   r	   ConfigurationDatar-   r   r   r   Zconfig_cacher   r.   r'   r(   r      s   F)rt   rY   rS   r-   )rE   rV   r   rw   r   )rN   re   rQ   rg   r   r   resr'   r   r(   rL      s   
zSourceSetImpl.apply_methodr=   r   )rQ   rR   rS   rT   )rQ   ra   rS   rb   )re   r   rQ   rf   rg   r   rS   rh   )re   r   rQ   rk   rg   r*   rS   rh   rU   )rl   rm   r?   r-   rn   ro   rS   r9   re   r   rQ   rz   rg   r   rS   r    re   r   rQ   rz   rg   r   rS   r4   )re   r   rQ   r   rg   r,   rS   r   )#r#   r$   r%   rB   r`   rc   r   rY   r   rZ   r	   ZGeneratedListZCustomTargetZCustomTargetIndexr
   rW   r   r1   r   r   r   rH   r:   rI   rw   r   r   rJ   r   rK   r   r   r-   rL   __classcell__r'   r'   rO   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   r9   c                   s*   t    || _| j| j| jd d S )N)r6   r
   )rA   rB   r   rF   rG   sources_methoddependencies_method)rN   r   rO   r'   r(   rB     s   
zSourceFilesObject.__init__re   r   rQ   rz   rg   r   rS   r    c                 C     t | jjS rU   )r   r   r6   rN   re   rQ   rg   r'   r'   r(   r        z SourceFilesObject.sources_methodr4   c                 C  r   rU   )r   r   r5   r   r'   r'   r(   r     r   z%SourceFilesObject.dependencies_method)r   r9   r   r   )	r#   r$   r%   rB   r   r   r   r   r   r'   r'   rO   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)rA   rB   rF   rG   r   rM   rO   r'   r(   rB   '  s   
zSourceSetModule.__init__re   r   rQ   rz   rg   r   rS   r<   c                 C  s
   t | jS rU   )r<   r=   r   r'   r'   r(   r   -  s   
zSourceSetModule.source_setr   )re   r   rQ   rz   rg   r   rS   r<   )
r#   r$   r%   r   INFOrB   r   r   r   r   r'   r'   rO   r(   r   #  s    
r   interpr   rS   c                 C  s   t | S rU   )r   )r   r'   r'   r(   
initialize2  s   r   )r   r   rS   r   )1
__future__r   typingT r   r   r   r   r	   r
   r   Zinterpreterbaser   r   r   r   r   r   Zinterpreterbase.decoratorsr   r   r   r   r   TYPE_CHECKINGtyping_extensionsr   r   r=   r   r   r   r   r*   r,   r   rY   rW   r1   r&   
NamedTupler2   r9   r:   r<   r   r   r   r'   r'   r'   r(   <module>   s>     1