
    擖g                     0    S r SSKrS r " S S5      rS rg)zPython module for generating .ninja files.

Note that this is emphatically not a required piece of Ninja; it's
just a helpful utility for build-file-generation systems that already
use Python.
    Nc                 f    U R                  SS5      R                  SS5      R                  SS5      $ )Nz$ z$$  :z$:replace)words    2/usr/lib/python3/dist-packages/gyp/ninja_syntax.pyescape_pathr
      s-    <<e$,,S$7??TJJ    c                       \ rS rSrSS jrS rS rSS jrS r        SS jr	 SS	 jr
S
 rS rS rS rSS jrS rSrg)Writer   c                     Xl         X l        g Noutputwidth)selfr   r   s      r	   __init__Writer.__init__   s    
r   c                 :    U R                   R                  S5        g )N
)r   write)r   s    r	   newlineWriter.newline   s    $r   c                     [         R                  " XR                  S-
  5       H$  nU R                  R	                  SU-   S-   5        M&     g )N   z# r   )textwrapwrapr   r   r   )r   textlines      r	   commentWriter.comment   s8    MM$

Q7DKKdTkD01 8r   c                     Uc  g [        U[        5      (       a  SR                  [        S U5      5      nU R	                  U SU 3U5        g )Nr   z = )
isinstancelistjoinfilter_line)r   keyvalueindents       r	   variableWriter.variable   sE    =eT""HHVD%01E

cU#eW%v.r   c                 N    U R                  SU-  5        U R                  SUSS9  g )Nzpool %sdepth   r,   r)   r-   )r   namer0   s      r	   poolWriter.pool&   s%    

9t#$guQ/r   Nc                    U R                  SU-  5        U R                  SUSS9  U(       a  U R                  SUSS9  U(       a  U R                  SUSS9  U(       a  U R                  SSSS9  U(       a  U R                  S	USS9  U(       a  U R                  S
SSS9  U(       a  U R                  SUSS9  U	(       a  U R                  SU	SS9  U
(       a  U R                  SU
SS9  g g )Nzrule %scommandr1   r2   descriptiondepfile	generator1r5   restatrspfilerspfile_contentdepsr3   )r   r4   r8   r9   r:   r;   r5   r=   r>   r?   r@   s              r	   ruleWriter.rule*   s     	

9t#$i3MM-QM?MM)WQM7MM+s1M5MM&$qM1MM(CM2MM)WQM7MM+_QMGMM&$qM1 r   c           	         U R                  U5      nU R                  U5      S S  n[        [        [        U5      5      n[        [        [        U5      5      nU(       aA  [        [        U R                  U5      5      nUR	                  S5        UR                  U5        U(       aA  [        [        U R                  U5      5      nUR	                  S5        UR                  U5        U R                  SR                  SR                  U5      SR                  U/U-   5      5      5        U(       aU  [        U[        5      (       a  [        UR                  5       5      n	O[        U5      n	U	 H  u  pU R                  XSS9  M     U$ )N|z||zbuild {}: {}r   r1   r2   )_as_listr&   mapr
   appendextendr)   formatr'   r%   dictiteritemsr-   )r   outputsrA   inputsimplicit
order_only	variables
all_inputsout_outputsiteratorr*   vals               r	   buildWriter.buildJ   s3    --(]]6*1-
3{G45#k:67
;h(?@Hc"h'[$--
*CDJd#j)

!!#((;"74&:BU9VW	
 )T**	 12	?$cq1 % r   c                 ,    U R                  SU-  5        g )Nz
include %sr)   r   paths     r	   includeWriter.includej   s    

<$&'r   c                 ,    U R                  SU-  5        g )Nzsubninja %srY   rZ   s     r	   subninjaWriter.subninjam   s    

=4'(r   c                 h    U R                  SSR                  U R                  U5      5      -  5        g )Nz
default %sr   )r)   r'   rE   )r   pathss     r	   defaultWriter.defaultp   s%    

<#((4==+?"@@Ar   c                 d    SnUS-
  nUS:  a"  X   S:X  a  US-  nUS-  nUS:  a
  X   S:X  a  M  U$ )z<Returns the number of '$' characters right in front of s[i].r   r1   $ )r   sidollar_countdollar_indexs        r	   _count_dollars_before_index"Writer._count_dollars_before_indexs   sP    1uQ1?c#9ALAL Q1?c#9 r   c                    SU-  n[        U5      [        U5      -   U R                  :  a  U R                  [        U5      -
  [        S5      -
  nUn UR                  SSU5      nUS:  d  U R                  X5      S-  S:X  a  OM4  US:  a<  US-
  n UR	                  SUS-   5      nUS:  d  U R                  X5      S-  S:X  a  OM6  US:  a  OYU R
                  R                  X1SU -   S-   5        XS-   S nSUS-   -  n[        U5      [        U5      -   U R                  :  a  M  U R
                  R                  X1-   S	-   5        g)
z3Write 'text' word-wrapped at self.width characters.z  z $r   r   r   r1   z $
Nr   )lenr   rfindrl   findr   r   )r   r    r,   leading_spaceavailable_spacespaces         r	   r)   Writer._line|   sZ   v- 3t9,tzz9
 #jj3}+==D	IO#E

35119 @ @ MPQ QUV V 
 qy'!+ IIc5195E	;;DH1LPQQ  qyKKm1Um;fDE	$D !FQJ/M= - 3t9,tzz9@ 	-.56r   c                 @    Uc  / $ [        U[        5      (       a  U$ U/$ r   )r%   r&   )r   inputs     r	   rE   Writer._as_list   s%    =IeT""Lwr   r   )N   )r   )NNFNFNNN)NNNN)__name__
__module____qualname____firstlineno__r   r   r"   r-   r5   rA   rV   r\   r_   rc   rl   r)   rE   __static_attributes__rg   r   r	   r   r      sh     2/0 2B UY@()B#7Jr   r   c                 @    SU ;  d   S5       eU R                  SS5      $ )z^Escape a string such that it can be embedded into a Ninja file without
further interpretation.r   z$Ninja syntax does not allow newlinesrf   z$$r   )strings    r	   escaper      s)     vEEE>>#t$$r   )__doc__r   r
   r   r   rg   r   r	   <module>r      s'   
 KS Sl%r   