
    -Pho                        U d Z ddlmZ ddlZddlZddlZddlZej        rddl	m
Z
mZ  ej        d          Zd d
Zi Zded<   d!dZd"dZd#dZd$dZd%dZdS )&zyAccumulator for p1689r5 module dependencies.

See: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html
    )annotationsN   )DescriptionRulez[$ :\n]textstrreturnc                    t                               |           s| S d| v r't          j        d|  d          }t	          |          t                               d|           S )N
zT            Ninja does not support newlines in rules. The content was:

            zQ

            Please report this error with a test case to the Meson bug tracker.z$\g<0>)
_QUOTE_PATsearchtextwrapdedentRuntimeErrorsub)r   errmsgs     `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mesonbuild/scripts/depaccumulate.pyquoter      sz    T"" t|| "S "S "S "S T T 6""">>)T***    zT.Dict[str, str]_PROVIDER_CACHErulesT.List[Rule]nameT.Optional[str]c                    |t           v rt           |         S | D ]?}|                    dg           D ]&}|d         |k    r|d         }|t           |<   |c c S '@dS )a  Get the object that a module from another Target provides

    We must rely on the object file here instead of the module itself, because
    the object rule is part of the generated build.ninja, while the module is
    only declared inside a dyndep. This creates for the dyndep generator to
    depend on previous dyndeps as order deps. Since the module
    interface file will be generated when the object is generated we can rely on
    that in proxy and simplify generation.

    :param rules: The list of rules to check
    :param name: The logical-name to look for
    :raises RuntimeError: If no provider can be found
    :return: The object file of the rule providing the module
    provideslogical-nameprimary-outputN)r   get)r   r   rpobjs        r   get_providerr#   )   s      t$$  z2&& 	 	A D((()(+%




 )	
 4r   extra_rules>T.Iterable[T.Tuple[str, T.Optional[T.List[str]], T.List[str]]]c              #  4  K   | D ]}d}g }d|v rd |d         D             }d|v re|d         D ]\}|                     d          }||                    |           /t          ||d                   }|r|                    |           ]|d         ||fV  dS )a	  Process the rules for this Target

    :param rules: the rules for this target
    :param extra_rules: the rules for all of the targets this one links with, to use their provides
    :yield: A tuple of the output, the exported modules, and the consumed modules
    Nr   c                    g | ]
}|d          S )compiled-module-path ).0r!   s     r   
<listcomp>z!process_rules.<locals>.<listcomp>R   s    HHH!A,-HHHr   requiresr(   r   r   )r   appendr#   )r   r$   ruleprovreqr!   modfilefounds           r   process_rulesr3   E   s        0 0(,HHtJ7GHHHD*% 	* 	*%% 677&JJw'''' )a6GHHE *

5)))#$dC/////!0 0r   filesT.Optional[T.List[str]]c                R    | r$d                     d | D                       }d| S dS )N c              3  4   K   | ]}t          |          V  d S )N)r   )r*   fs     r   	<genexpr>zformatter.<locals>.<genexpr>c   s(      //AuQxx//////r   z|  )join)r4   fmts     r   	formatterr>   a   s;     hh///////Czz2r   outfiledescr   intc                T   t          | dd          5 }|                    d           t          |d         |          D ]P\  }}}t          |          }t          |          }|                    dt	          |           d| d| d	           Q	 d d d            n# 1 swxY w Y   d
S )Nwutf-8encodingzninja_dyndep_version = 1

r   zbuild r7   z	: dyndep z

r   )openwriter3   r>   r   )	r?   r@   r$   r9   r"   r   r,   insouts	            r   genrK   h   s   	gsW	-	-	- C	.///'4T']K'P'P 	C 	C#C8H%%CH%%CGGAU3ZZAA#AAAAABBBB	CC C C C C C C C C C C C C C C 1s   A=BB!$B!argsT.List[str]c                   t          |           dk    s
J d            | ^}}}t          |dd          5 }t          j        |          }d d d            n# 1 swxY w Y   |d                                         }|D ]Z}t          |d          5 }t          j        |          }|                    |d                    d d d            n# 1 swxY w Y   [t          |||          S )N   zgot wrong number of arguments!r    rD   rE   r   )lenrG   jsonloadcopyextendrK   )	rL   r?   jsonfilejsondepsr9   r@   r   depds	            r   runrY   t   s_   t99>>>;>>>#' GX	hg	.	.	. )! IaLL) ) ) ) ) ) ) ) ) ) ) ) ) ) ) M  E % %#((( 	%A!Yq\\ALL7$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% we$$$s#   AAA0CC	C	)r   r   r	   r   )r   r   r   r   r	   r   )r   r   r$   r   r	   r%   )r4   r5   r	   r   )r?   r   r@   r   r$   r   r	   rA   )rL   rM   r	   rA   )__doc__
__future__r   rQ   rer   typingTTYPE_CHECKINGdepscanr   r   compiler   r   r   __annotations__r#   r3   r>   rK   rY   r)   r   r   <module>rc      s    
 # " " " " "  				     ? +******** RZ
##
+ + + + %' & & & &   80 0 0 08   	 	 	 	% % % % % %r   