
    Kb                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZ	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ g dZddgZg dZ e       ai Zi Z	 efZ	 ee fZ!ee!z   Z"e"e#fz   Z$d	 Z%g d
Z&g a'g dZ(da)da*dQdZ+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3 G d de4      Z5 G d de6      Z7d Z8 ed      Z9ddddZ:d  Z;d! Z< e
jz                  d"      Z> e
jz                  d#      Z? e
jz                  d$      Z@i ZAd% ZBd ZCd&ZDd'ZEd( ZFi ZGd) ZHd* ZId+ ZJd, ZKd- ZL	 dQd.ZMd/ ZNd0 ZOd1 ZPd2 ZQd3 ZRd4 ZSd5 ZTd6 ZUd7 ZV G d8 d9e6      ZWd: ZXd; ZYd< ZZd= Z[ e
jz                  d>      Z\d? Z]dRd@Z^dA Z_dB Z`dC ZadD ZbdE ZcdF ZddG ZedH ZfdI ZgdJ ZhdK ZidL ZjdM ZkdN ZldO ZmdP Zny# e$ r efZY Kw xY w# e$ r efZ!Y Uw xY w)S    )print_functionN)GypError)
OrderedSet)
executableshared_libraryloadable_modulemac_kernel_extensionwindows_driverdependenciesexport_dependent_settings)destinationfilesinclude_dirsinputs	librariesoutputssourcesc                     | r| dd  dv r| d d } | r| dd  dv r| t         v ryd| v r"| dd  }|d   dk(  r|d d }|dd  dv ry|d	d  d
k(  S y)Nz=+?!T_is)_file_path_dirF)path_sections)sectiontails     +/usr/lib/python3/dist-packages/gyp/input.pyIsPathSectionr!   J   s     	GBCLF*crlG 	GBCLF*  	G^23<DBx3#2YdBCy&&9	    )actionsall_dependent_settingsconfigurationscopiesdefault_configurationr   dependencies_originaldirect_dependent_settingsr   
postbuildsproduct_dirproduct_extensionproduct_nameproduct_prefixrulesrun_asr   standalone_static_librarysuppress_wildcardtarget_nametoolsettoolsetstype	variables)r#   r$   r%   r   r)   r   link_settingsr   r1   r3   r6   Fc                     |dk(  rg }| |v r|S |j                  |        ||    j                  dg       D ]  }t        |||        |S )a  Return a list of all build files included into build_file_path.

  The returned list will contain build_file_path as well as all other files
  that it included, either directly or indirectly.  Note that the list may
  contain files that were included into a conditional section that evaluated
  to false and was not merged into build_file_path's dict.

  aux_data is a dict containing a key for each build file or included build
  file.  Those keys provide access to dicts whose "included" keys contain
  lists of all other files included by the build file.

  included should be left at its default None value by external callers.  It
  is used for recursion.

  The returned list will not contain any duplicate entries.  Each build file
  in the list will be relative to the current directory.
  Nincluded)appendgetGetIncludedBuildFiles)build_file_pathaux_datar:   included_build_files       r    r=   r=      sb    & H O
///"%o6:::rJ C-xBC 
/r"   c                 
   t        j                  |       }t        |t         j                        sJ |j                  }t        |      dk(  sJ |d   }t        |t         j                        sJ t        |j                  g       S )zReturn the eval of a gyp file.

  The gyp file is restricted to dictionaries and lists only, and
  repeated keys are not allowed.

  Note that this is slower than eval() is.
     r   )	astparse
isinstanceModulebodylenExpr	CheckNodevalue)file_contentssyntax_treec1c2s       r    CheckedEvalrP      so     		-(+	K	,,	,"	RA	!u"	B	!!	!	288R	  r"   c           	      X   t        | t        j                        ri }t        | j                  | j
                        D ]  \  }}t        |t        j                        sJ |j                  }||v rAt        d|z   dz   t        t        |      dz         z   dz   dj                  |      z   dz         t        |      }|j                  |       t        ||      ||<    |S t        | t        j                        rag }t!        | j"                        D ]E  \  }}t        |      }|j                  t        |             |j                  t        ||             G |S t        | t        j                        r| j                  S t%        ddj                  |      z   dz   t        |       z         )	NzKey 'z' repeated at level rB   z with key path '.'zUnknown AST node at key path 'z': )rE   rC   DictzipkeysvaluesStrr   r   reprrH   joinlistr;   rJ   List	enumerateelts	TypeError)	nodekeypathdictkeyrK   kpchildrenindexchilds	            r    rJ   rJ      s   chhD$))T[[1 	'
USWW%%%EEc	w}'==3w<!#$%'9:hhw "%& ' 	' =biinE2&d3i	' K$!H!$)), ,u=biiUooir*+, O$ 66M
4sxx7HH	d  r"   c                    | |v r||    S t         j                  j                  |       r*t        | d      j	                         j                  d      }n#t        | dt        j                         d      d }	 |rt        |      }nt        |di id       }t!        |      t"        urt        d| z        ||| <   i || <   d|vs|d   s(	 |rt%        || ||||       |S t%        || ||d |       	 |S |S # t        $ r}| |_         d }~wt        $ r)}t        j                  j                  |d| z           d }~ww xY w# t        $ r)}t        j                  j                  |d	| z           d }~ww xY w)
Nrbutf-8z not found (cwd: )__builtins__zwhile reading z%%s does not evaluate to a dictionary.skip_includeszwhile reading includes of )ospathexistsopenreaddecoder   getcwdrP   evalSyntaxErrorfilename	ExceptiongypcommonExceptionAppendr6   rb   LoadBuildFileIncludesIntoDict)	r>   datar?   includes	is_targetcheckbuild_file_contentsbuild_file_dataes	            r    LoadOneBuildFiler      s     WW^^O$5::<CCGL
		L
MM/

#$78o0>22FMo 
/$&
:_L
MM)$ (? _,
/
*
	%o&.%	A 
 	&o&.e	= 
9 
 
 AJ		 
JJq"2_"DE	
(  	jj  !=!OQsB   9C2 	D; D; 2	D8;DD8$D33D8;	E-$E((E-c                    g }|d k7  r|j                  |       d| v rx| d   D ]m  }t        j                  j                  t        j                  j	                  t        j                  j                  |      |            }|j                  |       o | d= |D ]i  }d||   vrg ||   d<   ||   d   j                  |       t        j                  t        j                  d|       t        | t        |||d d|      ||       k | j                         D ]H  \  }	}
t        |
      t        u rt        |
|||d |       (t        |
      t         u s:t#        |
||||       J y )Nr~   r:   zLoading Included File: '%s'F)extendrn   ro   normpathrZ   dirnamer;   ry   DebugOutputDEBUG_INCLUDES
MergeDictsr   itemsr6   rb   r|   r[   LoadBuildFileIncludesIntoList)subdictsubdict_pathr}   r?   r~   r   includes_listincluderelative_includekvs              r    r|   r|     s]   -"7:& -
 ''

277<<(EwO
P +,- 	
  	&g,//+-h|Z(\:&--g6OOC&&(EwOwxueLW&	& mmo +daAw$#A|T8$(%1	aD#A|T8$)++r"   c           	          | D ]E  }t        |      t        u rt        ||||d |       %t        |      t        u s7t	        |||||       G y N)r6   rb   r|   r[   r   )sublistsublist_pathr}   r?   r   items         r    r   r   C  sP     OdDzT#D,h$(%1	dt	#D,hNOr"   c                    d| v r| d   }g }|D ]  }d|v rd|vr|j                  |       t        r|j                  ddg      }ndg}d|v r|d= t        |      dkD  sP|dd  D ]7  }t        j
                  j                  |      }||d<   |j                  |       9 |d   |d<   |j                  |        || d<   d| v rD| d   D ];  }t        |      t        u s|dd  D ]  }t        |      t        u st        |       ! = y y )Ntargetsr4   r5   targetr   rB   
conditions)r;   multiple_toolsetsr<   rH   ry   simple_copydeepcopyr6   r[   rb   ProcessToolsetsInDict)	r}   target_listnew_target_listr   r5   build
new_target	conditioncondition_dicts	            r    r   r   M  sB   $y/KO ' 
f	6!9v&	::j8*5:	v	:	X	ab\ 	-E//7*"'*Y


 
 
,	- %QKyv&)'* &DOT,' 2		iD	 'm 	2N.!T)!.1	22 r"   c                    |r]t         j                  j                  |t        j                  j                  |             }|dk(  rd|d<   n|j                  dd      |d<   d|v r| |d   v ry|d   j                  |        t        j                  t         j                  d|        t        | |||d	|      }	||	d
<   d|	v rt        | dz         t        | |      }
g |	d<   |
D ]S  }t         j                  j                  |t        j                  j                  |             }|	d   j                  |       U t        |	       t        |	t         ||        t        |	       d|	v rd|	vrt        d| z        d}|t#        |	d         k  rW|	d   |   }t         j$                  j'                  |	d         }t)        ||| |        ||	d   |<   |dz  }|t#        |	d         k  rW|	d= g }d|	v rL|	d   D ]D  }d|vr|d   D ]5  }|j                  t         j                  j+                  | |d       d          7 F |r|D ]  }	 t-        ||||||||        y | |fS # t.        $ r)}t         j                  j1                  |d| z          d }~ww xY w)N rR   DEPTH\/target_build_filesFzLoading Target Build File '%s'T_DEPTHincluded_filesz$ must not contain included_files keytarget_defaultsr   z'Unable to find targets in build file %sr   rB   r   z while loading dependencies of %s)ry   rz   RelativePathrn   ro   r   replaceaddr   r   r   r   r=   r;   r   #ProcessVariablesAndConditionsInDictPHASE_EARLYrH   r   r   r   ResolveTargetLoadTargetBuildFilerx   r{   )r>   r}   r?   r7   r~   depthr   load_dependenciesdr   r:   included_fileincluded_relativerf   old_target_dictnew_target_dictr   target_dict
dependencyr   s                       r    r   r   r  s     	

rww'GHABwi99T3/i T!$344	""?3//#$$2OE %_dH%-tU</ $/( (
?%KK
LL"?H=(&(/"# @m 	

 " @	B  $%,,->?@ ( &{I@
 ( /)'>$% & & E
#oi01
1 (	259o00)*,o/ /3*9oi 'qje #oi01
1" 	)* ,/!&y1 L	{	*#N3 L*JJ$$_j$GJ	LLL " 
Jh	$eU4E	G \**  

""
//A	Cs   :I	J$J  Jc           
      f   	 t        j                   t         j                  t         j                         | j                         D ]  \  }}|t	               |<    t        |       t        |t        t        ||||d      }	|	s|	S |	\  }}
t        j                  |      }|||
fS # t        $ r,}t        j                  j                  d|z         Y d}~yd}~wt        $ rS}t        d|t        j                         t        t!        j"                         t        j                         Y d}~yd}~ww xY w)zWrapper around LoadTargetBuildFile for parallel processing.

     This wrapper is used when LoadTargetBuildFile is executed in
     a worker process.
  Fzgyp: %s
Nz
Exception:)file)signalSIGINTSIG_IGNr   globalsSetGeneratorGlobalsr   per_process_dataper_process_aux_datapopr   sysstderrwriterx   print	traceback
format_exc)global_flagsr>   r7   r~   r   r   generator_input_inforc   rK   resultr   r   r   s                r    CallLoadTargetBuildFiler     s    
MM&--0 #((* 
Ugin ,- 2B!5y!)5%@F m&,#_l
 '**?;O   
 JJ[1_%	 	,

+	)


 szz2s+   A?B! B! !	D0*"CD0A	D++D0c                       e Zd Zy)ParallelProcessingErrorN__name__
__module____qualname__ r"   r    r   r     s    r"   r   c                       e Zd ZdZd Zd Zy)ParallelStatea  Class to keep track of state when processing input files in parallel.

  If build files are loaded in parallel, use this to keep track of
  state during farming out and processing parallel jobs. It's stored
  in a global so that the callback function can have access to it.
  c                 v    d | _         d | _        d | _        d| _        t	               | _        g | _        d| _        y )Nr   F)poolr   r}   pendingset	scheduledr   errorselfs    r    __init__zParallelState.__init__  s<    DI DNDI DL UDNDDJr"   c                 D   | j                   j                          |s<d| _        | j                   j                          | j                   j	                          y|\  }}}|| j
                  |<   | j
                  d   j                  |       |D ]G  }|| j                  vs| j                  j                  |       | j                  j                  |       I | xj                  dz  c_
        | j                   j                          | j                   j	                          y)zJHandle the results of running LoadTargetBuildFile in another process.
    TNr   rB   )r   acquirer   notifyreleaser}   r   r   r   r;   r   )r   r   build_file_path0build_file_data0dependencies0new_dependencys         r    LoadTargetBuildFileCallbackz)ParallelState.LoadTargetBuildFileCallback1  s     	NNdj
nn
nn:@7'"2DIIII"#''(89' 1	t~~	->*  01 	LLALNNNNr"   N)r   r   r   __doc__r   r   r   r"   r    r   r     s    &r"   r   c           
      z   t               }t        j                         |_        t	        |       |_        t        |       |_        d|_        ||_	        	 |j                  j                          |j
                  s|j                  r|j                  rn|j
                  s|j                  j                          N|j
                  j                         }|xj                  dz  c_        t               d   t               d   t               d   d}	|j                  s,t!        j"                  t!        j$                               |_        |j                  j'                  t(        |	||||||f|j*                         |j
                  r|j                  r|j                  j1                          |j                  j3                          |j                  j5                          d |_        |j                  rt7        j8                  d       y y # t,        $ r!}
|j                  j/                          |
d }
~
ww xY w)Nr   rB   r   non_configuration_keysr   )r   r   r   )argscallback)r   	threading	Conditionr   r[   r   r   r   r   r}   r   r   waitr   r   r   multiprocessingPool	cpu_countapply_asyncr   r   KeyboardInterrupt	terminater   closerZ   r   exit)build_filesr}   r7   r~   r   r   r   parallel_stater   r   r   s              r    LoadTargetBuildFilesParallelr  F  s    ?.&002. $[ 1. -...$$&

%
%)?)?			((  %%'!..224j! ?3")),D"E$Y':;=l
   -22?3L3L3NO%%
!
Xue5IK#??	 & A# 
%
%)?)?4 ""$.HHQK  
 !!#
Gs   D5H 
H 	H:H55H:z{[({[()}]rk   c                     g }d}t        |       D ][  \  }}|t        v r|j                  |       |dk(  s%|}(|t        v s1|s y|j	                         t        |   k7  r y|rT||dz   fc S  y)Nr   )r   r   rB   )r]   	LBRACKETSr;   BRACKETSr   )	input_strstackstartrf   chars        r    FindEnclosingBracketGroupr  |  s~    
%
%y) "keTyll4	"				&uqy!!" 
r"   c                     t        | t              r8| r6| dk(  ry| d   dk(  r| dd } | syd| d   cxk  rd	k  r| j                         S  yy)
z|Returns True if |string| is in its canonical integer form.

  The canonical form is such that str(int(string)) == string.
  0Tr   -rB   NF19)rE   
_str_typesisdigit)strings    r    IsStrCanonicalIntr    sb    
 
# 	3	c		q		 S	 ~~ 
! 
r"   zy(?P<replace>(?P<type><(?:(?:!?@?)|\|)?)(?P<command_string>[-a-zA-Z0-9_.]+)?\((?P<is_array>\s*\[?)(?P<content>.*?)(\]?)\))zy(?P<replace>(?P<type>>(?:(?:!?@?)|\|)?)(?P<command_string>[-a-zA-Z0-9_.]+)?\((?P<is_array>\s*\[?)(?P<content>.*?)(\]?)\))z|(?P<replace>(?P<type>[\^](?:(?:!?@?)|\|)?)(?P<command_string>[-a-zA-Z0-9_.]+)?\((?P<is_array>\s*\[?)(?P<content>.*?)(\]?)\))c                     t         j                  dk(  rKt        |       t        u r#t	        j
                  dd| d         g| dd  z   } | S t	        j
                  dd|       } | S )Nwin32z^cat ztype r   rB   )r   platformr6   r[   resub)cmds    r    FixupPlatformCommandr    s^    \\WCyDVVGWc!f-.QR8c 
* FF7GS)c	*r"   rB      c           	      t   |t         k(  r	t        }d}n&|t        k(  r	t        }d}n|t        k(  r	t
        }d}nJ t        |       }t        |      rt        |      S ||vr|S t        |j                  |            }|s|S |}|j                          |D ]:  }	|	j                         }
t        j                  t        j                  d|
       d|
d   v }|
d   }d	|
d   v }|	j!                  d
      }|	j#                  d
      }t%        ||d        \  }}||z   }||| }||z   dz   }|dz
  }||| }|r:t        j&                  j)                  |      }t+        ||       t-        ||||      }nt-        ||||      }|j/                         }d|
d   v xr ||k(  }|s|r(t0        j2                  j5                  |      }|dk(  r|sd }|rt7        |      t        u r|}n|j9                  d      }|d   }t0        j2                  j;                  |      rt=        d|z        t>        s!t0        j2                  jA                  |      }nt0        j2                  j;                        r*t>        d   }t        jB                  jE                  ||      }n|}t>        d   }t0        j2                  jA                  |||      }t        jB                  jG                  |       t        jB                  jE                  ||      }t        jB                  jI                  |      }|dd  D ]  }|jK                  d|z          |jM                          nS|r)d} |
d   rtO        |      }d} t        |      f}!tP        jS                  |!d       }"|"t        j                  t        j                  d||       d}|dk(  rt1        jT                         }#|rt1        jV                  |       	 tY        j8                  |      }$	 t[        |$d         }%t        |%j_                  |$dd              ja                         }t1        jV                  |#       |d k7  sJ |rt=        d|d|d      tc        |      }	 te        jf                  || td        jh                  td        jh                  td        jh                  |      }'|'jm                  d      \  }(})|'jo                         dk7  s|)rK|)jq                  d       }*tr        jt                  jK                  |*       t=        d!||'jv                  |fz        |(jq                  d       ja                         }|tP        |!<   nPt        j                  t        j                  d"||       |"}n'||vr|d#   d$v rg }nt=        d%|z   d&z   |z         ||   }t7        |      t        u rZ|D ]F  }+|d#   d'k(  rty        |+tz              rt=        d(|z   d)z   d*z   |+j|                  j~                  z          t        ||||       nDty        |tz              s4t=        d(t        |      z   d)z   d+z   |j|                  j~                  z         |r6t7        |      t        u r|d d  }nktY        j8                  t        |            }nLd},t7        |      t        u r t        jB                  j                  |      },n|},|d | t        |,      z   ||d  z   }|}= || k(  r&t        j                  t        j                  d,|       nt        j                  t        j                  d-|       t7        |      t        u r@|rt7        |d         t        u rn7g }-|D ]  }+|-j                  t-        |+|||             ! |-}nt-        ||||      }t7        |      t        u r/t        |      D ]  \  }.}/t        |/      st        |/      ||.<   ! |S t        |      rt        |      }|S # t\        $ r}&t=        d|$d   d|&      d }&~&ww xY w# t1        jV                  |#       w xY w# tj        $ r}&t=        |&d|d|      d }&~&ww xY w).N<>^FzMatches: %r!r6   command_string|r   rB   @r    r   z(| cannot handle absolute paths, got "%s"toplevelqualified_out_dirz%s
Tis_arrayz(Executing command '%s' in directory '%s'pymod_do_mainz%Error importing pymod_do_mainmodule (z): zUnknown command string 'z' in 'z'.)shellstdoutr   stdincwdz while executing command '' in rj   z1Call to '%s' returned exit status %d while in %s.z2Had cache value for command '%s' in directory '%s'r   r%  r   zUndefined variable  in r   z	Variable z- must expand to a string or list of strings; zlist contains a zfound a z?Found only identity matches on %r, avoiding infinite recursion.zFound output %r, recursing.)Dr   early_variable_re
PHASE_LATElate_variable_rePHASE_LATELATElatelate_variable_restrr  intr[   finditerreverse	groupdictry   r   DEBUG_VARIABLESr  endr  r   r   ProcessListFiltersInDictExpandVariablesstriprn   ro   r   r6   splitisabsr   generator_filelist_pathsrZ   rz   r   EnsureDirExistsWriteOnDiffr   r   ru   cached_command_resultsr<   rt   chdirshlex
__import__ImportErrorDoMainrstripr  
subprocessPopenPIPErx   communicater   rs   r   r   
returncoderE   _str_int_types	__class__r   #ProcessVariablesAndConditionsInListEncodePOSIXShellListr;   r]   )0inputphaser7   
build_filevariable_reexpansion_symbolr  matchesoutputmatch_groupmatchrun_commandr&  	file_listreplace_startreplace_endc_startc_endreplacementcontents_startcontents_endcontentsprocessed_variablesexpand_to_listbuild_file_dircontents_listro   r*  rel_build_file_dirr+  fi	use_shell	cache_keycached_valueoldwdparsed_contents	py_moduler   pp_stdoutp_stderrp_stderr_decodedr   encoded_replacement
new_outputrf   outstrs0                                                   r    rB  rB    sU   
k#K
"K&K5%j)y!y> Y& %%i01'	&
 
// {k!!#EOOC''> v&K+,N uV}$I  %%i0M//),K 1=>1JKWe  %'K M+6K #W,q0N?L5H OO44Y?x)<= 5!4jBh !5)ZHh ~~H E&M)Fi;.FNi wwz2n	2	i
  	h4	  s+!!$k	{	#AKOPP%ww||NK877==(-j9("zz66~xP
-
45HIww||-/A;O

""4(JJ++D.Ak
**
 
 
&aQR  !	
ggi	i	z	>	 x=.1i+//	4@l		++B .	2 _, ))+%HH^$
#kk(3OJ$_Q%78i i..qr/BCDKKMKHHUO$
$$((4 5 5 *(3(6  (2(2'1%3	5A  !}}R0
(HVVX]h'w7JJ-. N$allJ?@ A A 0779+,7y)++L 	1 # "B<:% +.9 ",- . .  )KD  2$|s":dN+Kx/HI+, 001 2 22 *+ui*46^4s8}4HI#$&1&;&;&D&DE F F  
k	d	"Q S-. 	k	d	" "jj==kJ)n}%,?(@@kl#$f Iw{z u_OOC''! OOC'')FOF|t	DOt+ 	
 	CD


dE9jAC	C vuiDf 
&\T"6* $v	6	"Fu$ 
-  [F	-Y  J2A!2DaI J JJ
 HHUO  6x5 6 66sI   _<1_?+_<&A`	_9 _44_99_<<`	`7`22`7c           	         t        |       t        urt        |dz         t        |       dk  r,t        |dz   | d   z   dz   t	        t        |             z         d}d}|t        |       k  r| |   }| |dz      }t        |      t
        ur%t        dj                  ||t        |                  t        |       |dz   kD  rZt        | |dz            t
        u rC| |dz      }	|d	z   }|t        |       k7  r/t        d
