o
    ™æVc`  ã                   @  s.  d dl mZ d dlZd dlZddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZ ejr‰dd
lmZ ddlmZ ddlmZ ddlmZ ejg ef Zejdeejeejf eje geje f Zejdeejeejf geje f Z ejdef Z!G dd„ dƒZ"ddd„Z#dS )é    )ÚannotationsNé   )ÚDependencyExceptionÚDependencyMethods©Úprocess_method_kw)ÚBuiltinDependencyÚSystemDependency)ÚCMakeDependency)ÚExtraFrameworkDependency)ÚPkgConfigDependency)ÚExternalDependency)ÚConfigToolDependencyé   )ÚEnvironment)ÚMachineChoicer   .c                   @  sJ   e Zd ZdZddededdeeedœ
d+dd„Z	e
d,d$d%„ƒZd-d)d*„ZdS ).ÚDependencyFactorya2  Factory to get dependencies from multiple sources.

    This class provides an initializer that takes a set of names and classes
    for various kinds of dependencies. When the initialized object is called
    it returns a list of callables return Dependency objects to try in order.

    :name: The name of the dependency. This will be passed as the name
        parameter of the each dependency unless it is overridden on a per
        type basis.
    :methods: An ordered list of DependencyMethods. This is the order
        dependencies will be returned in unless they are removed by the
        _process_method function
    :*_name: This will overwrite the name passed to the corresponding class.
        For example, if the name is 'zlib', but cmake calls the dependency
        'Z', then using `cmake_name='Z'` will pass the name as 'Z' to cmake.
    :*_class: A *type* or callable that creates a class, and has the
        signature of an ExternalDependency
    :system_class: If you pass DependencyMethods.SYSTEM in methods, you must
        set this argument.
    N)
Úextra_kwargsÚpkgconfig_nameÚpkgconfig_classÚ
cmake_nameÚcmake_classÚconfigtool_classÚframework_nameÚframework_classÚbuiltin_classÚsystem_classÚnameÚstrÚmethodsúT.List[DependencyMethods]r   úT.Optional[T.Dict[str, T.Any]]r   úT.Optional[str]r   ú'T.Type[PkgConfigDependency]'r   r   ú7'T.Union[T.Type[CMakeDependency], CmakeDependencyFunc]'r   ú*'T.Optional[T.Type[ConfigToolDependency]]'r   r   ú"'T.Type[ExtraFrameworkDependency]'r   ú'T.Type[BuiltinDependency]'r   ú'T.Type[SystemDependency]'c       
         C  s¨   t j|v r|stdƒ‚|pi | _|| _t jt |
|	p|¡t jt ||p$|¡t j	t ||p-|¡t j
t ||¡t jt ||¡t jd i| _|d urRt ||¡| jt j< d S d S )Nz%A configtool must have a custom class)r   ZCONFIG_TOOLr   r   r   ÚEXTRAFRAMEWORKÚ	functoolsÚpartialZ	PKGCONFIGZCMAKEZSYSTEMZBUILTINÚclasses)Úselfr   r   r   r   r   r   r   r   r   r   r   r   © r.   ú~home/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/mesonbuild/dependencies/factory.pyÚ__init__P   s   
øýÿzDependencyFactory.__init__Úmethodr   Úenvú'Environment'Úfor_machiner   ÚreturnÚboolc                 C  s    | t ju r|j|  ¡ sdS dS )a%  Report whether a method is valid or not.

        If the method is valid, return true, otherwise return false. This is
        used in a list comprehension to filter methods that are not possible.

        By default this only remove EXTRAFRAMEWORK dependencies for non-mac platforms.
        FT)r   r)   ZmachinesZ	is_darwin)r1   r2   r4   r.   r.   r/   Ú_process_methodq   s
   

ÿz!DependencyFactory._process_methodÚkwargsúT.Dict[str, T.Any]úT.List['DependencyGenerator']c                   s8   t ˆj|ƒ}ˆj ¡ ‰ˆ |¡ ‡ ‡‡‡fdd„|D ƒS )zBReturn a list of Dependencies with the arguments already attached.c                   s.   g | ]}ˆ  |ˆ ˆ¡rt ˆj| ˆ ˆ¡‘qS r.   )r7   r*   r+   r,   )Ú.0Úm©r2   r4   Znwargsr-   r.   r/   Ú
<listcomp>‡   s    ÿz.DependencyFactory.__call__.<locals>.<listcomp>)r   r   r   ÚcopyÚupdate)r-   r2   r4   r8   r   r.   r=   r/   Ú__call__€   s   

zDependencyFactory.__call__)r   r   r   r    r   r!   r   r"   r   r#   r   r"   r   r$   r   r%   r   r"   r   r&   r   r'   r   r(   )r1   r   r2   r3   r4   r   r5   r6   ©r2   r3   r4   r   r8   r9   r5   r:   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r   r   r	   r0   Ústaticmethodr7   rA   r.   r.   r.   r/   r   9   s     ö!r   r   úT.Set[DependencyMethods]r5   ú1T.Callable[['FactoryFunc'], 'WrappedFactoryFunc']c                   s   d‡ fdd„}|S )	a†  Decorator for handling methods for dependency factory functions.

    This helps to make factory functions self documenting
    >>> @factory_methods([DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE])
    >>> def factory(env: Environment, for_machine: MachineChoice, kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
    >>>     pass
    Úfuncú'FactoryFunc'r5   ú'WrappedFactoryFunc'c                   s   t  ˆ ¡d‡ ‡fd	d
„ƒ}|S )Nr2   r3   r4   r   r8   r9   r5   r:   c                   s   ˆ | ||t ˆ|ƒƒS )Nr   )r2   r4   r8   )rJ   r   r.   r/   Úwrapped–   s   z/factory_methods.<locals>.inner.<locals>.wrappedrB   )r*   Úwraps)rJ   rM   ©r   )rJ   r/   Úinner”   s   zfactory_methods.<locals>.innerN)rJ   rK   r5   rL   r.   )r   rP   r.   rO   r/   Úfactory_methods‹   s   	rQ   )r   rH   r5   rI   )$Ú
__future__r   r*   ÚtypingÚTÚbaser   r   r   r   r	   Zcmaker
   Z	frameworkr   Z	pkgconfigr   ÚTYPE_CHECKINGr   Z
configtoolr   Úenvironmentr   Zmesonlibr   ÚCallableZDependencyGeneratorÚDictr   ÚAnyÚListZFactoryFuncZWrappedFactoryFuncZCmakeDependencyFuncr   rQ   r.   r.   r.   r/   Ú<module>   sF   üúÿ
ýûÿR