
    擖gM                    &   S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SKr	S SK
Jr  S SKJs  Jr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  \R@                  " S5      r!\	RD                  RG                  5       r$0 SS_SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _S!S"_S#S$_S%S&S'.Er%S(S)/r&/ S*Qr'Sq(S+S,/r)Sq*Sq+S- r,Sq-S. r.SS/ jr/S0 r0SS1 jr1 SS2 jr2SS3 jr3SS4 jr4S5 r5S6 r6S7 r7S8 r8S9 r9S: r:S; r;S< r<S= r=S> r>S? r?S@ r@SA rASB rBSC rCSD rDSE rE\R@                  " SF5      rFSG rG\R@                  " SH5      rHSI rISJ rJ\R@                  " SK5      rKSL rLSM rMSN rNSO rOSP rPSQ rQSR rRSS rSST rTSU rUSV rVSW rWSX rXSY rYSZ rZS[ r[S\ r\S] r]S^ r^S_ r_S` r`Sa raSb rbSc rcSd rdSe reSf rfSg rgSh rhSi riSj rjSk rkSl rlSm rmSn rnSo roSp rpSq rqSr rrSs rsSt rtSu ruSv rvSw rwSx rxSy rySz rzS{ r{S| r|S} r}S~ r~S rS rS rS r " S S5      rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r\R@                  " S5      rS rS rS rS rS rS rS rS rS rS rS rS rS rS rg)    N)OrderedDict)GypError)
OrderedSetz^[A-F0-9\-]+$DRIVER_PREFIX DRIVER_SUFFIX.sysEXECUTABLE_PREFIXEXECUTABLE_SUFFIX.exeSTATIC_LIB_PREFIXSHARED_LIB_PREFIXSTATIC_LIB_SUFFIX.libSHARED_LIB_SUFFIX.dllINTERMEDIATE_DIR	$(IntDir)SHARED_INTERMEDIATE_DIRz!$(OutDir)/obj/global_intermediateOSwinPRODUCT_DIR	$(OutDir)LIB_DIRz$(OutDir)libRULE_INPUT_ROOT$(InputName)RULE_INPUT_DIRNAME$(InputDir)RULE_INPUT_EXT$(InputExt)RULE_INPUT_NAME$(InputFileName)$(InputPath)z$(ConfigurationName))RULE_INPUT_PATHCONFIGURATION_NAMEmsvs_cygwin_dirs
msvs_props)r&   msvs_cygwin_shellmsvs_large_pdb
msvs_shardmsvs_external_buildermsvs_external_builder_out_dirmsvs_external_builder_build_cmdmsvs_external_builder_clean_cmd#msvs_external_builder_clcompile_cmdmsvs_enable_winrtmsvs_requires_importlibrarymsvs_enable_winphonemsvs_application_type_revisionmsvs_target_platform_versionmsvs_target_platform_minversionmsvs_precompiled_headermsvs_precompiled_sourcec                     [         R                  S;  a  g[        (       a  [        (       Gd3  [        R
                  R                  S5      n [        R
                  R                  S5      nU (       a  U(       d  [        R                  " / SQ[        R                  S9nUR                  5       S   R                  S5      n[        R                  " S	[        R                  5      nUR                  U5      nU(       a  UR!                  S
5      n[        R                  " S[        R                  5      nUR                  U5      nU(       a  UR!                  S
5      n U qUq[        [        4$ )N)win32cygwin)DOMAINUSERNAME
USERDOMAINr<   )netconfigWorkstation)stdoutr   zutf-8z^User name\s+(\S+)   z^Logon domain\s+(\S+))sysplatformcached_domaincached_usernameosenvironget
subprocessPopenPIPEcommunicatedecoderecompile	MULTILINEsearchgroup)domainusernamecallr?   username_reusername_match	domain_redomain_matchs           4/usr/lib/python3/dist-packages/gyp/generator/msvs.py_GetDomainAndUserNamer\   l   s   
||..% =-::>>*-X##0D %%'*11':F**%:BLLIK(//7N)//2

#;R\\JI$++F3L%++A."?++    c                     [         R                  R                  U 5      nU R                  S5      UR                  S5      :X  a  Un U $ )zNormalize the path.

But not if that gets rid of a variable, as this may expand to something
larger than one directory.

Arguments:
    source: The path to be normalize.d

Returns:
    The normalized path.
$)rG   pathnormpathcount)source
normalizeds     r[   _NormalizedSourcere      s>     !!&)J||CJ,,S11Mr]   c                    [         (       ah  U (       aa  [        R                  R                  U 5      (       d=  U S   S:w  a4  [	        U 5      (       d$  [        R                  R                  [         U 5      n US:X  a  U R                  SS5      n [        U 5      n US:X  a  U R                  SS5      n U (       a  U S   U:X  a  U SS n U $ )zConvert paths to a form that will make sense in a vcproj file.

Arguments:
  path: The path to convert, may contain / etc.
Returns:
  The path with all slashes made into backslashes.
r   r_   \/N)fixpath_prefixrG   r`   isabs_IsWindowsAbsPathjoinreplacere   )r`   	separators     r[   _FixPathrp      s     	d##GsN!$''ww||ND1D||C&T"DC||D#&RI%CRyKr]   c                 T    U R                  S5      =(       d    U R                  S5      $ )z
On Cygwin systems Python needs a little help determining if a path
is an absolute Windows path or not, so that
it does not treat those as relative, which results in bad paths like:
'..\C:\<some path>\some_source_code_file.cc'
zc:zC:
startswithr`   s    r[   rl   rl      s!     ??4 9DOOD$99r]   c                 D    U  Vs/ s H  n[        X!5      PM     sn$ s  snf )z"Fix each of the paths of the list.)rp   )pathsro   is      r[   	_FixPathsrx      s    ,12EqHQ"E222s   c           	      D   U(       d  / n/ n/ n[        5       nU  H  n[        U5      S:X  aG  [        SR                  X-   5      5      n	X;   a  UR	                  U	5        MF  UR	                  U	5        MY  U(       aP  UR                  5       (       d;  UR                  US   5      (       d  / XxS   '   XxS      R	                  USS 5        M  [        USS /XS   /-   UUUS9n
[        R                  " US   U
S9n
UR	                  U
5        M     U(       a-  U(       a&  [        R                  " SUS9nUR	                  U5        U(       a  UR                  5       (       a  U$ U H:  n[        X|   X/-   UUUS9n
[        R                  " XS9n
UR	                  U
5        M<     U$ )	a  Converts a list split source file paths into a vcproj folder hierarchy.

Arguments:
  sources: A list of source file paths split.
  prefix: A list of source file path layers meant to apply to each of sources.
  excluded: A set of excluded files.
  msvs_version: A MSVSVersion object.

Returns:
  A hierarchy of filenames and MSVSProject.Filter objects that matches the
  layout of the source tree.
  For example:
  _ConvertSourcesToFilterHierarchy([['a', 'bob1.c'], ['b', 'bob2.c']],
                                   prefix=['joe'])
  -->
  [MSVSProject.Filter('a', contents=['joe\a\bob1.c']),
   MSVSProject.Filter('b', contents=['joe\b\bob2.c'])]
rB   rg   r   Nexcludedlist_excludedmsvs_version)contents_excluded_files)prefixr{   r|   r}   )
r   lenre   rm   appendUsesVcxprojrI    _ConvertSourcesToFilterHierarchyMSVSProjectFilter)sourcesr   r{   r|   r}   resultexcluded_resultfolderssfilenamer~   excluded_folderfs                r[   r   r      s   * FOmGq6Q;(6:)>?H#&&x0h',":":"<"< ;;qt$$ "!aDM  12'712A$!+)H #))!A$BHMM(#- 0 =%,,
 	o&0022 3JC<'%
 %%a;h  Mr]   c                 .    U(       d  g [        XX#U5        g N)_ToolSetOrAppend)tools	tool_namesettingvalueonly_if_unsets        r[   _ToolAppendr     s    Uw}Er]   c                    SU;   d  SU;   aG  [        U5      [        :X  a  UR                  SS5      nO!U Vs/ s H  oUR                  SS5      PM     nnU R                  U5      (       d  0 X'   X   nUS:X  a  g UR                  U5      (       ac  U(       a  g [        Xb   5      [        :X  a   [        U5      [        :X  a  Xb==   U-  ss'   g [        SU< SU< SU< S	[        Xb   5      < 35      eX6U'   g s  snf )
NDirectoriesDependenciesrh   rg   CompileAsWinRTzAppending "z" to a non-list setting "z" for tool "z"" is not allowed, previous value: )typestrrn   rI   list	TypeError)r   r   r   r   r   rw   tools          r[   r   r     s    >W#<;#MM#t,E3895aYYsD)5E999YD""xx$&4;$+>MU"M '9c$-.@B  W% :s   C7c                 &    U R                  SS5      $ )Nmsvs_target_versionWindows7rI   config_datas    r[   _ConfigTargetVersionr   /  s    ??0*==r]   c                 &    U R                  SS5      $ )Nmsvs_configuration_platformWin32r   r   s    r[   _ConfigPlatformr   3  s    ??8'BBr]   c                 \    U R                  SU-   5      (       a  U S[        U5      * S-
   $ U $ )N_r   rB   )endswithr   )config_nameplatform_names     r[   _ConfigBaseNamer   7  s8    C-/001M 22Q677r]   c                 8    [        U5      n[        X5       SU 3$ )N|)r   r   )r   r   r   s      r[   _ConfigFullNamer   >  s#    #K0Mk9:!M?KKr]   c                 h  ^ U R                  S5      nU(       a  [        R                  " SU5      (       a  U$ U R                  S5      nU(       a  U/OTR                  nU H  nS H  n[        R
                  " Xe-  S5      nU(       d  M%  [        R
                  " Xe-  S5      =(       d    SmSU-  n[        U4S	 j[        R                  R                  U5      (       a  [        R                  " U5      O/  5       S
S9n	U	(       a	  U	S   s  s  $ [        ST-  [        R                  S9  M     M     g )N$msvs_windows_target_platform_versionz^\d+msvs_windows_sdk_version)z1HKLM\Software\Microsoft\Microsoft SDKs\Windows\%sz=HKLM\Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows\%sInstallationFolderProductVersionr   z
%s\includec              3   X   >#    U  H  nUR                  T5      (       d  M  Uv   M!     g 7fr   rr   ).0xversions     r[   	<genexpr>6_ConfigWindowsTargetPlatformVersion.<locals>.<genexpr>U  s/        
 ||G, A s   *	*T)reverser   zCWarning: No include files found for detected Windows SDK version %sfile)rI   rO   matchcompatible_sdksMSVSVersion_RegistryGetValuesortedrG   r`   isdirlistdirprintrC   rA   )
r   r   
target_ver
config_verversverkeysdk_direxpected_sdk_dirnamess
    `        r[   #_ConfigWindowsTargetPlatformVersionr   C  s   !GHJbhhw
33!;<J%J<7+B+BD
C "33CI?STG!33CI?OPVTVG,w6 77==)9:: 

#34  E Qx-0793
 r]   c                 z   U Vs/ s H  nSU;   d  M  UPM     sn(       a  SnOSnU(       Gau  [        U R                  SS/5      S   5      nUn	U	 V
s/ s H  oR                  SS5      PM     n	n
U	 V
s/ s H  oR                  S	S
5      PM     n	n
U	 V
s/ s H  oR                  SS5      PM     n	n
U(       a"  U	 V
s/ s H  n
U
R                  SS5      PM     n	n
U	 V
s/ s H  n
SU
R                  SS5      -  PM     n	n
SR                  U	5      n	SnU(       a  US-  nUS-  nU	R	                  S5      S:  a  US-  nU	R	                  S5      S:  a  US-  nU	R	                  S5      S:  a  US-  nU(       a  U	R	                  S5      S:  a  US-  nUS-  nXU	S.-  nXq-   $ US   S:X  a  S/OUS   R                  S S!5      /nUR                  SS"5        US#S   V
s/ s H   n
U
S S# S$;   d  S%U
;   a  U
O[        U
S 5      PM"     nn
U V
s/ s H  oR                  SS&5      PM     nn
U V
s/ s H  n
[        R                  " U
5      PM     nn
U(       a   S'US#   -  US#'   U V
s/ s H  n
S'U
-  PM
     nn
USR                  X-   5      -   $ s  snf s  sn
f s  sn
f s  sn
f s  sn
f s  sn
f s  sn
f s  sn
f s  sn
f s  sn
f )(Nr   z_set INPUTDIR=$(InputDir)
if NOT DEFINED INPUTDIR set INPUTDIR=.\
set INPUTDIR=%INPUTDIR:~0,-1%
r   r&   .r   r   z`cygpath -m "${INTDIR}"`r   z`cygpath -m "${OUTDIR}"`z`cygpath -m "${INPUTDIR}"`r#   z`cygpath -m "${INPUTPATH}"`z\"%s\""z\\\" z4call "$(ProjectDir)%(cygwin_dir)s\setup_env.bat" && zset CYGWIN=nontsec&& NUMBER_OF_PROCESSORSz@set /a NUMBER_OF_PROCESSORS_PLUS_1=%%NUMBER_OF_PROCESSORS%%+1&& INTDIRzset INTDIR=$(IntDir)&& OUTDIRzset OUTDIR=$(OutDir)&& 	INPUTPATHzset INPUTPATH=$(InputPath) && zbash -c "%(cmd)s")
cygwin_dircmdcatr   rh   rg   rV   rB   z/-=z
%INPUTDIR%"%s")rp   rI   rn   rm   findinsertMSVSSettingsFixVCMacroSlashes)specr   cygwin_shellhas_input_path	quote_cmddo_setup_envr   input_dir_preambler   
direct_cmdrw   command	argumentss                r[   _BuildCommandLineForRuleRawr   j  s     -3a-1,3-. 	  dhh'9C5A!DE

HR
HR1IIk#=>
 	 
 IS
HR1IIk#=>
 	 
 MW
LVqIIm%ABJ 	 
  $#A 		.*GH#   GQQjj199S)#<<j
QXXj)
JJC&&??12a7UUC??8$),,C??8$),,Cjook:a?33C""jAA!'' "!fo6(CFNN34M3N
 	q&! W
 BQ%4-3!8A(1c2BB 	 
 FOOYYY}l;Y	O@IJ	1\33A6		J  '!*,GAJ-67Y!YI7!CHHW-@$AAAW .


 RD
 PJ 8s@   
JJJ4JJ=JJ$'J)J., J3$J8c           	          UR                  S5      nUc  [        U R                  SS5      5      nO [        U[        5      (       a  [        U5      n[        UR                  SS5      5      n[	        XS   XBXSS9$ )Nr(   rB   msvs_quote_cmdaction)r   )rI   int
isinstancer   r   )r   ruler   r   mcsr   s         r[   _BuildCommandLineForRuler     sr    
 ((&
'C
{$((.23	C		#hDHH-q12I&8nc9 r]   c                 f    U(       d   eUUUUS.nUS   nX`;  a  / X'   X   R                  U5        g)a  Merge action into an existing list of actions.

Care must be taken so that actions which have overlapping inputs either don't
get assigned to the same input, or get collapsed into one.

Arguments:
  actions_dict: dictionary keyed on input name, which maps to a list of
    dicts describing the actions attached to that input file.
  inputs: list of inputs
  outputs: list of outputs
  description: description of the action
  command: command line to execute
inputsoutputsdescriptionr   r   Nr   )actions_dictr   r   r   r   r   chosen_inputs          r[   _AddActionStepr     sL     M6 "	F !9L '%'"%%f-r]   c                 $   [        U5      n[        U5      n[        R                  " SUSR                  U5      SR                  U5      US.5      nUS   R	                  5        H)  u  pU R                  [        U5      [        X5      U/S9  M+     g)a&  Add a custom build tool to execute something.

Arguments:
  p: the target project
  spec: the target project dict
  primary_input: input file to attach the build tool to
  inputs: list of inputs
  outputs: list of outputs
  description: description of the action
  cmd: command line to execute
VCCustomBuildTool;)DescriptionAdditionalDependenciesOutputsCommandLineconfigurationsr   N)rx   r   Toolrm   itemsAddFileConfigrp   r   )
pr   primary_inputr   r   r   r   r   r   c_datas
             r[   _AddCustomBuildToolForMSVSr    s     vF G&&)hhv&6xx(		
D  $$45;;=	]#_[%IRVQW 	 	
  >r]   c                    U H  n[        5       n[        5       n/ n/ nX#    He  nUR                  [        US   5      5        UR                  [        US   5      5        UR                  US   5        UR                  US   5        Mg     SR                  U5      n	SR                  U5      n
[	        U UUUUU	U
S9  M     g)	a  Add actions accumulated into an actions_dict, merging as needed.

Arguments:
  p: the target project
  spec: the target project dict
  actions_dict: dictionary keyed on input name, which maps to a list of
      dicts describing the actions attached to that input file.
r   r   r   r   , and also 
)r  r   r   r   r   N)r   updater   rm   r  )r  r   r   r  r   r   descriptionscommandsr   r   r   s              r[   _AddAccumulatedActionsToMSVSr    s     &,"1FMM*VH%567NN:fY&789} 56OOF9-.	 2 $((6++h'"'#	
 &r]   c                 4   U R                  S[        R                  R                  [        R                  R	                  U5      S   5      S   5      n U R                  S[        R                  R                  U5      5      n U R                  S[        R                  R                  [        R                  R	                  U5      S   5      S   5      n U R                  S[        R                  R	                  U5      S   5      n U R                  SU5      n U $ )zGiven the input file to which a rule applied, string substitute a path.

Arguments:
  path: a path to string expand
  input_file: the file to which the rule applied.
Returns:
  The string substituted path.
r   rB   r   r   r    r"   r#   )rn   rG   r`   splitextsplitdirname)r`   
input_files     r[   _RuleExpandPathr  0  s     <<((z)B1)EFqID <<rwwz'BCD<<rww''j(A!(DEaHD <<*BGGMM*,Ea,HID<<
3DKr]   c                 &    U R                  S/ 5      $ )zFind the list of files which a particular rule applies to.

Arguments:
  rule: the rule in question
  sources: the set of all known source files for this project
Returns:
  The list of sources that trigger a particular rule.
rule_sourcesr   )r   r   s     r[   _FindRuleTriggerFilesr  E  s     88NB''r]   c                 J   [        U R                  S/ 5      5      n[        U R                  S/ 5      5      n[        5       n[        5       nUR                  U5        U H  nUR                  [	        Xa5      5        M     U H  nUR                  [	        Xq5      5        M     XE4$ )zFind the inputs and outputs generated by a rule.

Arguments:
  rule: the rule in question.
  trigger_file: the main trigger for this rule.
Returns:
  The pair of (inputs, outputs) involved in this rule.
r   r   )rx   rI   r   addr  )r   trigger_file
raw_inputsraw_outputsr   r   rw   os           r[   _RuleInputsAndOutputsr&  Q  s     488Hb12JDHHY34K\FlG
JJ|

?134 OA45 r]   c           
      "   SR                  US   UR                  5      n[        R                  " [        R
                  R                  X%5      US   5      nU H  nUS   nUS   n	[        UR                  S/ 5      5      n
[        UR                  S/ 5      5      nSU;  a  UR                  S/ 5      (       d  Mb  [        X7S	S	S
9nUR                  UUR                  SU5      U	/U
UUS9  M     UR                  5         U R                  U5        g)zGenerate a native rules file.

Arguments:
  p: the target project
  rules: the set of rules to include
  output_dir: the directory in which the project/gyp resides
  spec: the project dict
  options: global generator options
z
{}{}.rulestarget_name	rule_name	extensionr   r   r   r  Tr   r   message)namer   
extensionsadditional_dependenciesr   r   N)formatsuffixMSVSToolFileWriterrG   r`   rm   rx   rI   r   AddCustomBuildRuleWriteIfChangedAddToolFile)r  rules
output_dirr   optionsrules_filename
rules_filerr)  rule_extr   r   r   s                r[   _GenerateNativeRulesForMSVSr>  f  s    "((m)<gnnMN$$
Z0$}2EJ kN	[>1552./AEE)R011QUU>2%>%>&ttRVW%%i3 z$* 	& 	
 $  MM.!r]   c                 N    U R                  SS5      n U R                  SS5      n U $ )Nr   z$(OutDirCygwin)r   z$(IntDirCygwin)rn   rt   s    r[   
_CygwinifyrA    s)    <<%67D<<%67DKr]   c           
         SR                  US   UR                  5      n[        R                  R	                  [
        R                  R                  X5      5      nUR                  S5        UR                  S5        [        5       n[        5       n	[        5       n
/ nU  H  n[        X5      nU H  n[        X5      u  nnUR                  [        U5      5        U	R                  [        U5      5        UR                  [        [        U5      5      5        U Vs/ s H%  n[
        R                  R!                  U5      S   PM'     nnU H  nU
R#                  U5        M     M     M     U Vs/ s H  n[%        U5      PM     nnUR                  SSR                  U5      -  5        U
 H   nU(       d  M  UR                  SU-  5        M"     UR                  S	5        U  H  n[        X5      nU H  n[        X5      u  nnU Vs/ s H  n[%        U5      PM     nnU Vs/ s H  n[%        U5      PM     nnUS
    Vs/ s H  n['        UU5      PM     nnU Vs/ s H  nSU-  PM
     nnSR                  U5      nUR                  SR                  SR                  U5      SR                  U5      5      5        UR                  SU-  5        M     M     UR)                  5         UR#                  U5        SSSSSSU/n[+        UUSSSS5      n[-        U5      nUR/                  SU5        [1        U[3        U5      [3        U	5      SUS   -  US9  gs  snf s  snf s  snf s  snf s  snf s  snf )a7  Generate an external makefile to do a set of rules.

Arguments:
  rules: the list of rules to include
  output_dir: path containing project and gyp files
  spec: project specification data
  sources: set of sources known
  options: global generator options
  actions_to_add: The list of actions we will add to.
z{}_rules{}.mkr(  z.OutDirCygwin:=$(shell cygpath -u "$(OutDir)")
z.IntDirCygwin:=$(shell cygpath -u "$(IntDir)")
r   zall: %s
r   z	mkdir -p `cygpath -u "%s"`

r   r   z{}: {}
z	%s

makezOutDir=$(OutDir)zIntDir=$(IntDir)z-jz${NUMBER_OF_PROCESSORS_PLUS_1}z-fTFzRunning external rules for %sr   N)r0  r1  gypcommonWriteOnDiffrG   r`   rm   writer   r  r&  r  r   nextiterr  r!  rA  r  closer   r   r   r   rx   )r7  r8  r   r   r9  actions_to_addr   mk_file
all_inputsall_outputsall_output_dirsfirst_outputsr   trigger_filestfr   r   rw   output_dirsodfirst_outputs_cygcr   s                          r[   _GenerateExternalRulesrX    s    %%d=&97>>JHjj$$RWW\\*%GHGMMCDMMCDJ,K lOM-d<B3D=OFGj01z'23   d7m!458?@1277==+A.K@!##B' "    1>>1A>MM+): ;;<2MM:R?@  MM$-d<B3D=OFG-34VjmVF4.56gz!}gG637>B>a?1b)>CB'*+s!6A:sC+((3-CMM*++CHHW,=sxx?OPQMM*s*+    MMO KK 	(C &dCudD
IC j!Ja"$+&3d=6II[ A ? 56B+s$   ,M0MM!#M&M+M0c                 *    U R                  SS5      n U $ )ar  Escapes % characters.

Escapes any % characters so that Windows-style environment variable
expansions will leave them alone.
See http://connect.microsoft.com/VisualStudio/feedback/details/106127/cl-d-name-text-containing-percentage-characters-doesnt-compile
to understand why we have to do this.

Args:
    s: The string to be escaped.

Returns:
    The escaped string.
%z%%r@  r   s    r[   #_EscapeEnvironmentVariableExpansionr\    s     	
		#tAHr]   z(\\*)"c                 F    S n[         R                  X5      n SU -   S-   n U $ )ac  Escapes a Windows command-line argument.

So that the Win32 CommandLineToArgv function will turn the escaped result back
into the original string.
See http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
("Parsing C++ Command-Line Arguments") to understand why we have to do
this.

Args:
    s: the string to be escaped.
Returns:
    the escaped string.
c                 0    SU R                  S5      -  S-   $ )N   rB   \"rS   r   s    r[   _Replace3_EscapeCommandLineArgumentForMSVS.<locals>._Replace  s     5;;q>!E))r]   r   )quote_replacer_regexsubr   rc  s     r[   !_EscapeCommandLineArgumentForMSVSrh    s+    * 	  -Aa#AHr]   z(\\*)([,;]+)c                    S nU R                  S5      n[        S[        U5      S5       H  n[        R	                  XU   5      X#'   M     SR                  U5      n [        U5      S-  S:X  a  [        SU -   [        R                  S9  U $ )a  Escapes command line arguments for MSVS.

The VCProj format stores string lists in a single string using commas and
semi-colons as separators, which must be quoted if they are to be
interpreted literally. However, command-line arguments may already have
quotes, and the VCProj parser is ignorant of the backslash escaping
convention used by CommandLineToArgv, so the command-line quotes and the
VCProj quotes may not be the same quotes. So to store a general
command-line argument in a VCProj list, we need to parse the existing
quoting according to VCProj's convention and quote any delimiters that are
not already quoted by that convention. The quotes that we add will also be
seen by CommandLineToArgv, so if backslashes precede them then we also have
to escape those backslashes according to the CommandLineToArgv
convention.

Args:
    s: the string to be escaped.
Returns:
    the escaped string.
c                 Z    SU R                  S5      -  S-   U R                  S5      -   S-   $ )Nr_  rB   r   ra  rb  s    r[   rc  5_EscapeVCProjCommandLineArgListItem.<locals>._Replace2  s.     5;;q>!C'%++a.83>>r]   r   r   r_  z;Warning: MSVS may misinterpret the odd number of quotes in r   )	r  ranger   delimiters_replacer_regexrf  rm   r   rC   stderr)r   rc  segmentsrw   s       r[   #_EscapeVCProjCommandLineArgListItemrp    s    ,? wws|H1c(mQ'/33HqkJ ( 	A
8}qA 	NQRR	
 Hr]   c                     [        U 5      n [        U 5      n [        U 5      n U R                  SS[	        S5      -  5      n U $ zBEscapes a CPP define so that it will reach the compiler unaltered.#z\%03o)r\  rh  rp  rn   ordr[  s    r[   _EscapeCppDefineForMSVSru  M  s@    +A.A)!,A+A.A 	
		#x#c(*+AHr]   z(\\+)"c                 6    S n[         R                  X5      n U $ )z;Escapes a Windows command-line argument for use by MSBuild.c                 N    [        U R                  S5      5      S-  S-  S-  S-   $ )NrB   r_     rg   r`  )r   rS   rb  s    r[   rc  6_EscapeCommandLineArgumentForMSBuild.<locals>._Replace^  s)    EKKN#a'!+t3e;;r]   )quote_replacer_regex2rf  rg  s     r[   $_EscapeCommandLineArgumentForMSBuildr{  [  s    < 	!!(.AHr]   c           	          SSSSSSSS.nS	R                  U  Vs/ s H  o!R                  X"5      PM     sn5      nU$ s  snf )
Nz%25z%24z%40z%27z%3Bz%3Fz%2A)rZ  r_   @'r  ?*r   )rm   rI   )r   escape_dictionaryrW  r   s       r[   _EscapeMSBuildSpecialCharactersr  f  sQ     WW1=1a++A11=>FM >s   =c                     [        U 5      n [        U 5      n [        U 5      n U R                  SS[	        S5      -  5      n U $ rr  )r\  r{  r  rn   rt  r[  s    r[   _EscapeCppDefineForMSBuildr  t  s@    +A.A,Q/A'*A 	
		#x#c(*+AHr]   c           	      v   UR                  S/ 5      nU Vs/ s H'  n[        UR                  SS5      5      (       a  M%  UPM)     n	nU Vs/ s H'  n[        UR                  SS5      5      (       d  M%  UPM)     n
nU	(       a  [        X	XU5        U
(       a  [        XX4X&5        [	        XtUS5        gs  snf s  snf )a  Generate all the rules for a particular project.

Arguments:
  p: the project
  output_dir: directory to emit rules to
  options: global options passed to the generator
  spec: the specification for this project
  sources: the set of all known source files in this project
  excluded_sources: the set of sources excluded from normal processing
  actions_to_add: deferred list of actions to add in
r7  msvs_external_ruler   FN)rI   r   r>  rX  _AdjustSourcesForRules)r  r8  r9  r   r   excluded_sourcesrL  r7  r<  rules_nativerules_externals              r[   _GenerateRulesForMSVSr    s     HHWb!E$Pu!C6JA0N,OAuLP!&NA#aee4H!.L*MaNN #AZwO w	
 5+;UC QNs   $B1B1$B63B6c                    U  H  n[        XA5      nU H  nUR                  [        U5      5        [        UR	                  SS5      5      (       d  M?  [        XF5      u  px[        [        U5      5      n[        [        U5      5      nUR                  [        U5      5        UR                  U5        U(       d  UR                  U5        UR                  U5        M     M     g )Nprocess_outputs_as_sourcesF)
r  discardrp   r   rI   r&  r   rx   remover  )	r7  r   r  
is_msbuildr   rR  r"  r   r   s	            r[   r  r    s    -d<)L $$Xl%;<4888%@AA"7"K#If$56$Yw%78h|45v&!$++F3w' * r]   c                     [        [        UR                  5       5      5      nU  Vs/ s H  o3U;  d  M
  UPM     sn$ s  snf )a  Take inputs with actions attached out of the list of exclusions.

Arguments:
  excluded_sources: list of source files not to be built.
  actions_to_add: dict of actions keyed on source file they're attached to.
Returns:
  excluded_sources with files that have actions attached removed.
)r   rx   keys)r  rL  	must_keepr   s       r[   _FilterActionsFromExcludedr    s;     9^%8%8%:;<I'>'!I+=A'>>>s   	==c                     U S   U S      $ )Nr  default_configuration )r   s    r[   _GetDefaultConfigurationr    s     !$'>"?@@r]   c                    [        U5      nUR                  S5      nU(       a=  [        R                  U5      c"  [	        SU< S[        R
                  < S35      eSU-  nU=(       d    [        R                  " U 5      nU$ )zGet the guid for the project.

Arguments:
  proj_path: Path of the vcproj or vcxproj file to generate.
  spec: The target dictionary containing the properties of the target.
Returns:
  the guid.
Raises:
  ValueError: if the specified GUID is invalid.
	msvs_guidzInvalid MSVS guid: "z".  Must match regex: "z".z{%s})r  rI   VALID_MSVS_GUID_CHARSr   
ValueErrorpatternMSVSNewMakeGuid)	proj_pathr   default_configguids       r[   _GetGuidOfProjectr    su     .d3Nk*D &&t,4.668  }.7##I.DKr]   c                     [        U5      nUR                  S5      nU(       d%  UR                  5       (       a  UR                  5       nUS   S:X  a  SnU$ )a  Get the platform toolset for the project.

Arguments:
  proj_path: Path of the vcproj or vcxproj file to generate.
  spec: The target dictionary containing the properties of the target.
  version: The MSVSVersion object.
Returns:
  the platform toolset string or None.
msbuild_toolsetr   windows_driverzWindowsKernelModeDriver10.0)r  rI   DefaultToolset)r  r   r   r  toolsets        r[   _GetMsbuildToolsetOfProjectr    sU     .d3N  !23Gw--//((*F|''/Nr]   c                     [        U R                  5      nUR                  S5      (       a  / $ UR                  5       (       a  [	        XX#U5      $ [        XX#5      $ )a  Generates a vcproj file.

Arguments:
  project: the MSVSProject object.
  options: global generator options.
  version: the MSVSVersion object.
  generator_flags: dict of generator-specific flags.
Returns:
  A list of source files that cannot be found on disk.
msvs_existing_vcproj)r  r   rI   r   _GenerateMSBuildProject_GenerateMSVSProject)projectr9  r   generator_flagsr   r  s         r[   _GenerateProjectr    sW     .gll;N 011	&wSWXX#GgOOr]   c           	      ,   U R                   n[        R                  R                  U R                  5        [        U5      n[        R                  " U R                  X$S   U R                  U5      n[        R                  R                  U R                  5      S   n[        U R                  5      n[        R                  R                  X5      n	[        X@R                  5      n
US   R                  5        H  u  p[!        XdXU5        M     [        R                  R                  U R                  5      S   n[#        XCU5      u  p0 n[%        XgXXU5        UR'                  SS5      n[)        XAX~UUU5      u  pn[+        X5      nUR-                  U5        [/        Xd5        [1        XnU5        [3        UXI5        [5        UU5        [7        U R                  X$5        [9        UU5      n[;        XdUUU5        [=        XdU5        UR?                  5         U$ )a!  Generates a .vcproj file.  It may create .rules and .user files too.

Arguments:
  project: The project object we will generate the file for.
  options: Global options passed to the generator.
  version: The VisualStudioVersion object.
  generator_flags: dict of generator-specific flags.
r(  r   r  rB   msvs_list_excluded_filesT) r   rE  rF  EnsureDirExistsr`   _GetUniquePlatformsr   r3  r  rG   r  re   
build_fileRelativePath_GetMSVSConfigurationTyper
  _AddConfigurationToMSVSProject_PrepareListOfSourcesr  rI   )_AdjustSourcesAndConvertToFilterHierarchy_VerifySourcesExistAddFiles_AddToolFilesToMSVS_HandlePreCompiledHeaders_AddActions
_AddCopies_WriteMSVSUserFiler  _ExcludeFilesFromBeingBuiltr  r5  )r  r9  r   r  r   	platformsr  project_dirgyp_pathrelative_path_of_gyp_fileconfig_typer   r?   gyp_filer   r  rL  r|   excluded_idlmissing_sourcess                       r[   r  r  	  s    <<DJJw||,#D)IgM2GLL)	A
 ''---a0K !3!34H #

 7 7 N+D2D2DEK#$45;;=&q&Q  > ww}}W//03H 5dX VG N	w. $''(BDIM.W{-=}g/+G|
 *'?OJJw a$/@~t$w||W3 22BNS)9<W .9 r]   c                     [        5       nU S    H#  nUR                  [        U S   U   5      5        M%     [        U5      nU$ )zReturns the list of unique platforms for this spec, e.g ['win32', ...].

Arguments:
  spec: The target dictionary containing the properties of the target.
Returns:
  The MSVSUserFile object created.
r  )r   r!  r   r   )r   r  configurations      r[   r  r  G  sF     I./od+;&<]&KLM 0YIr]   c                 z    [        5       u  p4SR                  XUS/5      n[        R                  " XQUS   5      nU$ )aq  Generates a .user file for the user running this Gyp program.

Arguments:
  proj_path: The path of the project file being created.  The .user file
             shares the same path (with an appropriate suffix).
  version: The VisualStudioVersion object.
  spec: The target dictionary containing the properties of the target.
Returns:
  The MSVSUserFile object created.
r   userr(  )r\   rm   MSVSUserFiler3  )r  r   r   rT   rU   vcuser_filename	user_files          r[   _CreateMSVSUserFiler  W  sA     /0Vhh	8VDEO##Od=>QRIr]   c           
           SSSSSSS.U S      nU$ ! [          aL    U R                  S5      (       a  [        SU S   < S	U S
   < SU< S35      e[        SU S
   < SU< S35      ef = f)a  Returns the configuration type for this project.

It's a number defined by Microsoft.  May raise an exception.

Args:
    spec: The target dictionary containing the properties of the target.
    build_file: The path of the gyp file.
Returns:
    An integer, the configuration type.
124510)
executableshared_libraryloadable_modulestatic_libraryr  noner   zTarget type z' is not a valid target type for target r(  z in r   zMissing type field for target )KeyErrorrI   r   )r   r  r  s      r[   r  r  h  s    !"!!
 v,&   
88F&*6lD4GU 
 &
4 
s
    AA)c           	         [        U5      u  pVn[        U5      n[        U5      n	[        USS9u  pn[	        U5      nU Vs/ s H  n[        U5      PM     nn[        U5      nUR                  S5      nUR                  S5      n[        U5      nUR                  S5      n0 nUR                  S0 5      n[        R                  " U5        [        USSS	/5        U H%  nUS   U   nU H  n[        UUUUU   5        M     M'     [        US
SU5        [        USSU5        [        USSU5        [        USSU5        [        USSU	5        U
(       a  [        UUSU
SS9  [        US
SU5        [        USSU5        [        US
SSSS9  [        US
SU5        [        USSU5        [        USSU5        U(       aL  [        R                  R                  U5      S   n[        US
SS5        [        US
SU5        [        US
SU5        US   S:X  a  [        USS S!5        U(       a  [        USS"U5        [        XUXBU5        g#s  snf )$a  Adds a configuration to the MSVS project.

Many settings in a vcproj file are specific to a configuration.  This
function the main part of the vcproj file that's configuration specific.

Arguments:
  p: The target project being generated.
  spec: The target dictionary containing the properties of the target.
  config_type: The configuration type, a number as defined by Microsoft.
  config_name: The name of the configuration.
  config: The dictionary that defines the special processing to be done
          for this configuration.
Fmsbuildmsvs_prebuildmsvs_postbuildr6   msvs_settingsVCLinkerToolr  $(NOINHERIT)VCCLCompilerToolAdditionalIncludeDirectories
VCMIDLToolVCResourceCompilerToolAdditionalLibraryDirectories
OutputFileTr   PreprocessorDefinitionsProgramDataBaseFileNamez $(IntDir)$(ProjectName)\vc80.pdbDisableSpecificWarningsVCPreBuildEventToolr  VCPostBuildEventToolrB   UsePrecompiledHeaderr  PrecompiledHeaderThroughForcedIncludeFilesr   r  IgnoreImportLibrarytrueModuleDefinitionFileN)_GetIncludeDirs_GetLibraries_GetLibraryDirs_GetOutputFilePathAndTool_GetDefinesru  _GetDisabledWarningsrI   _GetModuleDefinitionr   ValidateMSVSSettingsr   rG   r`   r  _AddConfigurationToMSVS)r  r   r  r   r?   include_dirsmidl_include_dirsresource_include_dirs	librarieslibrary_dirsout_filevc_toolr   definesddisabled_warningsprebuild	postbuilddef_fileprecompiled_headerr   r  r   settingsr   s                            r[   r  r    sw    >MV=T:L%:d#I"6*L4T5IHq&!G3:;7a&q)7G;,V4zz/*H

+,I#D)H$=> EJJ3M%%m4 ~'?.AQR/*40GtWhw.?@   
 )+I<X|%CEVW &	 ~'?K~'E|TE7L($O)+DgN/1JGT!+ )+DFWX,mXF-}iHWW]]+=>qAE-/EsK%'ACU	
 	E-/CEWX F|((E>+@&IE>+A8LAUFMG <s   I c                    U R                  S/ 5      U R                  S/ 5      -   nU R                  S/ 5      U R                  S/ 5      -   nU R                  SU5      n[        U5      n[        U5      n[        U5      nXU4$ )zReturns the list of directories to be used for #include directives.

Arguments:
  config: The dictionary that defines the special processing to be done
          for this configuration.
Returns:
  The list of directory paths.
r  msvs_system_include_dirsr  r  rI   rx   )r?   r  r  r  s       r[   r  r    s     ::nb1FJJ"B5 L 

#6;fjj"B?  #JJ'>M\*L!"34%&;<,AAAr]   c                 @    U R                  S/ 5      n[        U5      nU$ )zReturns the list of directories to be used for library search paths.

Arguments:
  config: The dictionary that defines the special processing to be done
          for this configuration.
Returns:
  The list of directory paths.
r  r  )r?   r  s     r[   r  r    s$     ::nb1L\*Lr]   c                 `   U R                  S/ 5      n[        5       n/ n[        U5       Hp  n[        R                  " SSU5      n[
        R                  R                  U5      S   (       d  US-  nXR;  d  MN  UR                  U5        UR                  U5        Mr     UR                  5         U$ )zReturns the list of libraries for this configuration.

Arguments:
  spec: The target dictionary containing the properties of the target.
Returns:
  The list of directory paths.
r  z^\-lr   rB   r   )rI   r   reversedrO   rf  rG   r`   r  r!  r   r   )r   r  foundunique_libraries_listentrylibrarys         r[   r  r    s     b)I
 LE)$&&"e,ww(+vGIIg!((1 % !!#  r]   c                    SnSnSnSSSSSS.nUR                  U S   5      nU(       a  [        U R                  SS	5      5      (       a  Uu  p4pxU R                  S
S5      (       a  SnU R                  SU5      nU R                  S5      n	U	(       a  SU	-   nO	U(       a  SnU R                  SS5      n
U R                  SS5      n[        R                  " XzU-   U-   5      nX#U4$ )a@  Returns the path and tool to use for this target.

Figures out the path of the file this spec will create and the name of
the VC tool that will create it.

Arguments:
  spec: The target dictionary containing the properties of the target.
Returns:
  A triple of (file path, name of the vc tool, name of the msbuild tool)
r   )r  Linkr   r   )r  r  r   r   )r  r  r   r	   )VCLibrarianToolLibz$(OutDir)lib\r   r  r  r  r  r  r   msvs_auto_output_filerB   standalone_static_libraryr   r   product_dirproduct_extensionr   z$(TargetExt)product_prefixproduct_name$(ProjectName))rI   r   ntpathrm   )r   r  r  r  msbuild_tooloutput_file_mapoutput_file_propsout_dirr1  r#  r   r%  s               r[   r  r  %  s     HGLCGHGNO (++DL9S*A1!EFF1B.w88/33!G((='2 HH%89,,F#F*B/xx0@A;;w(=(FGl**r]   c                 >    U R                  S5      nU(       a  SU-   $ g)aa  Returns the extension for this target, including the dot

If product_extension is specified, set target_extension to this to avoid
MSB8012, returns None otherwise. Ignores any target_extension settings in
the input files.

Arguments:
  spec: The target dictionary containing the properties of the target.
Returns:
  A string with the extension, or None
r#  r   Nr   )r   target_extensions     r[   _GetOutputTargetExtr.  L  s&     xx 34%%%r]   c           	          / nU R                  S/ 5       H_  n[        U[        5      (       a+  SR                  U Vs/ s H  n[	        U5      PM     sn5      O
[	        U5      nUR                  U5        Ma     U$ s  snf )zReturns the list of preprocessor definitions for this configuration.

Arguments:
  config: The dictionary that defines the special processing to be done
          for this configuration.
Returns:
  The list of preprocessor definitions.
r	  r   )rI   r   r   rm   r   r   )r?   r	  r
  dpartfds        r[   r  r  ^  sj     GZZ	2&6@D6I6ISXXq1qes5zq12sSTvr ' N 2s   A:
c                 d    U R                  S/ 5       Vs/ s H  n[        U5      PM     sn$ s  snf )Nmsvs_disabled_warnings)rI   r   )r?   rw   s     r[   r  r  n  s,    "JJ'?DEDqCFDEEEs   -c                 .   SnU S   S;   a  U R                  S/ 5       Vs/ s H  o"R                  S5      (       d  M  UPM     nn[        U5      S:X  a  [        US   5      nU$ U(       a%  [	        SU S	   < S
SR                  U5      < 35      eU$ s  snf )Nr   r   )r  r  r  r  r   z.defrB   r   z7Multiple module definition files in one target, target r(  z lists multiple .def files: r   )rI   r   r   rp   r  rm   )r   r  r   	def_filess       r[   r  r  r  s    HF|   !%B 7N 71::f;MQ 7	Ny>Q	!-H O -1--@#((9BUW  O Os
   BBc                 b   / nU R                  5        H  u  p#0 nUR                  5        HX  u  pV[        U5      [        :X  a<  US:X  a  US:X  d  US:X  a  SR                  U5      XE'   M?  SR                  U5      XE'   MT  XdU'   MZ     UR	                  [
        R                  " X$5      5        M     U$ )zConvert tools to a form expected by Visual Studio.

Arguments:
  tools: A dictionary of settings; the tool name is the key.
Returns:
  A list of Tool objects.
r  r  AdditionalOptionsr   r  )r
  r   r   rm   r   r   r	  )r   	tool_listr   r  settings_fixedr   r   s          r[   _ConvertToolsToExpectedFormr:    s     I++-&nn.NGE{d"N*w:R/R 33.1hhuoN+.1hhuoN+*/w' / 	))$?@ ( r]   c                 d    [        XU5      n[        U5      nU R                  [        XS5      XgS9  g)a  Add to the project file the configuration specified by config.

Arguments:
  p: The target project being generated.
  spec: the target project dict.
  tools: A dictionary of settings; the tool name is the key.
  config: The dictionary that defines the special processing to be done
          for this configuration.
  config_type: The configuration type, a number as defined by Microsoft.
  config_name: The name of the configuration.
)attrsr   N)_GetMSVSAttributesr:  	AddConfigr   )r  r   r   r?   r  r   
attributesr8  s           r[   r  r    s/     $D+>J+E2IKK4JKXr]   c                    0 nUR                  S0 5      nU H	  nXE   X5'   M     UR                  S/ 5      n[        U5      nU(       a  SR                  U5      US'   X#S'   UR                  SS5      n[        U5      S-   US'   S	U;  a  S
n[        U5      S-   US	'   U$ [        US	   5      S-   n[        R
                  " U5      nXS	'   U$ )Nmsvs_configuration_attributesr'   r  InheritedPropertySheetsConfigurationTypeOutputDirectoryz"$(SolutionDir)$(ConfigurationName)rg   IntermediateDirectoryz'$(ConfigurationName)\obj\$(ProjectName))rI   rx   rm   rp   r   r   )	r   r?   r  prepared_attrssource_attrsavsprops_dirsr8  intermediates	            r[   r=  r=    s    N::=rBL(O  ::lB/L\*L47HH\4J01*5&'##?J )1(<t(CN$%n4B2:<2H42O./
   /F GH4O#55lC2>./r]   c                 4    U R                  S U 5       5        g )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr   )re   r   r   s     r[   r   (_AddNormalizedSources.<locals>.<genexpr>  s     C](++]s   )r  )sources_setsources_arrays     r[   _AddNormalizedSourcesrQ    s    C]CCr]   c                    [        5       n[        X0R                  S/ 5      5        [        5       nUR                  S5      (       d  UR                  U5        U R                  S/ 5       H  nUS   nU Vs/ s H  n[	        U5      PM     nn[        U5      nUR                  U5        U R                  S5      (       d  UR                  U5        [        UR                  SS5      5      (       d  M  [        X5R                  S/ 5      5        M     U R                  S	/ 5       H  n[        X8R                  S
/ 5      5        M      X44$ s  snf )a  Prepare list of sources and excluded sources.

Besides the sources specified directly in the spec, adds the gyp file so
that a change to it will cause a re-compile. Also adds appropriate sources
for actions and copies. Assumes later stage will un-exclude files which
have custom build steps attached.

Arguments:
  spec: The target dictionary containing the properties of the target.
  gyp_file: The name of the gyp file.
Returns:
  A pair of (list of sources, list of excluded sources).
  The sources will be relative to the gyp file.
r   
standaloneactionsr   r+   r  Fr   copiesfiles)r   rQ  rI   r!  re   r  r   )	r   r  r  r   r  rH  r   rw   cpys	            r[   r  r    s    lG'88Ir#:;!||,,H XXi$80671#A&7F#vxx/00##F+quu159::!'55B+?@ % xx"%gwww';< &&& 8s   5Ec                    UR                  [        U R                  S/ 5      5      5        UR                  U5        [        U5      n[        U5      n[	        X5      n[        U 5      nU V	s/ s H  oU;  d  M
  U	PM     n
n	U V	s/ s H  oR                  S5      PM     nn	[        UU
UUS9nUR                  5       (       a  [        S U 5       5      (       a  [        U Vs1 s H  oR                  iM     sn5      S:X  ay  [        S U 5       5      (       d   eU Vs/ s H  oR                  S   PM     nn[        S U 5       5      (       a+  [        U Vs1 s H  oR                  iM     sn5      S:X  a  My  Os[        U5      S:X  ad  [        US   [        R                  5      (       aB  US   R                  n[        U5      S:X  a$  [        US   [        R                  5      (       a  MB  X4U4$ s  sn	f s  sn	f s  snf s  snf s  snf )a  Adjusts the list of sources and excluded sources.

Also converts the sets to lists.

Arguments:
  spec: The target dictionary containing the properties of the target.
  options: Global generator options.
  gyp_dir: The path to the gyp file being processed.
  sources: A set of sources to be included for this project.
  excluded_sources: A set of sources to be excluded for this project.
  version: A MSVSVersion object.
Returns:
  A trio of (list of sources, list of excluded sources,
             path of excluded IDL file)
sources_excludedrg   rz   c              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7fr   )r   r   r   rM  s     r[   r   <_AdjustSourcesAndConvertToFilterHierarchy.<locals>.<genexpr>(  s      C7a
1k00117s   ')rB   c              3   R   #    U  H  n[        UR                  5      S :H  v   M     g7f)rB   N)r   r~   rM  s     r[   r   r[  +  s     =Ws1::!+Ws   %'r   )r  r   rI   rx   _IdlFilesHandledNonNatively_GetPrecompileRelatedFilesr  r   r   allr   r-  r~   r   r   r   )r   r9  gyp_dirr   r  r|   r   r  precompiled_relatedrw   fully_excludedr   s               r[   r  r    s   & Jtxx0BB'GHINN#$  G !12.t=L4T:!1R!1A>Q5Qa!1NR '..gwwt}gG..#	G C7CCCW-WVVW-.!3=W=====.56gzz!}gG6	 C7CCCW-WVVW-.!3
 'laJwqz;;M;M$N$Naj))G 'laJwqz;;M;M$N$N l221 S / . 7 .s$   ,	G39G3G8"G=HHc                    SnU R                  S/ 5       H2  nUS   S:X  d  M  [        UR                  SS5      5      (       d  M0  Sn  O   U(       a+  U Vs/ s H  oDR                  S5      (       d  M  UPM     nnU$ / nU$ s  snf )	NFr7  r*  idlr  r   T.idl)rI   r   r   )r   r   	using_idlr   rw   r  s         r[   r]  r]  4  s     I"%%#dhh7KQ.O*P*PI & BKw=w!**V*<AwL= QSL >s   B3Bc                     / nU S   R                  5        HF  u  p#[         H7  nUR                  U5      nU(       d  M  UR                  [	        U5      5        M9     MH     U$ )Nr  )r
  precomp_keysrI   r   rp   )r   ra  r   r?   kr   s         r[   r^  r^  @  sY    *+113	A

1Aq#**8A;7  4
 r]   c           	          [        XU5      nUR                  5        HR  u  pgU(       d  [        U5      [        US   5      :X  a  M)  U H#  u  pU R                  U[	        X5      SS05        M%     MT     g )Nr  ExcludedFromBuildr  )_GetExcludedFilesFromBuildr
  r   r  r   )
r  r   r  r  r|   
exclusions	file_nameexcluded_configsr   r?   s
             r[   r  r  K  sp    +DLQJ'1'7'7'9#	%5!6#dCS>T:U!U '7##K8(&1 (8 (:r]   c                 t   0 nU Hm  n/ nU S   R                  5        HM  u  pg[         Vs/ s H  n[        UR                  US5      5      PM      n	nXI;  d  M;  UR	                  Xg45        MO     XSU'   Mo     U H7  n/ nU S   R                  5        H  u  pgUR	                  Xg45        M     XSU'   M9     U$ s  snf )Nr  r   )r
  rh  rp   rI   r   )
r   r  r  rm  r   ro  r   r?   rw   	precompeds
             r[   rl  rl  [  s    J#'(8#9#?#?#AK>JKl&**Q"34lIK! ''(=>	 $B
 )1  #'(8#9#?#?#AK##[$9: $B(1	 
  Ls   %B5c                     [        5       nUS   R                  5        H/  u  p4UR                  S/ 5       H  nUR                  U5        M     M1     U H  nU R	                  U5        M     g )Nr  msvs_tool_files)r   r
  rI   r!  r6  )r  r   
tool_filesr   r?   r   s         r[   r  r  p  s^    J*+113	-r2ANN1 3 4 	a r]   c                   ^ ^^	^
 / m
TS   R                  5        H  u  p4UR                  S5      nU(       d  M  [        U5      n[        R                  " SSS05      nT R                  U[        X45      0 U/S9  [        R                  R                  U5      u  pxUS:X  a  / SQm
M  S/m
M     U	U
U U4S	 jm	T
(       a	  T	" U5        g g )
Nr  r7   r  r  r  r  .c.cc.cpp.cxxc           	        > U  H  n[        U[        R                  5      (       a  T" UR                  5        M6  [        R
                  R                  U5      u  p#UT;   d  M_  T
S   R                  5        HD  u  pE[        R                  " SSSS.5      nT	R                  [        U5      [        XE5      0 U/S9  MF     M     g )Nr  r  0r  )r  r  r  )r   r   r   r~   rG   r`   r  r
  r	  r  rp   r   )source_treerc   basenamer*  r   r?   r   DisableForSourceTree#extensions_excluded_from_precompiler  r   s          r[   r  7_HandlePreCompiledHeaders.<locals>.DisableForSourceTree  s    !F&+"4"455$V__5&(gg&6&6v&># CC/34D/E/K/K/M+*//.8;6D  $V,+K@#'&	 (  0N "r]   )
r
  rI   rp   r   r	  r  r   rG   r`   r  )r  r   r   r   r?   rc   r   r~  r*  r  r  s   ` `      @@r[   r  r  z  s    
 +-'#$45;;=566f%F##$69OQT8UVDOO<b   #%''"2"26":HD 6M37;f3  > . +W% +r]   c                 .   UR                  S/ 5      n[        5       nU Hs  nUR                  S5      =(       d    U/nUS   nXt;  n[        XSUS9n	UR                  U5        [	        U UUR                  S/ 5      UR                  SUS   5      U	S	9  Mu     g )
NrT  r   r   Fr+  r   r,  action_namer   )rI   setr   r!  r   )
rL  r   r  rT  have_setup_envrH  r   attached_toneed_setup_envr   s
             r[   r  r    s    hhy"%G
 UNx?%>$?Qi$:&E
 	;'EE)R(i=)9:	
 r]   c                    SU;   a<  US   nUR                  S/ 5      nUR                  S/ 5      nUR                  SS5      nO*[        UR                  SS5      5      (       a	  SS	/n/ nSnOg [        XU5      nUS
   R                  5        H!  u  pUR	                  [        X5      XEU5        M#     UR                  5         g )Nrun_asr   environmentworking_directoryr   testr   z$(TargetPath)z--gtest_print_timer  )rI   r   r  r
  AddDebugSettingsr   r5  )
project_pathr   r   r  r   r  r  r  r   r  s
             r[   r  r    s    4hHb)jj3"JJ':C@	TXXfa 	!	!!#78#L4@I#$45;;=""K0&GX	
  > r]   c           	      L    [        U5      nU H  u  p4pV[        U UUUUS9  M     g )Nr   )
_GetCopiesr   )rL  r   rU  r   r   r   r   s          r[   r  r    s2    F-3)#	
 .4r]   c                    / nU R                  S/ 5       GHM  nUR                  S/ 5       GH2  n[        R                  R                  US   [        R                  R	                  U5      5      nUR                  S5      (       a  US S n[        R                  " U5      S   n[        R                  " U5      S   n[        U5      nSU S	U S
3n	SR                  U	[        U5      UU	5      n
UR                  U/SU/U
SU SU 345        M  [        US   5      nSR                  U[        U5      [        U5      5      n
UR                  U/U/U
SU SU 345        GM5     GMP     U$ )NrU  rV  destinationrh   ri   r   rB   r   rg   r`  z2mkdir {} 2>nul & cd "{}" && xcopy /e /f /y "{}" {}dummy_copieszCopying z to z7mkdir "{}" 2>nul & set ERRORLEVEL=0 & copy /Y "{}" "{}")rI   rG   r`   rm   r~  r   	posixpathr  rp   r0  r   )r   rU  rW  srcdstsrc_barebase_dir	outer_dir	fixed_dstfull_dstr   fix_dsts               r[   r  r    sn   Fxx"%777B'C'',,s=12773C3CC3HIC ||C  s8$??84Q7%OOH5a8	$SM	ykI;c:JQQX&	 '-"3%tI;7	 #3}#56OVVSMSM
 useSHSEgY2OPQ? ( &B Mr]   c                     U(       a$  UR                  [        R                  5      (       a  U $ [        R                  R	                  U5      u  p#[        X5      nX4;  a  0 XC'   XC   $ r   )r   rG   sepr`   r  _GetPathDict)rootr`   parentfolderparent_dicts        r[   r  r    sS     4==((WW]]4(NFt,K  r]   c                    / nUR                  5        H  u  pE[        U5      [        :X  a  [        [        R
                  R                  X5      XR5      nU(       a  X6-  nMN  [        R                  " [        R
                  R                  X5      SU-   S-   US9nUR                  U5        M  UR                  U5        M     U$ )N())r-  entries)
r
  r   dict_DictsToFoldersrG   r`   rm   r  
MSVSFolderr   )	base_pathbucketflatchildrenr  r~   folder_childrens          r[   r  r    s    H"LLN>T!-Y/O +")"4"4GGLL3v++#
 0OOH% +  Or]   c                 
   [        U5      [        :X  aA  [        U5      S:X  a2  [        [	        U5      5      U S-   :X  a  U[        [	        U5      5         $ [        U5      [        :w  a  U$ U H  n[        X!U   5      X'   M     U$ )NrB   .vcproj)r   r  r   rI  rJ  _CollapseSingles)r  nodechilds      r[   r  r  0  ss     DzTc$i1nd4j1AViEW1WDd$%%DzT&u5k: Kr]   c                 :   0 nU  Hu  n[         R                  R                  U5      SS u  pVUR                  S5      (       a  US-  n[        R
                  R                  U5      n[        X75      nX   XS-   '   Mw     [        U5      S:X  ax  [        U[        [        U5      5         5      [        :X  aP  U[        [        U5      5         n[        U5      S:X  a*  [        U[        [        U5      5         5      [        :X  a  MP  [        SU5      n[        SX25      $ )Nr   r_  z#host_hostr  rB   r   )rE  rF  ParseQualifiedTargetr   rG   r`   r  r  r   r   rI  rJ  r  r  r  )	sln_projectsproject_objectsr  r  r  r  targetr`  	path_dicts	            r[   _GatherSolutionFoldersr  =  s    D::::1=aB::ggF''//(+ /	(7(:	9$%  d)q.T$tDJ'7"89TADd$% d)q.T$tDJ'7"89TA B%D2t**r]   c                    [        U5      nUR                  S5      nU(       d2  US   nUS   S:X  a  US-  nXRR                  -   UR                  5       -   n[        R
                  R                  U 5      n[        R                  R                  [        R                  R                  U5      U5      nS nUR                  (       a  [        R                  R                  [        R                  R                  U5      5      n	[        R                  R                  UR                  U5      n[        R
                  R                  U	[        R                  R                  U5      5      nXx4$ )Nr  r(  r  hostr  )r  rI   r1  ProjectExtensionrE  rF  	BuildFilerG   r`   rm   r  generator_outputabspathr  )
qualified_targetr   r9  r}   r  proj_filenamer  r  
fix_prefixproject_dir_paths
             r[   _GetPathOfProjectr  R  s	   -d3N"&&'=>M]+	?f$W$M%69V9V9XX%%&67JRWW__Z8-HIJ77??277??9+EFGGLL!9!99E	ZZ,,bggooi8

   r]   c           	         0 nU S   R                  5        Hm  u  p#[        X#5      nUR                  S[        U5      5      nSR	                  [        U[        U5      5      U5      nU S   S:X  a  [        (       a  U S3nXaU'   Mo     U$ )Nr  msvs_target_platformz{}|{}r  r  z|x64)r
  r   rI   r   r0  r   $generator_supports_multiple_toolsets)r   config_platform_overridesr   rW  config_fullnamerD   fixed_config_fullnames          r[   _GetPlatformOverridesOfProjectr  g  s     !#/0668)+955/1CD 'K);<!
 	?f$)M)M'2m4$8!5J/2 9 %$r]   c                 t   0 nU  H  nX   n[        XVX#5      u  nq[        Xv5      n[        U5      n	[        R
                  R                  U5      n
US   nUS   S:X  a  US-  n[        R                  " UUUUU
U	[        S9nUR                  5       (       a  UR                  [        XvU5      5        XU'   M     UR                  5        Hf  nUR                  R                  S5      (       a  M%  UR                  R                  S/ 5      nU Vs/ s H  oU   PM	     nnUR                  U5        Mh     U$ s  snf )aH  Create a MSVSProject object for the targets found in target list.

Arguments:
  target_list: the list of targets to generate project objects for.
  target_dicts: the dictionary of specifications.
  options: global generator options.
  msvs_version: the MSVSVersion object.
Returns:
  A set of created projects, keyed by target.
r(  r  r  r  )r-  r  r   r  r  rj   r+   dependencies)r  rj   r  r  rE  rF  r  r  r   r   set_msbuild_toolsetr  valuesr   rI   set_dependencies)target_listtarget_dictsr9  r}   projectsr  r   r  r  	overridesr  r(  objr  depsr
  s                   r[   _CreateProjectObjectsr  x  sC    H'-$5G%
!	> !1248	ZZ))*:;
=)	?f$7"K!!!&/)
 ##%%##+I\J &)!"5 (: ??$|| 788<<##NB7D)-.AQKD.$$T*	 %
 O /s   D5c                    U GHj  nX#   nUR                  S5      (       a  M   UR                  SS5      nSUS'   UR                  S5      (       d  [        R                  R                  U5      u  n  n[        R
                  R                  U5      nSn	U R                  S5      S:X  a  U	S	-  n	U R                  S5      S
:X  a  U	S-  n	[        R
                  R                  [        R                  R                  U S   R                  U5      [        R                  " U 5      U	5      US'   UR                  S5      (       d	  USSS/US'   UR                  S5      (       a  GM`  USSSS/US'   GMm     g)a  Initialize targets for the ninja flavor.

This sets up the necessary variables in the targets to generate msvs projects
that use ninja as an external builder. The variables in the spec are only set
if they have not been set. This allows individual specs to override the
default values initialized here.
Arguments:
  params: Params provided to the generator.
  target_list: List of target pairs: 'base/base.gyp:base'.
  target_dicts: Dict of target properties keyed on target pair.
r+   msvs_path_to_ninjaz	ninja.exeninjar,   $(Configuration)target_archx64_x64arm64_arm64r9  r-   z-Cr   r&  r.   z-tcleanN)rI   rE  rF  r  rG   r`   r  rm   r  toplevel_dirninja_generatorComputeOutputDir)
paramsr  r  r  r   path_to_ninjar  r   r`  r  s
             r[   _InitNinjaFlavorr    s_    (-88+,,!5{C(/$%xx788 ZZ<<=MNNHaggooh/G.Mzz-(E1'zz-(G3)46GGLL

''y(9(F(FP0085D01
 xx9:: 	7D23 xx9:: 7D23= (r]   c                    UR                  S0 5      n[        R                  " UR                  SS5      5      nX1S'   UR                  5       U S'   [        R
                  R                  SS5      R                  S5      S:  d3  [        R
                  R                  S	S5      R                  S5      S:  a  S
U S'   OSU S'   [        R                  R                  U5      S:X  a  SU S'   gg)z4Generated variables that require params to be known.r  r}   autoMSVS_VERSIONPROCESSOR_ARCHITECTUREr   64r   PROCESSOR_ARCHITEW6432@   MSVS_OS_BITS    r  z$(OutDir)genr   N)
rI   r   SelectVisualStudioVersion	ShortNamerG   rH   r   rE  rF  	GetFlavor)default_variablesr  r  r}   s       r[   CalculateVariablesr    s     jj!2B7O 88NF3L *> )5(>(>(@n% 	

/499$?1D::>>2B7<<TBaG,..),..)
zzF#w.7E34 /r]   c                    US   nUS   n[         R                  R                  UR                  SSS5      nU R                  5        H|  u  pg[         R                  R	                  U5      u  pU	S:w  a  M.  XR
                  -   S-   n
UR                  (       d  MR  [         R                  R                  UR                  U
5      n
M~     U H0  nUW
SU/n[        S	U S
U 35        [        R                  " U5        M2     g )Nr9  r}   Common7IDEz
devenv.com.gyp.slnz/Buildz
Building [z]: )
rG   r`   rm   r
  r  r1  r  r   rJ   
check_call)datar  r  r9  r}   devenvr  build_file_dictbuild_file_rootbuild_file_extsln_pathr?   r   s                r[   PerformBuildr    s    YG.)LWW\\,++Y|LF'+zz|#
,.GG,<,<Z,H)V#"^^3f<###ww||G$<$<hGH (4 !Xx8	
6(#i[12i( !r]   c                     U R                  S5      S:X  ag  U S   R                  n[        R                  R	                  [        R                  R                  U[        R                  " U 5      S5      5      nUUS.qg g )Nflavorr  r9  zgypfiles-msvs-ninja)toplevelqualified_out_dir)	rI   r  rG   r`   ra   rm   r  r  generator_filelist_paths)r  r  r  s      r[   CalculateGeneratorInputInfor
    sq    zz(w&)$11GG,,GGLL008%
 !!2$
  'r]   c           
         US   nUS   nUR                  S0 5      n[        R                  " X5      u  p[        R                  " X[        5      u  pUR                  S5      S:X  a  [        X0U5        [        5       nU  HX  nX   n	U	S   R                  5        H:  u  p[        X5      n
UR                  U
5        U
S:X  d  M)  UR                  S5        M<     MZ     [        U5      n[        XXE5      n/ nUR                  5        H+  nUR                  qUR                  [        XXVW	5      5        M-     S	qU GHB  nUn[         (       a*  U Vs/ s H  nUR#                  S
5      (       d  M  UPM     nnUR#                  S5      (       d  MS  [$        R&                  R)                  U5      S   UR*                  -   S-   nUR,                  (       a*  [$        R&                  R/                  UR,                  U5      n[0        R2                  R5                  X5      nU[0        R2                  R7                  UU5      -  n[9        UXR;                  5       S9n[<        R>                  " UUUSUS9nURA                  5         GME     U(       a[  SSR/                  [        U5      5      -   nUR                  SS5      (       a  [C        U5      e[E        SU-   [F        RH                  S9  g	g	s  snf )a  Generate .sln and .vcproj files.

This is the entry point for this generator.
Arguments:
  target_list: List of target pairs: 'base/base.gyp:base'.
  target_dicts: Dict of target properties keyed on target pair.
  data: Dictionary containing per .gyp data.
r9  r}   r  r  r  r  zRelease|arm64zRelease|x64Nr  r  r   r  )r  F)r  variantswebsitePropertiesr   zMissing input files:
rC  msvs_error_on_missing_sourcesz	Warning: r   )%rI   MSVSUtilShardTargetsInsertLargePdbShimsgenerator_default_variablesr  r  r
  r   r!  r   r  r  rj   extendr  r  r   rG   r`   r  r1  r  rm   rE  rF  BuildFileTargetsDeepDependencyTargetsr  FlatSolutionr  MSVSSolutionWriter   r   rC   rA   )r  r  r  r  r9  r}   r  configsr  r   r   r?   r  r  r  r  target_only_configsrw   r  r  root_entriesslnerror_messages                          r[   GenerateOutputr  "  s    YG .)Ljj!2B7O #+"7"7"R[ #+">">#>#[
 zz(w&l; eG'-#'(8#9#?#?#AK)+>KKK$o-M*	 $B ( 7mG ,7O
 O"))+ //W|dS	
 ,
 N
%//.5"MgG9L1g"M""6**77##J/2W^^CfL##ww||G$<$<hGHzz22;K

88|TT-/0I0I0K
 "" (# 
 			3 6 0499S=Q3RR>FF=))+-CJJ? / #Ns   K!*K!c           
         / n/ n[        SUUUUUUU5        U(       a(  SSSS.S/U-   S/U-   /n[        R                  " XSSS9  g	[        R                  R                  U 5      (       a  [        R                  " U 5        g	g	)
aH  Generate the filters file.

This file is used by Visual Studio to organize the presentation of source
files into folders.

Arguments:
    filters_path: The path of the file to be created.
    source_files: The hierarchical structure of all the sources.
    extension_to_rule_name: A dictionary mapping file extensions to rules.
r   Projectz4.03http://schemas.microsoft.com/developer/msbuild/2003)ToolsVersionxmlns	ItemGroupTprettyr9   N)_AppendFiltersForMSBuildeasy_xmlWriteXmlIfChangedrG   r`   existsunlink)	filters_pathsource_filesrule_dependenciesextension_to_rule_namer  r  filter_groupsource_groupcontents	            r[   _GenerateMSBuildFiltersFiler3  ~  s    $ LL
	  %N ML(ML(
 	""7TR		%	%
		, 
&r]   c                    U H  n[        U[        R                  5      (       ay  U (       d  UR                  n	OU  SUR                   3n	UR	                  SSU	0S[
        R                  " UR                  5      //5        [        U	UR                  UUUUUU5        M  [        XX4U5      u  pUSU0/nU (       a  UR	                  SU /5        UR	                  U5        M     g)a  Creates the list of filters and sources to be added in the filter file.

Args:
    parent_filter_name: The name of the filter under which the sources are
        found.
    sources: The hierarchy of filters and sources to process.
    extension_to_rule_name: A dictionary mapping file extensions to rules.
    filter_group: The list to which filter entries will be appended.
    source_group: The list to which source entries will be appended.
rg   r   IncludeUniqueIdentifierN)
r   r   r   r-  r   r  r  r'  r~   _MapFileToMsBuildSourceType)parent_filter_namer   r.  r/  r  r  r0  r1  rc   filter_namer   elementsource_entrys                r[   r'  r'    s    ( fk0011%$kk!3 4Bv{{mD,')9)9&++)FG %!&	 5+AgJA $i%89L!##X/A$BC-G r]   c                 D   [         R                  R                  U 5      u  pVUR                  5       nXb;   a	  SnX&   nXx4$ US;   a  SnSnXx4$ US;   a  SnSnXx4$ US:X  a  S	nS
nXx4$ US;   a  SnSnSU;   a  US:X  a  SnXx4$ US:X  a  SnSnXx4$ X;   a  SnSnXx4$ SnSnXx4$ )a  Returns the group and element type of the source file.

Arguments:
    source: The source file name.
    extension_to_rule_name: A dictionary mapping file extensions to rules.

Returns:
    A pair of (group this file should be part of, the label of element)
r   )rx  ry  rv  rz  z.mmrP   	ClCompile)z.hz.hxxinclude	ClIncludez.rcresourceResourceCompile)z.sz.asmmasmMASMr  r  MARMASMre  midlMidlrule_dependencyCustomBuildr  None)rG   r`   r  lower)	rc   r.  r/  r  r  r   extrS   r:  s	            r[   r7  r7    s#    WWf%FA
))+C
$(-0 / 
4	4* ) 
	$ # 
#  
	iGx$7G  
  
	$!  r]   c
           	         UR                  S/ 5      n
U
 Vs/ s H'  n[        UR                  SS5      5      (       a  M%  UPM)     nnU
 Vs/ s H'  n[        UR                  SS5      5      (       d  M%  UPM)     nn/ nU H  nSU;  a  UR                  S/ 5      (       d  M"  [        X5      nUR                  U5        UR	                  UR
                  R                  S5      5        UR                  U	UR                  '   M     U(       a  US   UR                  -   nUS-   nUS	-   nUS
-   nUR                  U5        UR                  U5        [        R                  R                  U U5      n[        R                  R                  U U5      n[        R                  R                  U U5      n[        UU5        [        UU5        [!        UU5        U(       a  [#        XX#X5        [%        XUS5        g s  snf s  snf )Nr7  r  r   r   r  r  r(  z.propsz.targetsz.xmlT)rI   r   MSBuildRuler   r  r/  r  r)  r*  r1  r!  rG   r`   rm   _GenerateMSBuildRulePropsFile_GenerateMSBuildRuleTargetsFile_GenerateMSBuildRuleXmlFilerX  r  )r8  r9  r   r   r  props_files_of_rulestargets_files_of_rulesrL  r.  r/  r7  r<  r  r  msbuild_rulesr   msbuild_rulebase
props_nametargets_namexml_name
props_pathtargets_pathxml_paths                           r[   _GenerateRulesForMSBuildr\  	  s     HHWb!E$Pu!C6JA0N,OAuLP!&NA#aee4H!.L*MaNNM4(D(D"4.\*  !E!E!K!KC!PQ9E9O9O|556  M"W^^3H_
j(&=  ,""<0WW\\*j9
ww||J=77<<
H5%j-@'mD#Hm<w	
 5+;TBC QNs   $G4G4$G93G9c                       \ rS rSrSrS rSrg)rM  iF	  a  Used to store information used to generate an MSBuild rule.

Attributes:
  rule_name: The rule name, sanitized to use in XML.
  target_name: The name of the target.
  after_targets: The name of the AfterTargets element.
  before_targets: The name of the BeforeTargets element.
  depends_on: The name of the DependsOn element.
  compute_output: The name of the ComputeOutput element.
  dirs_to_make: The name of the DirsToMake element.
  inputs: The name of the _inputs element.
  tlog: The name of the _tlog element.
  extension: The extension this rule applies to.
  description: The message displayed when this rule is invoked.
  additional_dependencies: A string listing additional dependencies.
  outputs: The outputs of this rule.
  command: The command used to run the rule.
c                 D   US   U l         [        R                  " SSU R                   5      U l        SU R                  -   U l        U R                  S-   U l        U R                  S-   U l        U R                  S-   U l        SU R                  -  U l        U R                  S-   U l	        U R                  S	-   U l
        U R                  S
-   U l        US   U l        U R                  R                  S5      (       d  SU R                  -   U l        [        R                  " UR!                  SU R                  5      5      U l        [%        UR!                  S/ 5      5      nSR'                  U Vs/ s H  n[        R                  " U5      PM     sn5      U l        [%        UR!                  S/ 5      5      nSR'                  U Vs/ s H  n[        R                  " U5      PM     sn5      U l        [-        X!SSS9n[        R                  " U5      U l        g s  snf s  snf )Nr)  z\Wr   AfterTargetsBeforeTargets	DependsOnzCompute%sOutput
DirsToMake_inputs_tlogr*  r   r,  r   r  r   Tr+  )display_namerO   rf  r)  r(  after_targetsbefore_targets
depends_oncompute_outputdirs_to_maker   tlogr*  rs   r   ConvertVCMacrosToMSBuildrI   r   rx   rm   r/  r   r   r   )selfr   r   old_additional_dependenciesrw   old_outputsold_commands          r[   __init__MSBuildRule.__init__Z	  s    -sD,=,=> /!^^n<"nn>..;6/$..@ NN\9nny0NNW,	k*~~((-- 4>>1DN'@@HHY/
 '020F&G#'*xx 54A 55a84(
$  B 78xx?JK{!\2215{K
 /t$
 $<<[I Ls   / H H)r/  rf  rg  r   ri  rh  r   rj  re  r*  r   r   r)  r(  rk  N)__name__
__module____qualname____firstlineno____doc__rq  __static_attributes__r  r]   r[   rM  rM  F	  s    &$Jr]   rM  c                    SSS0/nU H  nUR                  SSSUR                  < SUR                  < S30UR                  S	/UR                  S
//SUR                  SS0SUR                  -  //SUR                  SUR
                  /SUR                  /SUR                  /SUR                  ////5        M     [        R                  " X SSS9  g)zGenerate the .props file.r   r#  r!  PropertyGroup	Conditionz'$(z)' == '' and '$(z1)' == '' and '$(ConfigurationType)' != 'Makefile'rF  rH  z$'$(ConfigurationType)' != 'Makefile'z_SelectedFiles;$(%s)ItemDefinitionGroupCommandLineTemplater  ExecutionDescriptionr  Tr%  N)r  rg  rf  rh  r)  r   r   r   r/  r(  r)  )rY  rS  r2  r   s       r[   rN  rN  	  s    		GHG  $#..0B0B&D
 ((&1''7	 $$&LM.@ *.="DLL1/1A1AB143O3OP	'	
 B w4tLr]   c                    SSS0/nSSSS0//nU H/  nUR                  SSUR                  0S	UR                  //5        M1     UR                  U5        U H'  nUR                  S
UR                  SSS.SS//5        M)     U GH-  nUR                  nSU-  nSU< SU< S3nSU-  nSn	SSS0USU-  SS.//n
SUR                  SSU-  0//nSUR                  SU-  SU< SU< S3S.SS U-  /S!S"UR                  -  ///nS#S$S%U-  S&./nS'S(UR                  < S)UR                  < S3S*S+UR                  < S,UR                  < S-3S../nS'S(UR                  < S)UR                  < S3S/S+UR                   S0UR                   S13S../nUS(U< S)U< S3S2S$S$S3U-  S4U-  US5./nUR                  S6UR                  S7UR                  -  S7UR                  -  S8U-  S9UR                  < S:UR                  < 3UUS;.U
UUUUUU/	S<S=S>S?UR                  -  /S@SAS?UR                  -  //S6UR                  S8U-  SB.SUR                  S(U< S)U< S3SU-  SC./SDSUR                  -  U	S./SESUR                  -  U	S./SFSUR                  -  U	S.//SGSHSIUR                  -  0///5        GM0     [        R                  " X SJSJSK9  gL)MzGenerate the .targets file.r   r#  r!  r$  PropertyPageSchemar5  z5$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xmlAvailableItemNameTargets	UsingTaskXamlTaskFactoryzMicrosoft.Build.Tasks.v4.0)TaskNameTaskFactoryAssemblyNameTaskz%%(%s.Outputs)z%(z.Identity);%(z..AdditionalDependencies);$(MSBuildProjectFile)z%%(%s.Identity)zd'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'r{  z'@(SelectedFiles)' != ''z@(%s)z#'%(Identity)' != '@(SelectedFiles)')Remover{  z%%(%s.AdditionalDependencies)z'%(z.Outputs)' != '' and '%(z.ExcludedFromBuild)' != 'true')r5  r{  Sourcez
@(%s, '|')Inputsz@(%s -> '%%(Fullpath)', ';')MessageHighz%%(%s.ExecutionDescription))
ImportanceTextWriteLinesToFilez'@(z)' != '' and '%(z$$(IntDir)$(ProjectName).write.1.tlogz^%(z.Source);@(z->'%(Fullpath)'))r{  FileLinesz#$(IntDir)$(ProjectName).read.1.tlogz.Source);%(z.Inputs)r  z%%(%s.CommandLineTemplate)z%%(%s.AdditionalOptions))r{  EchoOffStandardOutputImportanceStandardErrorImportancer}  r7  r  Targetz$(%s)z'@(%s)' != ''$(z);)Namer`  r_  r{  DependsOnTargetsr  r  rz  ComputeLinkInputsTargetsz$(ComputeLinkInputsTargets);z%s;ComputeLibInputsTargetsz$(ComputeLibInputsTargets);)r  r{  )r{  r5  r  r  ImpLibMakeDirr   z!@(%s->'%%(RootDir)%%(Directory)')Tr%  N)r   r)  r(  r   rk  r  rg  rf  rh  ri  rj  r(  r)  )rZ  rS  r2  
item_groupr   r)  target_outputstarget_inputsrule_inputsextension_conditionremove_sectioninputs_sectionlogging_sectionmessage_sectionwrite_tlog_sectionread_tlog_sectioncommand_and_input_sections                    r[   rO  rO  	  s     		GHG
 	 OP	
J #DNN+D,,-	
  NN: $#4$@
 PQ
	
  NN	)I5 	# ()3% 	 45%	1!F

 [[9&E	&QRS

 		/); CLYX <)349DKKGH
  !+H9+TU

  !IItyy2>99dii)		
  !IItyy2=tyykTYYKxH	
  &y2!,2+1'Ci'O%?)%K%	%
! 	  $ 0 0)043F3F)F(/$2D2D(D%4y%@??D,?,?-A#1"/	 #"##&%-%* $26 3 33 25 3 33  $ 3 3%4y%@
 $ -- $-i.9 ,<i+G	 #+<t?P?P+P-@ "+<t?P?P+P-@ %+<t?P?P+P-@3 D ") CdFWFW WO/ERT	
_ H wTNr]   c                 &   SSSSSS./nU GHk  nUR                  SUR                  SUR                  S	S
.SSSUR                  S.//SSSS0SSS///SSSS.SSS////SSSSSS.SSSUR                  SS.///S S!SS"S"S#./S$UR                  SS%S"S&.S'SS(//S)SS*//S+S,S-S.UR                  -  S/.//S0SSSS1.///S$UR                  SS%S"S&.S'SS2//S)SS3//S+S,S-S.UR                  -  S/.//S0SSS4SS5.///SS6S6S"S"S#./S S7S8S"S"S#./SS9S:S"S;S<./S S=S=SS>.S?SS@//SASS@////SBUR                  UR                  SC./SDSEUR
                  -   UR                  SF./SGUR                  S4UR                  SH.//5        GMn     [        R                  " X SISISJ9  g )KNProjectSchemaDefinitionszTclr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Frameworkz,http://schemas.microsoft.com/winfx/2006/xamlz&clr-namespace:System;assembly=mscorlibz+Microsoft.Cpp.Dev10.ConvertPropertyCallback)r#  zxmlns:xz	xmlns:syszxmlns:transformCallbackRuler   200)r  PageTemplateDisplayNameOrderzRule.DataSource
DataSourceProjectFile)PersistenceItemTypezRule.CategoriesCategoryr  GeneralzCategory.DisplayNamez
sys:StringzCommand Liner  )r  SubtypeStringListPropertyr  r  r   )r  r  
IsRequiredSwitchzStringListProperty.DataSourceItem)r  r  
SourceTypeStringPropertyr}  False)r  r  VisibleIncludeInCommandLineDynamicEnumPropertyr  )r  r  EnumProviderr  zDynamicEnumProperty.DisplayNamezExecute BeforezDynamicEnumProperty.Descriptionz@Specifies the targets for the build customization to run before.z$DynamicEnumProperty.ProviderSettingsNameValuePairExcludez^%s|^Compute)r  ValuezDynamicEnumProperty.DataSource)r  HasConfigurationConditionzExecute Afterz?Specifies the targets for the build customization to run after.r   )r  r  r  r  r~  zExecution Descriptionr  zAdditional Dependenciesfalse)r  r  r  r  r7  )r  r  r  zStringProperty.DisplayNamezAdditional OptionszStringProperty.Descriptionr  )r  r  FileExtensionr  )r  ContentTyper  )r  r  r  Tr%  )r  r)  re  rg  rf  r*  r(  r)  )r[  rS  r2  r   s       r[   rP  rP  u
  sP    	#5 FA'T	
G   $(.'+'8'8!&	 *(,9t~~V *&#Y/3lI5NO '%3N3lN5ST -$,(6*0&)	 < ,3@0428!"
* )$9+9'.4;	 .$($7$7(1,54;	 >)+;<
 > ,!2 C /,5-;d>Q>Q-Q!"	 = ,3@AG!"	=(T .$($6$6(1,54;	 >)?;
 > ,%5	 C /,5-;d>P>P-P!"	 = ,3@02AG!"
A+Z -$-+4'.4;	 )$:+B'.4;	 -$<+D4;'.	 )':$7(6 9)+?@
 9)+?@Syv !^^D<M<MN
 $ 4>>1$..Q
 " $')$(NNGKM	
 ^ wTJr]   c                 x    U R                  SS5      S   nUR                  SS5      nUS   S:X  a  US:X  a  S	nX44$ )
Nr   rB   r   r   r   r  r  r  r  )rsplitrI   )r-  r  r   r  rD   s        r[   _GetConfigurationAndPlatformr  U  sI    KKQ'*M||97CHI& X%8$$r]   c                      S[        XU5      -  $ )Nz''$(Configuration)|$(Platform)'=='%s|%s')r  )r-  r  r   s      r[   _GetConfigurationConditionr  ]  s    58T9  r]   c                     SSS0/n[        U R                  5       5       H5  u  p4[        X4U5      u  pVU SU 3nUR                  SSU0SU/SU//5        M7     U/$ )	Nr$  LabelProjectConfigurationsr   ProjectConfigurationr5  ConfigurationPlatform)r   r
  r  r   )r  r   rS   r-  r  r  rD   designations           r[    _GetMSBuildProjectConfigurationsr  c  s    7$;<=E">#7#7#9:">tt"T&q
3&K( -0X&		
 ; 7Nr]   c                    [         R                  R                  U5      S   nSSS0SU/SS/SU/S	S
///n[         R                  R	                  S5      S:X  d#  [         R                  R	                  S5      S:X  a  US   R                  SS/5        U R	                  S5      (       a{  U R	                  S5      nUS   R                  SU/5        U R	                  S5      (       a(  U R	                  S5      nUS   R                  SU/5        OUS   R                  SU/5        U R	                  S5      (       a  US   R                  SS/5        US   R                  SS
/5        U R	                  S5      (       a(  U R	                  S5      nUS   R                  SU/5        OUS   R                  SS/5        U R	                  S5      (       a  US   R                  SS/5        OUS   R                  SS/5        S n	S n
U S   R                  5        H=  nU	=(       d    [        U5      n	U
=(       d    [        X5      n
U	(       d  M4  U
(       d  M=    O   U
(       a   US   R                  S[        U
5      /5        O8UR                  (       a'  [        UR                  < S UR                  < S!35      eU	S":X  a  US   R                  S#S
/5        U$ )$Nr   rz  r  GlobalsProjectGuidKeyword	Win32ProjRootNamespace#IgnoreWarnCompileDuplicatedFilenamer  r  AMD64r  PreferredToolArchitecturer  r4   WindowsTargetPlatformVersionr5   WindowsTargetPlatformMinVersionr0   DefaultLanguagezen-USAppContainerApplicationr3   ApplicationTypeRevisionz8.1r2   ApplicationTypezWindows PhonezWindows Storer  z requires any SDK of z version, but none were foundARMWindowsSDKDesktopARMSupport)rG   r`   r  rH   rI   r   r  r   r   r   r   r   r   )r   r   r  gyp_file_name	namespace
propertiestarget_platform_versiontarget_platform_minversionapp_type_revisionr   r   r  s               r[   _GetMSBuildGlobalPropertiesr  s  s     /2I i D!$i(2F;	
	J 	

/0G;::>>23w>195ABxx.//"&((+I"J1<>UVW88566)-2S)T&qM  24NO qM  24KL xx#$$1/9:17@A88455 $)I JqM  ";=N!OPqM  ";U!CD88*++qM  "3_!EFqM  "3_!EFM#./668%G)G$ K2=J 	! =55 9  1+S1I-JK	
 
	 	 ""G$;$;=
 	

 1;VDEr]   c           	         0 nU S   R                  5        H  u  p4[        XU5      n[        X4U 5      nUR                  S5      nUR                  S5      nUR                  S5      n	[	        X&SU	5        UR                  S5      n
U
(       a  [	        X&SU
5        U	S:X  a#  [	        X&SS5        [	        X&S	[        U5      5        U(       a  S
U ;  a  [	        X&SU5        U(       d  M  S
U ;  d  M  [	        X&SU5        M     [        U SU5      $ )Nr  CharacterSetVCToolsVersionrC  SpectreMitigationDriver
DriverTypeWDMTargetVersionr0   r  )r
  _GetMSBuildAttributesr  rI   _AddConditionalPropertyr   _GetMSBuildPropertyGroup)r   r  r  r-  r  msbuild_attributes	conditioncharacter_setvctools_versionr  spectre_mitigations              r[   _GetMSBuildConfigurationDetailsr    s   J/066824:N.ttD	*..~>,001AB(,,-@A
7JKX/334GH#J;N$68("#J<O#8LX8V 0<#~} ?2$>#'7+ 90 $D/:FFr]   c                 ,    0 nU (       a
  SSS0SU ///nU$ )Nrz  r  LocalsPlatformToolsetr  )r  r  s     r[   _GetMSBuildLocalPropertiesr    s3    J  (#"O4

 r]   c                    Sn0 nSn[        U R                  5       5       H/  u  pV[        XVU5      nSU;   a  [        US   5      X7'   SnM+  SX7'   M1     U(       d  SSS0S	US
U-  SS.///$ / nUR                  5        HE  u  pSSU	S.S	US
U-  SS.//nU
 H  nUR	                  S	SU0/5        M     UR	                  U5        MG     U$ )Nz3$(UserRootDir)\Microsoft.Cpp.$(Platform).user.propsFmsbuild_propsTr   ImportGroupr  PropertySheetsImportzexists('%s')LocalAppDataPlatform)r   r{  r  )r  r{  r   )r   r
  r  rx   r   )r  r   
user_propsadditional_propsprops_specifiedr-  r  r  sheetsr  propsimport_group
props_files                r[   _GetMSBuildPropertySheetsr    s   GJO !5!5!78244Hh&.78Q.R+"O.0+ 9  *+#-%3j%@!7
 	
  0 6 6 8I*C#-%3j%@!7L $
##X	:/F$GH $MM,' !9  r]   c                 x   [        X5      n[        XU5      n0 nU H  nUS;   a9  [        R                  " XF   5      nUR	                  S5      (       d  US-  nXuU'   MB  US:X  a  [        XF   5      XV'   MY  US:X  a  [        XF   5      XV'   Mp  US:X  a  XF   XV'   M~  US:X  a  XF   XV'   M  [        SU-   5        M     U$ )N)rE  rD  rg   r  rC  r  r  z3Warning: Do not know how to convert MSVS attribute )r  r=  r   rl  r   _ConvertMSVSCharacterSet_ConvertMSVSConfigurationTyper   )r   r?   r  r  msvs_attributesr  rH  	directorys           r[   _ConvertMSVSBuildAttributesr    s    +D=K({CO<<$==o>PQI%%d++T!	$-q!. $<_=O$P!%%$A/BT$U!%%$3$6!""$3$6!G!KL   r]   c                 B    U R                  5       (       a	  SSSS.U    n U $ )N	MultiByteUnicode)r|  r  r  isdigit)char_sets    r[   r  r  ,  s'    $9;GQOr]   c                 F    U R                  5       (       a  SSSSSS.U    n U $ )NApplicationDynamicLibraryStaticLibraryr  Utility)r  r  r  r  r  r  )r  s    r[   r  r  2  s9    ! 
  r]   c                 B   SU;  a  [        XU5      nO[        X5      n[        U5      nUR                  S0 5      nUR	                  SU5        UR                  SS5      n[        U5      S-   US'   SU;  a  [        S5      S-   nXcS'   SU;   a  [        US   5      US'   S	U;  a,  U R                  S
S5      nU R                  SS5      nXx-   n	XS	'   SU;  a  SU ;   a  U R                  S5      n
SU
-   US'   U R                  S5      (       a#  U R                  SS5      n[        U5      S-   US'   SSSSSS.nUR                  U S   5      nU(       aL  US   nX   R                  S5      nU(       a  [        U5      US'   X   R                  S5      nU(       a  UUS'   U$ )N msbuild_configuration_attributesrC  rD  z$(SolutionDir)$(Configuration)rg   rE  r  r  
TargetNamer$  r   r%  r&  	TargetExtr#  r   r+   r,   r  r  r  r   finalized_msbuild_settingsr  
TargetPath)r  r  r  rI   
setdefaultrp   r  )r   r?   r  r  r  r8  rJ  r   r%  r(  rK  external_out_dirmsbuild_tool_mapr(  msbuild_settingsr  
target_exts                    r[   r  r  >  s   )78zR 0A3K@#ZZ(JBO%%&9;G'++?

 190Dt0K,-"*<<#$67$>L:F67//1I">22~. --*B/xx0@A++6<(,,1D1Lhh*+*-);'xx'((88$CSI089I0JT0Q,-
  !  $''V5L!">?#155lC/7/A|,%377D
.8{+r]   c                 ~   / nU R                  SS/5      S   nU(       a]  S[        U5      -  nUR                  U5        UR                  SS5      nUR                  U5        U(       a  SSR	                  U5      -   n0 n[        UR                  5       5       GH  u  p[        XU 5      n
[        X	U5      nU	S	   n[        XzS
US   5        [        XzSUS   5        [        XzSUS   5        SU;   a  [        XzSUS   5        UR                  S5      (       a  [        XzSUS   5        UR                  S5      (       a  [        XzSUS   5        U(       a  [        XzSU5        UR                  S0 5      n[        UR                  5       5       H  u  p[        SX5      n[        XzX5        M     GM     [        U S U5      $ )Nr&   r   r   z"$(MSBuildProjectDirectory)\%s\bin\z
cygwin\bin	python_26z$(ExecutablePath);r  r'  IntDirrE  OutDirrD  r%  r&  r(  ExecutablePathr   )rI   rp   r   rn   rm   r   r
  r  r  r  _GetValueFormattedForMSBuildr  )r   r  r  	new_pathscygwin_dirscyg_pathpython_pathr  r-  r  r  r?  r,  tool_settingsr   formatted_values                   r[   (_GetMSBuildConfigurationGlobalPropertiesr:  u  s    I((-u5a8K:Xk=RR" &&}kB%,sxx	/BBIJ!'(<(<(>!?.tDI	*4
K
()EF8Z8O-P	
 	 8Z8I-J	
 	 <L1I	
 *$#{J{4K >>,''#|Z5M >>+&&#{J{4K #J;KYW(,,R4!-"5"5"78KD:2tKO#J4Q 9= "@B $D$
;;r]   c                 Z    X ;  a  0 X'   X   nX4;  a  / XC'   XC   nUR                  U5        g)a  Adds a property / conditional value pair to a dictionary.

Arguments:
  properties: The dictionary to be modified.  The key is the name of the
      property.  The value is itself a dictionary; its key is the value and
      the value a list of condition for which this value is true.
  condition: The condition under which the named property has the value.
  name: The name of the property.
  value: The value of the property.
Nr   )r  r  r-  r   r  
conditionss         r[   r  r    s<     
FJi r]   z\$\(([a-zA-Z_][a-zA-Z0-9_]*)\)c                   ^ S/nU(       a  UR                  SU05        [        U S   5      nU4S jn[        R                  R	                  TR                  5       U5      n[        U5       Hl  nTU   n[        UR                  5       5       HG  u  p[        U
5      U:X  a  UR                  Xy/5        M(  U
 H  nUR                  USU0U	/5        M     MI     Mn     U/$ )ax  Returns a PropertyGroup definition for the specified properties.

Arguments:
  spec: The target project dict.
  label: An optional label for the PropertyGroup.
  properties: The dictionary to be converted.  The key is the name of the
      property.  The value is itself a dictionary; its key is the value and
      the value a list of condition for which this value is true.
rz  r  r  c                    > [        5       n[        TU    R                  5       5       HG  nUR                  [        R                  U5       Vs1 s H  nUT;   d  M  X0:w  d  M  UiM     sn5        MI     U$ s  snf r   )r  r   r  r  MSVS_VARIABLE_REFERENCEfindall)r  edgesr   vr  s       r[   GetEdges*_GetMSBuildPropertyGroup.<locals>.GetEdges  s|     Jt,1134E LL 5<<UCCJ +,9 C 5  s   
A5
A5
"A5
r{  )	r   r   rE  rF  TopologicallySortedr  r  r   r
  )r   labelr  rS   num_configurationsrC  properties_orderedr-  r  r   r<  r  s     `         r[   r  r    s     Egu%&T"234. 77
8I8T
 +,D!!'!7E:"44 d]+!+ILL$i(@%!HI ", "8 - 7Nr]   c                    / n[        UR                  5       5       H  u  p4US   nSS[        X4U 5      0/n[        UR                  5       5       Hk  u  pxU(       d  M  U(       d  M  U/n	[        UR                  5       5       H#  u  p:[        XsU
5      nU	R	                  X;/5        M%     UR	                  U	5        Mm     UR	                  U5        M     U$ )Nr'  r|  r{  )r   r
  r  r3  r   )r   r  groupsr-  r  r,  rS   r   r8  r   r   r9  s               r[   _GetMSBuildToolSettingsSectionsrK    s    F!'(<(<(>!?()EF!4T$OP
 )//?/E/E/G(H$I y]]!{#)-*=*=*?#@KD&B!'O KK 78	 $A
 T" )I 	e# "@$ Mr]   c           	         SU;   a  SnUS   n[         R                  " U5        O*SnUR                  S0 5      n[         R                  " U5      n[	        U5      u  pVn[        U 5      n[        U5      n	[        U SS9u  pn[        U 5      n[        U5      nU(       a[  U Vs/ s H  oS:w  d  M
  UPM     nnS/nU H9  nUR                  U5      nU(       d  M  [        SU< S	[        U5      < 35        M;     U Vs/ s H  n[        U5      PM     nn[        U5      nUR                  S
5      nUR                  S5      n[        U 5      nUR                  S5      n[        USSU5        [        USSU5        [        USSU5        [!        USSU5        [        USSU	5        U
(       a  [        X<SU
SS9  U(       a  [        X<SUSS9  [        USSU5        [        USSU5        [        USSU5        U(       aN  ["        R$                  R'                  U5      S   n[        USSS5        [        USSU5        [        USSU/5        O[        USSS5        [        USSS 5        U R                  S!5      (       a  [        US"S#S 5        U S$   S%:X  a  [        US"S#S&5        U(       a  [        USS'U5        X1S('   U(       a  [        US)S*U5        U(       a  [        US+S*U5        g g s  snf s  snf ),Nr,  FTr  r  z
_HAS_TR1=0rs  z=Warning: The automatic conversion to MSBuild does not handle z.  Ignoring setting of r  r  r6   r=  r  rF  rA  r  r  r  r  r  r&  r  r  rB   PrecompiledHeaderUsePrecompiledHeaderFiler  NotUsingr   r  r1   r   r  r   r  r  r  r'  PreBuildEventCommandPostBuildEvent)r   ValidateMSBuildSettingsrI   ConvertToMSBuildSettingsr  r  r  r  r.  r  r   r   r  r  r  r   r   rG   r`   r  )r   r  	convertedr,  r  r  r  r  r  r  r  r   r(  r-  r	  r
  ignored_settingsignored_settingr   r  r  r  r  r  s                           r[   _FinalizeMSBuildSettingsrY    s.   ]*	();<,,-=>	%))/2>'@@O=L>:L%: d#I"=1L 9$ MH$T*J-(G%;gl):1g;-./O!%%o6Eu5Dc%jR  0 7>>g)!,gG>,];  1H!!"23I#D)H&**+DE +'E| &"@BS &	 %v/GS &*H,WL(RV	
 KSW	
  +/H'R "35NPWX+'@BS WW]]+=>qA$k3FNk+BDV	
 	k+?BTAU	
 	$k3F
S +/?Ixx-..$b*?I F|(($b*?H$f.DhO2B./$oy(K$&6	9M a < ?s   !	K#.K#<K(c                 J   [        U5      [        :X  at  US;   a  UR                  SU-  5        S/S/S/S.nXR                  U / 5      ;   a  SOSnUR	                  U Vs/ s H  n[
        R                  " U5      PM     sn5      nU$ [
        R                  " U5      nU$ s  snf )N)r  r  r7  DelayLoadDLLsr  r  z%%(%s)r7  )r=  r  r  r   r  )r   r   r   rI   rm   r   rl  )r   r-  r   
exceptionscharrw   r9  s          r[   r3  r3  x  s    E{d  
 
 LLD) ..()'(


 nnY;;s))?DEu!\2215uE

  '??F	 Fs    B c                 d   / nU  H  n[        U[        R                  5      (       a'  UR                  [	        UR
                  U5      5        MI  SU;  d  MQ  [        R                  R                  X5      n[        R                  R                  U5      (       a  M  UR                  U5        M     U$ )a  Verifies that all source files exist on disk.

Checks that all regular source files, i.e. not created at run time,
exist on disk.  Missing files cause needless recompilation but no otherwise
visible errors.

Arguments:
  sources: A recursive list of Filter/file names.
  root_dir: The root directory for the relative path names.
Returns:
  A list of source files that cannot be found on disk.
r_   )r   r   r   r  r  r~   rG   r`   rm   r*  r   )r   root_dirr  rc   	full_paths        r[   r  r    s     Ofk0011""#6v#QR& GGLL:	ww~~i00#**95  r]   c           
          / SQn0 n	U H  n
/ X'   M	     [        U UUU	UUUU5        / nU H%  n
X   (       d  M  UR                  S/X   -   5        M'     U(       a  UR                  S/U-   5        U$ )N)r  rB  rE  r>  rP   r@  r   rG  r$  )_AddSources2r   )r   r   rm  r.  r/  actions_specsources_handled_by_actionr|   rJ  grouped_sourcesgs              r[   _GetMSBuildSourcesrg    s    	F O  !	 GNNK=?+==>  }|34Nr]   c                 X   / nU GH  n	[        U	[        R                  5      (       a  [        U U	R                  UUUUUU5        MA  X;  d  MH  / n
UR                  U	/ 5      n[        U5      [        U S   5      :X  a  U
R                  SS/5        O5[        U5       H&  u  p[        X5      nU
R                  SSU0S/5        M(     U S   R                  5        H  u  pUR                  SS5      nUS:w  aB  [        U5      nU(       d0  [        R                  R                  U5      u  nnUS:X  a  / SQnOS/nX:X  a$  [        XU 5      nU
R                  S	SU0S
/5        M  U HA  nU	R                  U5      (       d  M  U
R                  S	S/5        U
R                  SS/5        MC     M     [!        U	UU[#        U 5      U S   5      u  nnUS:X  a  [        R                  R%                  U	5      (       d  [        R                  R                  U	5      S   S-   nUR'                  S5      (       a  [(        R*                  " SSU5      nO.UR'                  S5      (       a  [(        R*                  " SSU5      nU
R                  SSU-   /5        UU   R                  USU	0/U
-   5        GM     g )Nr  rk  r  r{  r7   r   rv  rw  rM  Creater  r  rP   r   z.objz..\z
^(\.\.\\)+r  z^\$\([^)]+\)\\ObjectFileNamez
$(IntDir)\r5  )r   r   r   rb  r~   rI   r   r   r   r  r
  rp   rG   r`   r  r   r7  r  rk   rs   rO   rf  )r   r   rm  re  r.  r/  rd  r|   r  rc   detailexcluded_configurationsr   r  r  precompiled_sourcer~  r*  rS   r:  rn  s                        r[   rb  rb    s    +-'fk0011!&)	 6*4..*D'./3t<L7M3NNMM#6"?@6<=T6U2$>'%	 0;	2JFS	 7V 377G2H2N2N2P.K)6):):12*& *R/-56H-I*B 35''2B2BCU2V/Hi(D0G" C HLf C)3$>'%	 0;	2JHU *MI%y99 &/BB.G H &/CR.H I *M? 3QH "=%*'-O"w I%bggmmF.C.C !# 0 0 8 ;f DI ++F33$&FF="i$H	"--d33$&FF+<b)$L	MM#3]Y5N"OP&--wF8K.Lv.UVa r]   c                    / nU R                   (       Ga  S/n[        5       nU R                    GH  nUR                  nSnU R                  S   S:X  a  US   S:X  a  US   S:X  a  SnUR                  R	                  S	5      (       a  SnU(       a  Md  UR                  R                  S
S5      nUR                  U5        UR                  n[        R                  R                  U R                  5      S   n	[        R                  R                  UR                  U	5      n
SSU
0SU/SS//nUR                  R                  S0 5      R                  5        H[  nUR                  SS5      (       a  UR!                  SS/5          O0UR                  SS5      (       d  MH  UR!                  SS/5          O   UR!                  U5        GM     UR!                  U5        U$ )Nr$  Fr  r  r  r   r  Trun_r  r   r   ProjectReferencer5  r   ReferenceOutputAssemblyr  r  "msvs_use_library_dependency_inputsUseLibraryDependencyInputsr  &msvs_2010_disable_uldi_when_referenced)r  r  r   r-  rs   rn   r!  r  rG   r`   r  rE  rF  r  rI   r  r   )r  
referencesrS   added_dependency_set
dependencydependency_specshould_skip_depcanonical_namer  r  relative_pathproject_refr?   s                r[   _GetMSBuildProjectReferencesr}  7  s   J"u!..J(ooO#O||I&(2"9-7&v.2BB*.))&11"''__44WbAN $$^4??D''--5a8KJJ33JOO[QM"M*D!*G4	K %//--.>CJJL::BAFF&&(Df'MN::FJJ&&(Dg'NO M LL%? /@ 	% r]   c                 Z   U R                   nUS   nUS   n[        R                  R                  U R                  5      u  px[        R
                  R                  U R                  5        [        R                  R                  U R                  5      S   n	[        XCU	5      u  p0 n[        5       n[        5       n[        5       n0 nUR                  SS5      n[        U5      nUR                  S5      (       d  [        UUUU
UUUUUU5
        OUR                  S/ 5      n[        UXS5        [        XAXzUUU5      u  pnUR                  S5      (       d,  [        XU R                  5        [!        X5        [#        X5      n[%        XKU5      n['        XL5      u  nn[)        U R                  S-   U
UUUU5        [+        X5      nUR-                  5        H  n[/        UU5        M     S	S
S0//nS	S
S0//nS	S
S0//nS	S
S0//nS	S
S0//nS	S
S0//nS	S
S0//n SSS0//n!S
SUR1                  5       SS./n"U"[3        XT5      -  n"U"[5        XBU R6                  U5      -  n"U"U-  n"U"[9        X@R                  5      -  n"UR                  S5      (       a  U"[;        S5      -  n"OU"[;        U R<                  5      -  n"U"U-  n"U"U-  n"SU;   a  US:X  a  U"U-  n"U"[?        U5      -  n"U"[A        XT5      -  n"U"U!-  n"U"[C        XEU R                  5      -  n"U"[E        XE5      -  n"U"[G        UU
UUUUUU5      -  n"U"[I        U 5      -  n"U"U-  n"U"U-  n"SU;   a  US:X  a  U"U -  n"U"[K        U5      -  n"UR                  S5      (       a  U"[M        U5      -  n"[N        RP                  " U"U R                  SSS9  U$ )Nr  r  rB   r  Tr+   r7  z.filtersr  r   z,$(VCTargetsPath)\Microsoft.Cpp.Default.propsz$$(VCTargetsPath)\Microsoft.Cpp.propsz&$(VCTargetsPath)\Microsoft.Cpp.targetsz/$(VCTargetsPath)\BuildCustomizations\masm.propsz1$(VCTargetsPath)\BuildCustomizations\masm.targetsz2$(VCTargetsPath)\BuildCustomizations\marmasm.propsz4$(VCTargetsPath)\BuildCustomizations\marmasm.targetsrz  r  
UserMacrosr!  Build)r#  r"  DefaultTargetsr2   	v120_wp81r  r  r%  ))r   rG   r`   r  rE  rF  r  r  r  r  rI   r  r\  r  r  r  r  r  rl  _GenerateActionsForMSBuildr3  r  r  rY  ProjectVersionr  r  r  r  r  r  _GetMSBuildExtensionsr  r:  rK  rg  r}  _GetMSBuildExtensionTargets!_GetMSBuildExternalBuilderTargetsr(  r)  )#r  r9  r   r  r   r  r  r  project_file_namer  r   r  rL  rQ  rR  r.  r/  r|   r  r7  r  rm  rc  rd  r  r  import_default_sectionimport_cpp_props_sectionimport_cpp_targets_sectionimport_masm_props_sectionimport_masm_targets_sectionimport_marmasm_props_sectionimport_marmasm_targets_sectionmacro_sectionr2  s#                                      r[   r  r  `  s   <<D*+N9oG%'WW]]7<<%@"KJJw||, ww}}W//03H 5dX VGN5 U#''(BDIM#D)I 88+,,  ""	
 "%ugF.W{-=}g/+G|
 88+,,N'*<*<=>( 66FW+DLQJ.H/+L+  z! *'?O'..0 }5 1 
INOP 
IFGH  
IHIJ" 
IQRS! 
ISTU# 
ITUV$  
IVWX&" &'>?@M 	J#224%	
G /EEG*w||%6 G %%G.t5G5GHHGxx&''-k::-g.E.EFF''G((G)8 3//$%9::G(>>G}G7g00 G .tDDG!!	 	G +G44G))G**G)8 311*+ABBGxx'((4T::
 wTNr]   c                 j   [        X S   SSSS5      nSSS0/nUR                  SSU0/5        [        X S   SSSS5      nSSS	0/nUR                  SSU0/5        X$/nU R                  S
5      (       a?  [        U U S
   SSSS5      nSSS0/nUR                  SSU0/5        UR                  U5        U$ )a^  Return a list of MSBuild targets for external builders.

The "Build" and "Clean" targets are always generated.  If the spec contains
'msvs_external_builder_clcompile_cmd', then the "ClCompile" target will also
be generated, to support building selected C/C++ files.

Arguments:
  spec: The gyp target spec.
Returns:
  List of MSBuild 'Target' specs.
r-   Fr  r  r  ExecrR  r.   Cleanr/   r=  )r   r   rI   )r   	build_cmdbuild_target	clean_cmdclean_targettargetsclcompile_cmdclcompile_targets           r[   r  r    s    ,45ueUEI vw/0L)Y!789+45ueUEI vw/0L)Y!789*Gxx566367
 %v{&;<)])C DE'(Nr]   c                 P    SSS0/nU  H  nUR                  SSU0/5        M     U/$ )Nr  r  ExtensionSettingsr  r   r   )rQ  r.  r  s      r[   r  r  !  s<    '+>!?@J*
8i%<=> +<r]   c                 b    SSS0/n[        U 5       H  nUR                  SSU0/5        M     U/$ )Nr  r  ExtensionTargetsr  r   )r   r   )rR  targets_nodetargets_files      r[   r  r  (  sB    !G-?#@AL56X	<'@AB 7>r]   c                    [        5       n/ nUR                  5        GHT  u  pE[        (       a  UR                  SS5      n[        5       n[        5       n/ n/ n	U H  n
S n[        (       a  U
S    Vs/ s H
  o" U5      PM     snU
S'   UR	                  [        U
S   5      5        UR	                  [        U
S   5      5        UR                  U
S   5        U
S   n[        (       a  UR                  SS5      nU
R                  SS	5      (       a  S
U-   nU	R                  U5        M     SR                  U5      nSR                  U	 Vs/ s H  oS-   PM	     sn5      n[        U UUUUUUU5        GMW     X24$ s  snf s  snf )aK  Add actions accumulated into an actions_to_add, merging as needed.

Arguments:
  spec: the target project dict
  actions_to_add: dictionary keyed on input name, which maps to a list of
      dicts describing the actions attached to that input file.

Returns:
  A pair of (action specification, the sources handled by this action).
r   	_host.exec                 6    SU ;   a  U R                  SS5      n U $ )Nr   r   r  r@  )rw   s    r[   fixup_host_exe2_GenerateActionsForMSBuild.<locals>.fixup_host_exeE  s    !#		&+6Ar]   r   r   r   r   msbuild_use_callTzcall r  r  z,
if %errorlevel% neq 0 exit /b %errorlevel%)	r   r
  r  rn   r  r   rI   rm   _AddMSBuildAction)r   rL  rd  rc  r  rT  r   r   r  r  r   r  rw   r   r   rW  r   s                    r[   r  r  /  s    !+L"0"6"6"8//)11&+FM,F
 43?Eh?O#P?O!N1$5?O#Px MM*VH%567NN:fY&789} 56#C33kk&+6
 zz,d33mOOC + . $((6 ++KST8aAA8T
 	%		
O #9b 22E $Q, Us   2E9
E>
c                    [         R                  " U5      n[        U5      n[        U5      n	[        U5      n
SR	                  U	 Vs/ s H  oU:w  d  M
  UPM     sn5      nSR	                  U
5      nUR                  U5        SSU0/nUR                  SS/SU/SU/SU//5        U(       a  UR                  S	U/5        UR                  U5        g s  snf )
Nr  rH  r5  FileTypeDocumentrR  r  r  AdditionalInputs)r   rl  rp   rx   rm   r!  r  r   )r   r  r   r   r   r   rd  rc  r   inputs_arrayoutputs_arrayrw   additional_inputsaction_specs                 r[   r  r  p  s     33C8G]+MV$Lg&M\!P\-=O!\!PQhh}%G!!-0 9m"<=K $ $ 		
 .0ABC$ "Qs   	CC)rg   )NNTN)F)r'  rG   r  rO   rJ   rC   collectionsr   
gyp.commonrE  gyp.easy_xmlr(  gyp.generator.ninja	generatorr  r  gyp.MSVSNewr  gyp.MSVSProjectr   gyp.MSVSSettingsr   gyp.MSVSToolFiler2  gyp.MSVSUserFiler  gyp.MSVSUtilr  gyp.MSVSVersionr   r   r   rP   r  rF  CrossCompileRequestedr  r  "generator_additional_path_sections+generator_additional_non_configuration_keysr	  rh  rF   rE   r\   rj   re   rp   rl   rx   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r&  r>  rA  rX  r\  re  rh  rm  rp  ru  rz  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r.  r  r  r  r:  r  r=  rQ  r  r  r]  r^  r  rl  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r3  r'  r7  r\  rM  rN  rO  rP  r  r  r  r  r  r  r  r  r  r  r  r:  r  r?  r  rK  rY  r3  r  rg  rb  r}  r  r  r  r  r  r  r  r]   r[   <module>r     s`    	  	  
 #   - -  % ' ' '  %  ! 

#34 '*zz'G'G'I $RV  	
      B 	% ; ~ ~ -  m!" )#$ &0' 2 & "/ +$      ,4 $4:3 KOGTF6>CL
$NOBd  .F
@
B*	(*$"NRj$ zz), 8 JJ7 .b 

9- D<(,
?A4(P.;| "DWNtB0!4$+N$ F&6Y$6D$'N93x	 *-&`
6,	
$N	,
+*!*%"0f0fF>)&
$Y@x+ \7.t(V2Cj8J 8Jv'MTGOT]K@% DNG:-`.	4n2<j!* **%FG 5p.dNN:2(V[W|&RTn'T>3B%r]   