j                  ||t        |       |z
              d}	|dz   }|dk(  rt        |||	|||      }|t        |       k  r|S )z]Returns the dict that should be used or None if the result was
  that nothing should be used.z must be a listr   r)  r   z  must be at least length 2, not NrB   z.{} {} must be followed by a dictionary, not {}   z&{} {} has {} unexpected trailing items)r6   r[   r   rH   r:  rb   formatEvalSingleCondition)
r   conditions_keyrZ  r7   r[  rr  r   	cond_expr	true_dict
false_dicts
             r    EvalConditionr    s    
)_D 
>$55
66^a >C')A,6568;C	N8KL M M !&	C	N!I!a% IId"ELL	4	?4 5 5
9~A$yQ'7"8D"@QU#j
a%a	
c)n	?FF
)S^a%79 : 	: j
a%a~"
Y
E9jJf! 	
C	N& 
-r"   c                 j   t        | |||      }t        |t              s"t        d|j                  j
                  z         	 |t        v r
t        |   }nt        |dd      }|t        |<   t        |di i|      r|S |S # t        $ ro}t        dt        |j                  d         |j                  ||j                  fz  |j                  |j                  |j                  |j                        }	|	d}~wt         $ r6}t"        j$                  j'                  |d|d	|       t)        |      d}~ww xY w)
zMReturns true_dict if cond_expr evaluates to true, and false_dict
  otherwise.CVariable expansion in this context permits str and int only, found z<string>ru   rl   z9%s while evaluating condition '%s' in %s at character %d.r   Nzwhile evaluating condition 'r2  )rB  rE   rU  
ValueErrorrV  r   cached_conditions_astscompileru   rv   r:  r   textoffsetrw   lineno	NameErrorry   rz   r{   r   )
r  r  r  rZ  r7   r[  cond_expr_expandedast_coder   syntax_errors
             r    r  r  6  s9    'y%'13	&	7
/99BBCD D33'(:;h+Z@h3;/0H~r*I6	   2 #AFF1I
AHHM N  !zz188QXXqvvGL 	 JJq 2J#@ A
1+s+   8A= ;A= =	D2A*C00D2<1D--D2c                     |t         k(  rd}n|t        k(  rd}n|t        k(  ry J || vry | |   }| |= |D ]3  }t        |||||      }|d k7  st	        ||||       t        | |||       5 y )Nr   target_conditions)r   r6  r8  r  r   r   )the_dictrZ  r7   r[  r  conditions_listr   
merge_dicts           r    ProcessConditionsInDictr  Z  s    " k!N
(N
5	8	#
^,/~" 
?iy.%)+J T **e*3ZA :z:>
?r"   c                 f    |j                         D ]  \  }}t        |t              s|| d|z   <     y )Nr   )r   rE   _str_int_list_types)r7   r  rc   rK   s       r    LoadAutomaticVariablesFromDictr    s7     NN$ #jc5%,-"ic	#r"   c                     |j                  di       j                         D ]G  \  }}t        |t              s|j	                  d      r|d d }|| v r2|dk(  r||v r||   }n|}|| |<   I y )Nr7   %r   )r<   r   rE   r  endswith)r7   r  the_dict_keyrc   rK   variable_names         r    LoadVariablesFromVariablesDictr    s     LLb1779 %jc5e01
||C#2hm	)	#		$()B 'm$Im#%r"   c                    |j                         }t        ||        d| v r2| d   j                         D ]
  \  }}|||<    t        | d   |||d       t	        || |       | j                         D ]g  \  }}|dk7  st        |t              st        ||||      }t        |t              s(t        d|j                  j                  z   dz   |z         || |<   i |j                         }t        ||        t	        || |       t        | |||       |j                         }t        ||        t	        || |       | j                         D ]  \  }}|dk(  st        |t              rt        |      t        u rt        |||||       =t        |      t        u rt!        ||||       ]t        |t"              rnt%        d|j                  j                  z   dz   |z          y)zHandle all variable and command expansion and conditional evaluation.

  This function is the public entry point for all variable expansions and
  conditional evaluations.  The variables_in dictionary will not be modified
  by this function.
  r7   r  z for Unknown type N)copyr  r   r   r  rE   r  rB  rU  r  rV  r   r  r6   rb   r[   rW  
_int_typesr_   )	r  rZ  variables_inr[  r  r7   rc   rK   expandeds	            r    r   r     s
    !) H5H
 {+113 
Uin ((=u(1:{L !HlCNN$ jc5
kj
; y*Eh.1'11::;=DEGJKL 	L hsm !) H5 HlCD (E9jA !) H5 HlC NN$ %jc5 kZz:E{d *%	*4c;	e	
 *%	*46z*o(@(@@ #$ % %%%r"   c                 T   d}|t        |       k  r| |   }t        |      t        u rt        ||||       nt        |      t        u rt        ||||       nt        |t              rtt        ||||      }t        |t              r|| |<   nt        |      t        u r|| ||dz    |t        |      z  }t        d|j                  j                  z   dz   |z         t        |t              s(t        d|j                  j                  z   dz   |z         |dz   }|t        |       k  ry y )Nr   rB   zIVariable expansion in this context permits strings and lists only, found z at r  z
 at index )rH   r6   rb   r   r[   rW  rE   r  rB  rU  r  rV  r   r  r_   )the_listrZ  r7   r[  rf   r   r  s          r    rW  rW    s9    %HE?DDzT *$y*M	dt	)$y*M	D*	% uiDh	Hn	-">T!"*uQwX 	#%-%7%7%@%@ACIJ 	 j)o(?(??"#%*+ , ,AIE7 	Hr"   c                     i }| d   D ]Z  }| |   j                  dg       D ]@  }t        j                  j                  ||d   |d         }||v rt	        d|z         |||<   B \ |S )ay  Builds a dict mapping fully-qualified target names to their target dicts.

  |data| is a dict mapping loaded build files by pathname relative to the
  current directory.  Values in |data| are build file contents.  For each
  |data| value with a "targets" key, the value of the "targets" key is taken
  as a list containing target dicts.  Each target's fully-qualified name is
  constructed from the pathname of the build file (|data| key) and its
  "target_name" property.  These fully-qualified names are used as the keys
  in the returned dict.  These keys provide access to the target dicts,
  the dicts in the "targets" lists.
  r   r   r3   r4   z!Duplicate target definitions for )r<   ry   rz   QualifiedTargetr   )r}   r   r[  r   r3   s        r    BuildTargetsDictr  >  s     '-. $jz"&&y"5 $JJ..z/5m/D/5i/@Bk 
	:[HII#gk$$ 
.r"   c                    t         D cg c]  }dD ]  }||z   	  }}}| j                         D ]  \  }}t        j                  j	                  |      }|d   }|D ]  }|j                  |g       }	t        |	      D ]  \  }
}t        j                  j                  |||      \  }}}t        s|}t        j                  j                  |||      }||	|
<   |dk7  s_||d   vsgt        d|z   dz   |z   dz   |z   dz            yc c}}w )	a  Make dependency links fully-qualified relative to the current directory.

  |targets| is a dict mapping fully-qualified target names to their target
  dicts.  For each target in this dict, keys known to contain dependency
  links are examined, and any dependencies referenced will be rewritten
  so that they are fully-qualified and relative to the current directory.
  All rewritten dependencies are suitable for use as keys to |targets| or a
  similar dict.
  r   r%  r   r4   r   zFound r4   of z, but not in dependenciesN)dependency_sectionsr   ry   rz   	BuildFiler<   r]   r   r   r  r   )r   depopall_dependency_sectionsr   r   target_build_filer4   dependency_keyr   rf   dep_file
dep_targetdep_toolsetr   s                  r    QualifyDependenciesr  X  sW    )<7!$'57!# !2X 7X 7 7 %]]_ Hfk

,,V4)$G1 H __^R8l!,/ H*%,/JJ,D,DsG--)*k +ZZ//0:0;=
 )U ^+[88J.7.H "()+FG H HHHH	7s   Dc           	         | j                         D ]K  \  }}|d   }t        j                  j                  |      }t        D ]  }|j                  |g       }d}|t        |      k  s't        j                  j                  ||         \  }	}
}|
dk7  r|dk7  r|dz   }E|	|k(  rt        d|z   dz   |z   dz         ||= |dz
  }||	   d   }|D ]v  }t        |j                  d	d
            r|d   }|
dk7  r|
|k7  r/|d   }|dk7  r||k7  r?t        j                  j                  |	||      }|dz   }|j                  ||       x |dz   }|t        |      k  r N y)a  Expands dependencies specified as build_file:*.

  For each target in |targets|, examines sections containing links to other
  targets.  If any such section contains a link of the form build_file:*, it
  is taken as a wildcard link, and is expanded to list each target in
  build_file.  The |data| dict provides access to build file dicts.

  Any target that does not wish to be included by wildcard can provide an
  optional "suppress_wildcard" key in its target dict.  When present and
  true, a wildcard dependency link will not include such targets.

  All dependency names, including the keys to |targets| and the values in each
  dependency list, must be qualified when this function is called.
  r4   r   *rB   zFound wildcard in r  z referring to same build filer   r2   Fr3   N)r   ry   rz   r  r  r<   rH   ParseQualifiedTargetr   r;  r  insert)r   r}   r   r   r4   r  r  r   rf   dependency_build_filedependency_targetdependency_toolsetdependency_target_dictsdependency_target_dictdependency_target_namedependency_target_toolsetr   s                    r    ExpandWildcardDependenciesr    s     %]]_ 2fk)$G

,,V4- / __^R8l eC%%JJ++L,?@ 	G	 13E#(:c(A!)%
 $55 ->G "AB C C 	
 #''<"=i"H&= 	1"'++,?GH#9-#H
 3&#99&<Y&G
# C' $==zz112G2H2KM* !)%


eZ
0	1" 	S C%%/2r"   c                 Z    i }| D cg c]  }||vs|j                  ||       c}S c c}w )z=Removes duplicate elements from l, keeping the first element.
setdefault)lseenr   s      r    Unifyr    s,    	$)*	<Aatm$//!Q
	<<	<s   	((c                     | j                         D ]3  \  }}t        D ]%  }|j                  |g       }|st        |      ||<   ' 5 y)zRMakes sure every dependency appears only once in all targets's dependency
  lists.N)r   r  r<   r  )r   r3   r   r  r   s        r    RemoveDuplicateDependenciesr    sO     #*--/ :k;- : __^R8l	&+L&9N#::r"   c                 \    i }| D cg c]  }||k7  s	|j                  ||       c}S c c}w )zRemoves item from l.r  )r  r   resr   s       r    Filterr    s,    
#()	71Q$Y#..A
	77	7s   
))c                     | j                         D ]g  \  }}t        D ]Y  }|j                  |g       }|s|D ]=  }||k(  s	| |   j                  di       j                  dd      s/t        ||      ||<   ? [ i y)zYRemove self dependencies from targets that have the prune_self_dependency
  variable set.r7   prune_self_dependencyr   Nr   r  r<   r  r   r3   r   r  r   ts         r    RemoveSelfDependenciesr    s     #*--/ Nk;- N __^R8l	 	NA+qz~~k2.223JAN,2<,Mk.)	NNNr"   c                    | j                         D ]z  \  }}t        D ]l  }|j                  |g       }|s|D ]P  }|j                  dd      dk(  s| |   j                  di       j                  dd      s?t        ||   |      ||<   R n | y)zURemove dependencies having the 'link_dependency' attribute from the 'none'
  targets.r6   Nnoner7   link_dependencyr   r  r  s         r    %RemoveLinkDependenciesFromNoneTargetsr    s     #*--/ 9k;- 9 __^R8l	 	9A__VT*f4qz~~k2.223DaH^4a8 .)	999r"   c                   t    e Zd ZdZ G d de      Zd Zd Zd Zd Z	dd	Z
dd
ZddZddZ	 ddZd Zd Zy)DependencyGraphNodez

  Attributes:
    ref: A reference to an object that this DependencyGraphNode represents.
    dependencies: List of DependencyGraphNodes on which this one depends.
    dependents: List of DependencyGraphNodes that depend on this one.
  c                       e Zd Zy)%DependencyGraphNode.CircularExceptionNr   r   r"   r    CircularExceptionr    s    r"   r  c                 .    || _         g | _        g | _        y r   )refr   
dependents)r   r  s     r    r   zDependencyGraphNode.__init__  s    DHDDOr"   c                      d| j                   z  S )Nz<DependencyGraphNode: %r>r  r   s    r    __repr__zDependencyGraphNode.__repr__  s    &11r"   c                 p   t               }d }t        | j                  d d  |      }|r|j                         }|j	                  |j
                         t        |j                  |      D ];  }d}t        |j                  |      D ]  }|j
                  |vsd} n |s6||gz  }= |rt        |      S )Nc                     | j                   S )zAExtracts the object that the node represents from the given node.r  )r`   s    r    ExtractNodeRefz9DependencyGraphNode.FlattenToList.<locals>.ExtractNodeRef  s    XXor"   )rc   TF)r   sortedr  r   r   r  r   r[   )r   	flat_listr  in_degree_zerosr`   node_dependentis_in_degree_zeronode_dependent_dependencys           r    FlattenToListz!DependencyGraphNode.FlattenToList	  s    
 I T__Q/^DO

   "dmmDHH #4??G ..  +11L1L5C+E 	%*..);
 !&	  n-
-/'. > 	?r"   c                 h    g t               fdj                  |         | | g       S )zR
    Returns a list of cycles in the graph, where each cycle is its own list.
    c           	          | j                   D ]T  }||v r+j                  |g|d |j                  |      dz    z          2|vs7j                  |        ||g|z          V y )NrB   )r  r;   rf   r   )r`   ro   rg   Visitresultsvisiteds      r    r  z-DependencyGraphNode.FindCycles.<locals>.VisitB  sj    ?? '%D=
..%4(>E):Q)>#??
@'!
++e

w~
&'r"   )r   r   )r   r  r  r  s    @@@r    
FindCycleszDependencyGraphNode.FindCycles;  s5     GeG' KK	$Nr"   Nc                     |dk(  rg }| j                   D ]<  }|j                  dk7  s|j                  |vs"|j                  |j                         > |S )z+Returns a list of just direct dependencies.N)r   r  r;   r   r   r   s      r    DirectDependenciesz&DependencyGraphNode.DirectDependenciesO  sU    tl'' ,
	4	JNN,$FJNN+,
 r"   c                     |dk(  rg }d}|t        |      k  rV||   }||   }d}|j                  dg       D ]!  }||vs|j                  ||z   |       |dz   }# |dz   }|t        |      k  rV|S )a^  Given a list of direct dependencies, adds indirect dependencies that
    other dependencies have declared to export their settings.

    This method does not operate on self.  Rather, it operates on the list
    of dependencies in the |dependencies| argument.  For each dependency in
    that list, if any declares that it exports the settings of one of its
    own dependencies, those dependencies whose settings are "passed through"
    are added to the list.  As new items are added to the list, they too will
    be processed, so it is possible to import settings through multiple levels
    of dependencies.

    This method is not terribly useful on its own, it depends on being
    "primed" with a list of direct dependencies such as one provided by
    DirectDependencies.  DirectAndImportedDependencies is intended to be the
    public entry point.
    Nr   rB   r   )rH   r<   r  )r   r   r   rf   r   dependency_dict	add_indeximported_dependencys           r    _AddImportedDependenciesz,DependencyGraphNode._AddImportedDependencies[  s    $ tlE
#l#
#&j
+o i


92
>$
l2


ei/1D
E!m)	$
 aie #l#
#" r"   c                 H    | j                  |      }| j                  ||      S )zReturns a list of a target's direct dependencies and all indirect
    dependencies that a dependency has advertised settings should be exported
    through the dependency for.
    )r  r   )r   r   r   s      r    DirectAndImportedDependenciesz1DependencyGraphNode.DirectAndImportedDependencies  s'     **<8L((,??r"   c                     |
t               }| j                  D ]J  }|j                  |j                  |vs|j                  |       |j	                  |j                         L |S )zEReturns an OrderedSet of all of a target's dependencies, recursively.)r   r   r  DeepDependenciesr   r  s      r    r  z$DependencyGraphNode.DeepDependencies  sg      \l'' )
			|	+##L1() r"   c                 \   |
t               }| j                  |S d|| j                     vrt        d      d|| j                     vrt        d|| j                     d   z        || j                     d   }|t        v }|r|s|S |dk(  r<|| j                     j	                  dd      s|j                  | j                         |S |s|dv r|S |s	|d	k(  r|s|S | j                  |vrD|j                  | j                         |s|s%| j                  D ]  }|j                  |||d
        |S )au  Returns an OrderedSet of dependency targets that are linked
    into this target.

    This function has a split personality, depending on the setting of
    |initial|.  Outside callers should always leave |initial| at its default
    setting.

    When adding a target to the list of dependencies, this function will
    recurse into itself with |initial| set to False, to collect dependencies
    that are linked into the linkable target for which the list is being built.

    If |include_shared_libraries| is False, the resulting dependencies will not
    include shared_library targets that are linked into this target.
    r3   z&Missing 'target_name' field in target.r6   z!Missing 'type' field in target %sr  dependencies_traverseT)r   r   r	   r
   r   F)r   r  r   linkable_typesr<   r   r   _LinkDependenciesInternal)r   r   include_shared_librariesr   initialtarget_typeis_linkabler   s           r    r  z-DependencyGraphNode._LinkDependenciesInternal  sq       \l xx GDHH--=>>WTXX&&8TXX&}56 7 7 $((#F+K/K{
  	vDHH!!"94@txx  { '9 9  '77$ xx|#txx 	
 ++ 	DJ

.
.w/G/;UD	D
 r"   c                 d    || j                      j                  dd      }| j                  ||      S )zi
    Returns a list of dependency targets whose link_settings should be merged
    into this target.
    (allow_sharedlib_linksettings_propagationT)r  r<   r  )r   r   r	  s      r    DependenciesForLinkSettingsz/DependencyGraphNode.DependenciesForLinkSettings  s7     	H$O ))'3KLLr"   c                 &    | j                  |d      S )zP
    Returns a list of dependency targets that are linked into this target.
    T)r  )r   r   s     r    DependenciesToLinkAgainstz-DependencyGraphNode.DependenciesToLinkAgainst  s     ))'488r"   r   )NT)r   r   r   r   r   r  r   r  r  r  r  r   r  r  r  r  r  r   r"   r    r  r    sV    	( 	
20d(
'R@$ <@UnM9r"   r  c                 $   i }| j                         D ]  \  }}||vst        |      ||<    t        d       }| j                         D ]  \  }}||   }t        j                  j	                  |      }|j                  d      }|s$|g|_        |j                  j                  |       a|D ]\  }|j                  |      }	|	st        d|d|      |j                  j                  |	       |	j                  j                  |       ^  |j                         }
t        |
      t        |       k7  r|j                  sOt        t        |             }||   }|j                  j                  |       |j                  j                  |       g }|j                         D ]>  }|D cg c]  }|j                   }}|j                  ddj!                  |      z         @ t        j#                  ddj!                  |      z         ||
gS c c}w )Nr   zDependency 'z(' not found while trying to load target 	Cycle: %s -> z%Cycles in dependency graph detected:

)r   r  ry   rz   r  r<   r   r  r;   r   r  rH   nextiterr  r  rZ   r  )r   dependency_nodesr   spec	root_nodetarget_noder  r   r   dependency_noder  cyclescycler`   pathss                  r    BuildDependencyListr   
  s    mmo =lfd%%!4V!<v= "$')mmo 7lfd"6*K

,,V488N+L"+k!!+.$ 7**..z:7A6K L L  ''8""))+677  %%') 	^s7|# DM"f$V,k%%i0!!+.F%%' 6$)*Dtxx*e*mmK&++e"4456 
/
/0499V3DDF F I	&& +s   (Hc                    i }| j                         D ]4  }t        j                  j                  |      }||vs't	        |      ||<   6 | j                         D ]  \  }}t        j                  j                  |      }||   }|j                  dg       }|D ]  }	 t        j                  j                  |      }||k(  r)|j                  |      }
|
st        d|z        |
|j                  vsY|j                  j                  |
       |
j                  j                  |         t	        d       }|j                         D ]Q  }t        |j                        dk(  s|j                  j                  |       |j                  j                  |       S |j                         }t        |      t        |      k7  r|j                  sXt        t!        |j                                     }|j                  j                  |       |j                  j                  |       g }|j#                         D ]>  }|D cg c]  }|j$                   }}|j                  ddj'                  |      z         @ t        j)                  ddj'                  |      z         y # t        $ r)}	t        j                  j                  |	d|z          d }	~	ww xY wc c}w )	Nr   z,while computing dependencies of .gyp file %szDependancy '%s' not foundr   r  r  z/Cycles in .gyp file dependency graph detected:
r  )rV   ry   rz   r  r  r   r<   r   r{   r   r;   r  rW   rH   r  r  r  r  r  rZ   r  )r   r  r   r[  r  build_file_nodetarget_dependenciesr   r  r   r  r  r  	file_noder  r  r`   r  s                     r    #VerifyNoGYPFileCircularDependenciesr%  <  s     Ef%%f-J))%8%Dz"E mmo ;lfd%%f-J&z2O((>26) ;
 #

 4 4Z @ 
*	,(,,-BCo25JJKK	 < <	<$$++O<""))/:!;	;0 "$'))002 3o
?''(A-"")))4!!/23
 %%') 	^s+,, t,33567i##I.!!),F%%' 6$)*Dtxx*e*mmK&++e"4456 
/
/:TYYv=NNP P -7  

""=
J	LH +s   J >K 	K)$KKc                    |D ]  }||   }t         j                  j                  |      }| dk(  r||   j                         }nB| dk(  r||   j	                  |      }n(| dk(  r||   j                  |      }nt        d| z         |D ]<  }||   }	| |	vrt         j                  j                  |      }
t        ||	|    ||
       >  y )Nr$   r)   r8   zCDoDependentSettings doesn't know how to determine dependencies for )ry   rz   r  r  r  r  r   r   )rc   r  r   r  r   r   r[  r   r   r  r  s              r    DoDependentSettingsr'  w  s      4f&/K%%f-J
&&%f->>@l	+	+
6
"
@
@
I 		
6
"
>
>w
G   *,/0 1 1 # 4

+oO#!jj22:>oc2244!4r"   c                 ~   | D ]2  }||   }|d   }|dk(  rd|vr|j                  dg       d d  |d<   ||   j                  |      }d}|t        |      k  rK||   }	||	   }
|
d   dk(  r|
j                  dd      r|
d   dk7  r|	|d   vr||= n|dz   }|t        |      k  rKt        |      dkD  r||d<   |d= |t        v s||   j	                  |      }|D ]-  }	|	|k(  r	d|vrg |d<   |	|d   vs|d   j                  |	       / |s
d|v st        |       D cg c]  }||d   v r| c}|d<   5 y c c}w )	Nr6   static_libraryr   r(   r   hard_dependencyFrB   )r<   r  rH   r  r  r;   reversed)r  r   r  sort_dependenciesr   r   r  r   rf   r   r  link_dependenciesr  s                r    AdjustStaticLibraryDependenciesr.    s     BNf&/Kf%K&&{*-8__
"..!k)* 6
"
@
@
I eC%%!%(
!*- F#'77##$5u=F#'77k.99 5!!)% C%%& 
\	Q	&2N#'		& 6
"
<
<W
E ) 9*
,(*+n
%[88
n
%
,
,Z
89 
~<6>y6I 'Ns*-^1L*L (+ 'NN#CBNB'Ns    D:z["']?[-/$<>^]c           
         | |k(  st         j                  |      r|S t        j                  j	                  t        j                  j                  t        j                  j                  t        j                  j                  |      t        j                  j                  |             |            j                  dd      }|d   dk(  r|dz  }|S )Nr   r   r   )exception_rera  rn   ro   r   rZ   ry   rz   r   r   r   )to_filefro_filer   rets       r    MakePathRelativer4    s    $ L..t4K
 ''

277<<

 9 " 8	: $& ' (/wtS'9  Bx3	SjcJr"   c                    d fd}d}t        fd| D              }|D ]:  }	d}
t        |	t              r6|rt        |||	      }n|	}t        |	t              r|	j                  d      sid}
nft        |	      t        u ri }t        ||	||       nDt        |	      t        u rg }t        ||	||       n"t        d|	j                  j                  z         |r9|
r ||||       r| j                  |        |      s|j                  |       |
r|| v r| j!                  |       |
r|| v r| j#                  ||        |      r|j                  |       |d	z   }= y )
Nc                     | j                   S r   )__hash__)vals    r    <lambda>zMergeLists.<locals>.<lambda>  s
    CLL r"   c                 $     |       r| |v S | |v S r   r   )xr   r  is_hashables      r    is_in_set_or_listz%MergeLists.<locals>.is_in_set_or_list  s    1~!Vm6Mr"   r   c              3   4   K   | ]  } |      s|  y wr   r   ).0r;  r<  s     r    	<genexpr>zMergeLists.<locals>.<genexpr>  s     8aQ8s   Fr  Tz/Attempt to merge list item of unsupported type rB   )r   rE   rU  r4  r  
startswithr6   rb   r   r[   
MergeListsr_   rV  r   r;   r   remover  )tofror1  r2  is_pathsr;   r=  prepend_indexhashable_to_setr   	singletonto_itemr<  s               @r    rB  rB    sg    )+
 - 8288/ 5(dI$'	"7Hd;z*ts/C 		dt	 g$2	dt	 g$2
;
..
!
!"# #  /"M
		'w


g
&
 'R-
		' 'R- 	iiw'	W	G$#a'mk5(r"   c           	         |j                         D ]4  \  }}|| v rd}t        |t              rt        | |   t              sd}nt        |      t        | |         urd}|rEt	        d|j
                  j                  z   dz   | |   j
                  j                  z   dz   |z         t        |t              r$t        |      }|rt        |||      | |<   || |<   t        |      t        u r|| vri | |<   t        | |   |||       t        |      t        u r|d   }d}	|dk(  r|d d }
|
|
dz   g}g | |
<   n9|d	k(  r|d d }
|
dz   |
dz   g}d}	n"|dk(  r|d d }
|
|
dz   |
d	z   g}n|}
|
dz   |
dz   g}|D ]  }||v st        d
|z   dz   |z          |
| v ri|dk(  rt        | |
         t        urSt	        d|j
                  j                  z   dz   | |
   j
                  j                  z   dz   |
z   dz   |z   dz         g | |
<   t        |
      }t        | |
   |||||	       t	        d|j
                  j                  z   dz   |z          y )NFTz$Attempt to merge dict value of type z into incompatible type z	 for key r   =?+zIncompatible list policies  and r  rk   z0Attempt to merge dict value of unsupported type )r   rE   rU  r6   r_   rV  r   r!   r4  rb   r   r[   r   rB  )rD  rE  r1  r2  r   r   	bad_mergeis_pathextr;   	list_baselists_incompatiblelist_incompatiblerF  s                 r    r   r   M  s   iik ^2da 	Bwi	A~	&"Q%0)7$r!u+%		2Q[[5I5II&')+A)A)AB 	 !^$a g	 (A611	aD"W1A7H-	aD bEcf	crF	'S99#:crF	'#oy3?#:crF	'S)c/J	'#oy3?
  2 ,
#6:WD*+ , ,,
 
b#: "Y- , 4q{{7K7KK()+-i=+B+B+K+KL%&(+,./02567 7
 9 y)hI7HhG
<
++

!,-/012 2y^2r"   c           	          ||v ry |d   |   }|j                  dg       D ]  }t        | |||||gz           t        | |||       d| v r| d= y y )Nr%   inherit_fromabstract)r<   MergeConfigWithInheritancer   )new_configuration_dictr[  r   configurationr  configuration_dictparents          r    rY  rY    s     g
 ##34]C #&&~r: Of5z*FG}o4MOO
 #%7% ))z* *r"   c           	         g d}t         j                  j                  |       }d|vrdi i|d<   d|vrG|d   j                         D cg c]  \  }}|j	                  d      s| }}}t        |      d   |d<   i }|d   }|j                         D ]  \  }	}
|
j	                  d      ri }|j                         D ]A  \  }}|dd  }||v r|d d }n|}|t        vs t         j                  j                  |      ||<   C t        ||||	g        |||	<    |j                         D ]  }	||	   |d   |	<    |d   }|j                         D ci c]  \  }}|j	                  d      r|| c}}|d<   g }|D ]-  }|dd  }||v r|d d }n|}|t        vs|j                  |       / |D ]  }||=  |d   j                         D ]:  }	|d   |	   }|j                         D ]  }|t        v st        |d|	d	|        < y c c}}w c c}}w )
N)rL  rN  rM  r%  r   r%   Defaultr'   rX  r   r   z not allowed in the z  configuration, found in target )ry   rz   r  r   r<   r  r   r   r   rY  rV   r;   invalid_configuration_keysr   )r   r   key_suffixesr[  rr  configconcretemerged_configurationsconfigsr[  old_configuration_dictrZ  rc   
target_valkey_extkey_baser   r   delete_keysr\  s                       r    SetUpConfigurationsrk    s   
 +,zz##F+*
 
[	(%.OK !	 K	/%01A%B%H%H%J /kq&zz*-  /H /+1(+;A+>K'(()'18 B-},!!*-  (..0 KjBCg	L	 s8//&)oo&>&>z&Js#K 5z*M2? ,B-(+B0 -113 .mm,  !-0.
 ()'A1quuZ/@q!tA  + c"#hG,Sbhh--  cC ##3499; Cm$%56}E!&&( C	*	*&)=&B C 	CCCo/J Bs   	HH'Hc                 J   g }g }|j                         D ]  \  }}|d   }|dk7  r|dk7  rt        |      t        ur+t        | dz   |z   dz   |j                  j
                  z         |dd }||vr|j                  |       mt        ||         t        ur<||   }t        | dz   |z   dz   |j                  j
                  z   dz   dd	d
|   z         ||vs|j                  |        |D ]  }||=  |D ]V  }||   }	t        dt        |	      z        }
|dz   }||v r+||   D ]   }t        |	      D ]  \  }}||k(  sd|
|<    " ||= |dz   }||v r||   D ]y  }|\  }}t        j                  |      }|dk(  rd}n"|dk(  rd}nt        d|z   dz   | z   dz   |z         t        |	      D ]%  \  }}|
|   |k(  r|j                  |      s!||
|<   ' { ||= |dz   }||v rt        | dz   |z   dz   |z         g }t        t        |
      dz
  dd      D ]#  }|
|   dk(  s|j                  d|	|          |	|= % t        |      dkD  sR|||<   Y |j                         D ]A  \  }}t        |      t        u rt!        ||       $t        |      t        u s6t#        ||       C y)a  Process regular expression and exclusion-based filters on lists.

  An exclusion list is in a dict key named with a trailing "!", like
  "sources!".  Every item in such a list is removed from the associated
  main list, which in this example, would be "sources".  Removed items are
  placed into a "sources_excluded" list in the dict.

  Regular expression (regex) filters are contained in dict keys named with a
  trailing "/", such as "sources/" to operate on the "sources" list.  Regex
  filters in a dict take the form:
    'sources/': [ ['exclude', '_(linux|mac|win)\.cc$'],
                  ['include', '_mac\.cc$'] ],
  The first filter says to exclude all files ending in _linux.cc, _mac.cc, and
  _win.cc.  The second filter then includes all files ending in _mac.cc that
  are now or were once in the "sources" list.  Items matching an "exclude"
  filter are subject to the same processing as would occur if they were listed
  by name in an exclusion list (ending in "!").  Items matching an "include"
  filter are brought back into the main list if previously excluded by an
  exclusion list or exclusion regex filter.  Subsequent matching "exclude"
  patterns can still cause items to be excluded after matching an "include".
  r   r%  r   z key z must be list, not Nz when applying 	exclusionregexr3  )r   r   excluder   rB   zUnrecognized action r4  	_excludedzD must not be present prior  to applying exclusion/regex filters for )r   r6   r[   r  rV  r   r;   rH   r]   r  r  searchr   ranger  rb   rA  ProcessListFiltersInList)namer  lists	del_listsrc   rK   	operationlist_keydel_listr  list_actionsexclude_keyexclude_itemrf   	list_item	regex_key
regex_itemactionpattern
pattern_reaction_valueexcluded_keyexcluded_lists                          r    rA  rA  	  s   > %)NN$ jc5BICI,E{$tg~+.CC//0 1 1 3BxHx sHXt+x etg~0,-//02CD )w7	BC D D
 ull838  h  S-h!H H-.LS.Kh";/ $, )( 3 	$E9Y& #$L		$$ ;
3IH + /*&ZZ(
Y,y , 1F:VCdJ"#%./ 0 0 !*( 3 	/E9% L0 y)".L	//2 9
 k)LxTG^l2AACKL M M M s<(1,b"5 	e		! 	Q0UO =A,h|gS-l NN$ +jc5E{dsE*	e	sE*	+r"   c                     |D ]>  }t        |      t        u rt        | |       !t        |      t        u s3t	        | |       @ y r   )r6   rb   rA  r[   rs  )rt  r  r   s      r    rs  rs  	  s=     +dDzTtT*	dt	tT*	+r"   c           
          d}|j                  dd      }||vr$t        d| d|ddj                  |      d      |j                  d	d
      r|dk(  st        d| d|d      yy)zEnsures the 'type' field on the target is one of the known types.

  Arguments:
    target: string, name of target.
    target_dict: dict, target spec.

  Raises an exception on error.
  )r   r   r)  r   r	   r  r
   r6   NzTarget z has an invalid target type 'z'.  Must be one of r   rR   r1   r   r)  z
 has type zJ but standalone_static_library flag is only valid for static_library type.)r<   r   rZ   )r   r   VALID_TARGET_TYPESr  s       r    ValidateTargetTyper  	  s    J -+**
K2D)EG H H oo115
)
)
=C=HJ K K * 6r"   c                    |sy |j                  dd       dk7  ry |j                  dg       }i }|D ]k  }t        j                  j                  |      \  }}|dv }	|	s,t        j                  j	                  |      }
|j                  |
g       j                  |       m d}|j                         D ]/  \  }
}t        |      dkD  s|d|
dd	j                  |      d
z  }1 |rt        d| z  |z   dz          t        d      y )Nr6   r)  r   )z.cz.ccz.cppz.cxxz.mz.mmz.sz.Sr   rB   z  z: r)  r  z<static library %s has several files with the same basename:
z`libtool on Mac cannot handle that. Use --no-duplicate-basename-check to disable this validation.z6Duplicate basenames in sources section, see list above)r<   rn   ro   splitextbasenamer  r;   r   rH   rZ   r   r   )r   r   r[  duplicate_basename_checkr   	basenamessourcert  rR  is_compiled_filer  r   r   s                r    ValidateSourcesInTargetr  	  s#   	!
__VT"&66
OOIr*') 6f  (ID# > >ww%H2&--f56 %"* :oh
5zA~x%99e: 	
I
FF G K
LL	 r"   c                 \   i }i }|j                  dg       }|D ]  }|d   }||v rt        d|d|       |||<   |d   }|j                  d      r|dd }||v rt        d	|d
| d||   d   d|      |||<   d|v rt        d| d|      g }	dg}
|
j                  |       |
D ]h  }|j                  |g       D ]Q  }t        j
                  j                  |      \  }}|j                  d      r|dd }||k(  sA|	j                  |       S j t        |	      dkD  s|	|d<    y)a]  Ensures that the rules sections in target_dict are valid and consistent,
  and determines which sources they apply to.

  Arguments:
    target: string, name of target.
    target_dict: dict, target spec containing "rules" and "sources" lists.
    extra_sources_for_rules: a list of keys to scan for rule matches in
        addition to 'sources'.
  r/   	rule_namezrule z exists in duplicate, target 	extensionrR   rB   Nz
extension z( associated with multiple rules, target z rules rO  rule_sourcesz-rule_sources must not exist in input, target z rule r   r   )	r<   r   rA  r   rn   ro   r  r;   rH   )r   r   extra_sources_for_rules
rule_namesrule_extensionsr/   ruler  rule_extensionr  source_keys
source_keyr  source_rootsource_extensions                  r    ValidateRulesInTargetr  	  s    */
//'2
&% &*d[!IJ) * * Jy+&N  %%ab)n($f%n5kB	! " "
 '+ON# Y ! ! L+K./! &
OOJ3 &&*,''*:*:6*B'&&&s+-ab1
~-


f
%&& <1)d>M&*r"   c                    |j                  d      }|j                  d      }|sy t        |      t        urt        d|d|d      |j                  d      }|st        d|d|d      t        |      t        urt        d|d|d	      |j                  d
      }|r"t        |t              st        d|d|d      |j                  d      }|r$t        |      t        urt        d|d|d      y y )Nr3   r0   zThe 'run_as' in target z from file z should be a dictionary.r  z must have an 'action' section.z$The 'action' for 'run_as' in target z must be a list.working_directoryz/The 'working_directory' for 'run_as' in target z	 in file z should be a string.environmentz)The 'environment' for 'run_as' in target )r<   r6   rb   r   r[   rE   r  )r   r   r[  r3   r0   r  r  r  s           r    ValidateRunAsInTargetr  *
  s	   .+??8$&	
	&\
- . . ::h&	
- . . 
&\
- . . jj!45z*;ZH
- . . 

=)+T+&d2
- . . 3[r"   c                 ,   |j                  d      }|j                  dg       }|D ]l  }|j                  d      }|st        d|z        |j                  dd      }|t        d|z        |j                  d      }|sZ|d	   r`t        d
|z         y)z0Validates the inputs to the actions in a target.r3   r#   action_namezKAnonymous action in target %s.  An action must have an 'action_name' field.r   Nz"Action in target %s has no inputs.r  r   z%Empty action as command in target %s.)r<   r   )	r   r   r[  r3   r#   r  r  r   action_commands	            r    ValidateActionsInTargetr  H
  s    .+OOIr*' Lf**]+K C ! " " ZZ$'F~9KGHHZZ)NnQ/<{JKKLr"   c                 ,   | j                         D ]  \  }}t        |t              rt        |      }|| |<   n9t	        |      t
        u rt        |       nt	        |      t        u rt        |       t        |t              sq| |= || t        |      <    y)zGGiven dict the_dict, recursively converts all integers into strings.
  N)	r   rE   r  r:  r6   rb   TurnIntIntoStrInDictr[   TurnIntIntoStrInList)r  r   r   s      r    r  r  Z
  s    
 nn da!Z 
a&ahqk	aD1	aD1!Z 
1+hs1vr"   c                     t        |       D ]^  \  }}t        |t              rt        |      | |<   %t	        |      t
        u rt        |       Bt	        |      t        u sTt        |       ` y)zGGiven list the_list, recursively converts all integers into strings.
  N)	r]   rE   r  r:  r6   rb   r  r[   r  )r  rf   r   s      r    r  r  m
  s[     x( !keT$
#D	huo	dt	4 	dt	4 !r"   c                    g }|D ]S  }|j                         }t        j                  j                  ||      }|st	        d|z        |j                  |       U i }|D ]*  }| |   ||<   ||   j                         D ]
  }	| |	   ||	<    , |D 
cg c]	  }
|
|v s|
 }}
|d   D ]^  }d||   vrg }||   d   D ]?  }t        j                  j                  ||d   |d         }||v s/|j                  |       A |||   d<   ` ||fS c c}
w )zEReturn only the targets that are deep dependencies of |root_targets|.zCould not find target %sr   r   r3   r4   )	rC  ry   rz   FindQualifiedTargetsr   r   r  r  r;   )r   r  r  root_targetsr}   qualified_root_targetsr   qualified_targetswanted_targetsr   r  wanted_flat_listr[  new_targetsqualified_names                  r    PruneUnwantedTargetsr  y
  st     5f\\^F

77	J/&899!!"345 .& 7f$V_N6&v.??A 7
#*:#6nZ 77
 "+BAa>.AaBB -. 
.jZ((Kz"9- #zz11*282G282CEn 
>	)6"# #.DY
. 
)	)) Cs   	D
D
c                     i }| D ]i  }|j                  dd      \  }}t        j                  j                  |      \  }}|sd}|dz   |z   }||v rt	        d|d|d|d||   d	      |||<   k y	)
zVerify that no two targets in the same directory share the same name.

  Arguments:
    targets: A list of targets in the form 'path/to/file.gyp:target_name'.
  :rB   rR   zDuplicate target name "z" in directory "z" used both in "z" and "z".N)rsplitrn   ro   rD  r   )r   usedr   ro   rt  subdirry   rc   s           r    VerifyNoCollidingTargetsr  
  s     
$ f sA&JD$''--%KFC f
3,
C
d{,0&#tCyJ K KDI!r"   c                     t        t              at        j                  | d          t        d d  at
        j                  | d          | d   a| d   ay )Nr   r   $generator_supports_multiple_toolsetsrF  )	r   base_path_sectionsr   updatebase_non_configuration_keysr   r   r   rF  )r   s    r    r   r   
  sc     ()-+O<= 7q9 45M NO +,. 22LMr"   c
                    t        |       |d   }
dt               i}t        t        t        j                  j
                  |             } |rt        | ||||||       ni }| D ]  }	 t        |||||||d        t        |      }t        |       t        |       t        ||       t!        |       |j#                         D ]I  \  }}i }t$        D ]  }dD ]  }||z   }||v s||   ||<   ||=    t'        ||       |D ]
  }||   ||<    K t)        |       |rt+        |       t-        |      \  }}|	rt/        ||||	|      \  }}t1        |       dD ]%  }t3        ||||       |D ]  }|||   v s||   |=  ' |}|d   rt5        ||||d          |D ]8  }||   }t        j                  j7                  |      }t9        |t:        ||       : |D ]  }||   }t=        ||        |D ]  }||   }t'        ||        |D ]8  }||   }t        j                  j7                  |      }t9        |t>        ||       : |D ]g  }||   }t        j                  j7                  |      }tA        ||       tC        ||||       tE        |||
       tG        |||       tI        |||       i tK        |       |||gS # t        $ r)}t        j                  j                  |d|z          d }~ww xY w)	Nr  r   Tzwhile trying to load %sr  )r$   r)   r8   4generator_wants_static_library_dependencies_adjusted#generator_wants_sorted_dependencies)&r   r   maprn   ro   r   r  r   rx   ry   rz   r{   r  r  r  r  r  r   r  rA  r  r%  r   r  r  r'  r.  r  r   r6  rk  r8  r  r  r  r  r  r  )r   r7   r~   r   r   r   circular_checkr  parallelr  r  r}   r?   r[  r   r   r3   r   tmp_dictri  r  rc   r  r  settings_typer   giis                              r    Loadr  
  s   *+ 11JK 	&$ C((+67+ dIx!&(<> H! 
Jh%xt	E T"' g ! Wd+ (0 #*--/ 'k;H'  "m+%c*(3-#	 [(3 '!#k#'' g& (0"5g">Y .,lDBGY 9%) 	+m y';KL  +	'&/	)FOM*+	+ 	#	?@#Iw8H$'(M$NP  8f&/K%%f-J'ZJ88  -f&/K,-
  2f&/KV[12
  <f&/K%%f-J'^Y
<<  =f&/K%%f-Jv{+FK46&+/FG&+z:FK<= t
 Wd	##m  

""1&?*&LMs   &J;;	K-$K((K-r   )FT)o
__future__r   rC   
gyp.commonry   gyp.simple_copyr   optparseos.pathrn   r  rK  r   rP  r   r   timer   r   r   r  r  r  r   r   r   r   
basestringr  r  r:  r;  longr  rU  r[   r  r!   r  r   r`  r   rF  r=   rP   rJ   r   r|   r   r   r   r   rx   r   objectr   r  r	  r
  r  r  r  r5  r7  r9  rI  r  r   r6  r8  rB  r  r  r  r  r  r  r   rW  r  r  r  r  r  r  r  r  r  r   r%  r'  r.  r0  r4  rB  r   rY  rk  rA  rs  r  r  r  r  r  r  r  r  r  r   r  r   r"   r    <module>r     s  
 & 
      	    
     ! &'BC      }*
T{* j($w. 8 <        B!$8,^#+NO2Jq+f*Zi -F -`-h u:	3S)$2 BJJ !  2:: !  "rzz !    
F
   F!H+?\#%: BFm%`D4$HNBJ=:8
N9R9& R9j/'d8Pv4:JN\ rzz./@E(P`2F+.KC^Z+z+K0M:7*t.<L$&	! *F6N&Q$]T  v*  v*s$   #F& 'F5 &F21F25G G