HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //usr/lib/python3.6/site-packages/gyp/generator/__pycache__/msvs.cpython-36.opt-1.pyc
3

?9�^��@s<ddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddl
jZddljjZddljZddljZddljZddljZddljZddljZddlj Z ddlm!Z!ddlm"Z"ej#d�Z$dddd	ddd
ddd
dddddddddd�Z%ddgZ&dddddddd d!d"d#d$d%d&d'gZ'da(d(d)gZ)da*da+d*d+�Z,da-d,d-�Z.d.d/�Z/d0d1�Z0�dd3d4�Z1�dd6d7�Z2�dd8d9�Z3d:d;�Z4d<d=�Z5d>d?�Z6d@dA�Z7dBdC�Z8dDdE�Z9dFdG�Z:dHdI�Z;dJdK�Z<dLdM�Z=dNdO�Z>dPdQ�Z?dRdS�Z@dTdU�ZAdVdW�ZBdXdY�ZCdZd[�ZDej#d\�ZEd]d^�ZFej#d_�ZGd`da�ZHdbdc�ZIej#dd�ZJdedf�ZKdgdh�ZLdidj�ZMdkdl�ZNdmdn�ZOdodp�ZPdqdr�ZQdsdt�ZRdudv�ZSdwdx�ZTdydz�ZUd{d|�ZVd}d~�ZWdd��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d„Zyd�dĄZzd�dƄZ{d�dȄZ|d�dʄZ}d�d̄Z~d�d΄Zd�dЄZ�d�d҄Z�d�dԄZ�Gd�dքd�e��Z�d�d؄Z�d�dڄZ�d�d܄Z�d�dބZ�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�ej#d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d	�Z��d
�d�Z��d�d
�Z��d�d�Z��d�d�Z��d�d�Z�dS(�)�print_function)�OrderedDictN)�GypError)�
OrderedSetz
^[A-F0-9\-]+$�z.sysz.exez.libz.dllz	$(IntDir)z $(OutDir)obj/global_intermediate�winz	$(OutDir)z$(OutDir)libz$(InputName)z$(InputDir)z$(InputExt)z$(InputFileName)z$(InputPath)z$(ConfigurationName))Z
DRIVER_PREFIXZ
DRIVER_SUFFIXZEXECUTABLE_PREFIXZEXECUTABLE_SUFFIXZSTATIC_LIB_PREFIXZSHARED_LIB_PREFIXZSTATIC_LIB_SUFFIXZSHARED_LIB_SUFFIXZINTERMEDIATE_DIR�SHARED_INTERMEDIATE_DIRZOSZPRODUCT_DIRZLIB_DIRZRULE_INPUT_ROOTZRULE_INPUT_DIRNAMEZRULE_INPUT_EXTZRULE_INPUT_NAMEZRULE_INPUT_PATHZCONFIGURATION_NAME�msvs_cygwin_dirs�
msvs_props�msvs_cygwin_shellZmsvs_large_pdbZ
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_sourcecCs�tjdkrdStstr�tjjd�}tjjd�}|s>|r�tjdddgtj	d	�}|j
�d
}tjdtj
�}|j|�}|r�|jd�}tjd
tj
�}|j|�}|r�|jd�}|a|attfS)N�win32�cygwin�DOMAIN�USERNAMEZ
USERDOMAINZnet�configZWorkstation)�stdoutrz^User name\s+(\S+)�z^Logon domain\s+(\S+))rr)rr)�sys�platform�
cached_domain�cached_username�os�environ�get�
subprocess�Popen�PIPEZcommunicate�re�compile�	MULTILINE�search�group)�domain�username�callrZusername_reZusername_matchZ	domain_reZdomain_match�r2�/usr/lib/python3.6/msvs.py�_GetDomainAndUserNamels(





r4cCs(tjj|�}|jd�|jd�kr$|}|S)z�Normalize 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.
  �$)r$�path�normpath�count)�sourceZ
normalizedr2r2r3�_NormalizedSource�sr:cCsftr2|r2tjj|�r2|ddkr2tjjt|�}|jdd�}t|�}|rb|ddkrb|dd�}|S)	z�Convert 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.
  rr5�/�\rN���r=)�fixpath_prefixr$r6�isabs�join�replacer:)r6r2r2r3�_FixPath�s$rBcCsdd�|D�S)z"Fix each of the paths of the list.cSsg|]}t|��qSr2)rB)�.0�ir2r2r3�
<listcomp>�sz_FixPaths.<locals>.<listcomp>r2)�pathsr2r2r3�	_FixPaths�srGTc
Csf|sg}g}g}t�}x�|D]�}t|�dkr^tdj||��}	|	|krR|j|	�q�|j|	�q|r�|j�r�|j|d�s�g||d<||dj|dd��qt|dd�g||dg|||d�}
tj	|d|
d�}
|j|
�qW|o�|�r
tj	d|d�}|j|�|�r|j��r|SxB|D]:}t||||g|||d�}
tj	||
d�}
|j|
��q$W|S)	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'])]
  rr<rN)�excluded�
list_excluded�msvs_version)�contentsZ_excluded_files)�prefixrHrIrJ)
r�lenr:r@�append�UsesVcxprojr&� _ConvertSourcesToFilterHierarchy�MSVSProject�Filter)
�sourcesrLrHrIrJ�resultZexcluded_resultZfolders�s�filenamerKZexcluded_folder�fr2r2r3rP�sF



rPFcCs|sdSt|||||�dS)N)�_ToolSetOrAppend)�tools�	tool_name�setting�value�
only_if_unsetr2r2r3�_ToolAppend�sr^cCs�d|ksd|kr8t|�tkr*|jdd�}ndd�|D�}|j|�sLt�||<||}d|kr`dS|j|�r�|rrdSt||�tkr�t|�tkr�|||7<q�td|||t||�f��n|||<dS)	N�DirectoriesZDependenciesr;r<cSsg|]}|jdd��qS)r;r<)rA)rCrDr2r2r3rE�sz$_ToolSetOrAppend.<locals>.<listcomp>�CompileAsWinRTzZAppending "%s" to a non-list setting "%s" for tool "%s" is not allowed, previous value: %s)�type�strrAr&�dict�list�	TypeError)rYrZr[r\r]�toolr2r2r3rX�s$


rXcCs|jdd�S)NZmsvs_target_versionZWindows7)r&)�config_datar2r2r3�_ConfigTargetVersionsrhcCs|jdd�S)N�msvs_configuration_platform�Win32)r&)rgr2r2r3�_ConfigPlatformsrkcCs,|jd|�r$|dt|�d�S|SdS)N�_rr)�endswithrM)�config_name�
platform_namer2r2r3�_ConfigBaseNamesrpcCst|�}dt||�|fS)Nz%s|%s)rkrp)rnrgror2r2r3�_ConfigFullNamesrqc	s�|jd�}|r|gn�j}x�|D]�}x�dD]~}tj||d�}|sDq*tj||d�pVd�d|}t�fdd	�tjj|�r�tj|�ngD�d
d�}|r�|dSt	d
��q*Wq WdS)N�msvs_windows_sdk_version�1HKLM\Software\Microsoft\Microsoft SDKs\Windows\%s�=HKLM\Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows\%sZInstallationFolderZProductVersionrz
%s\includecsg|]}|j��r|�qSr2)�
startswith)rC�x)�versionr2r3rE/sz7_ConfigWindowsTargetPlatformVersion.<locals>.<listcomp>T)�reverserzCWarning: No include files found for detected Windows SDK version %s)rsrt)
r&�compatible_sdks�MSVSVersionZ_RegistryGetValue�sortedr$r6�isdir�listdir�print)	rgrwZ
config_verZversZver�keyZsdk_dirZexpected_sdk_dir�namesr2)rwr3�#_ConfigWindowsTargetPlatformVersion"s&

r�cCs�dd�|D�rd}nd}|�r t|jddg�d�}|}dd�|D�}d	d�|D�}d
d�|D�}|rtdd�|D�}dd�|D�}d
j|�}d}|r�|d7}|d7}|jd�dkr�|d7}|jd�dkr�|d7}|jd�dkr�|d7}|o�|jd�dk�r|d7}|d7}|||d�}||S|ddk�r6dg}	n|djdd�g}	|	jdd�dd�|d d�D�}
d!d�|
D�}
d"d�|
D�}
|�r�d#d�|
D�}
|d
j|	|
�SdS)$NcSsg|]}d|kr|�qS)z$(InputDir)r2)rCrvr2r2r3rE>sz/_BuildCommandLineForRuleRaw.<locals>.<listcomp>z_set INPUTDIR=$(InputDir)
if NOT DEFINED INPUTDIR set INPUTDIR=.\
set INPUTDIR=%INPUTDIR:~0,-1%
rr	�.rcSsg|]}|jdd��qS)z	$(IntDir)z`cygpath -m "${INTDIR}"`)rA)rCrDr2r2r3rELscSsg|]}|jdd��qS)z	$(OutDir)z`cygpath -m "${OUTDIR}"`)rA)rCrDr2r2r3rENscSsg|]}|jdd��qS)z$(InputDir)z`cygpath -m "${INPUTDIR}"`)rA)rCrDr2r2r3rEPscSsg|]}|jdd��qS)z$(InputPath)z`cygpath -m "${INPUTPATH}"`)rA)rCrDr2r2r3rESscSsg|]}d|jdd��qS)z\"%s\"�"z\\\")rA)rCrDr2r2r3rEVs� z4call "$(ProjectDir)%(cygwin_dir)s\setup_env.bat" && zset CYGWIN=nontsec&& ZNUMBER_OF_PROCESSORSz@set /a NUMBER_OF_PROCESSORS_PLUS_1=%%NUMBER_OF_PROCESSORS%%+1&& ZINTDIRzset INTDIR=$(IntDir)&& ZOUTDIRzset OUTDIR=$(OutDir)&& Z	INPUTPATHzset INPUTPATH=$(InputPath) && zbash -c "%(cmd)s")�
cygwin_dir�cmd�catrar;r<r1cSs(g|] }|dd�dkr|nt|��qS)Nrz/-)rB)rCrDr2r2r3rEzsrcSsg|]}|jdd��qS)z$(InputDir)z
%INPUTDIR%)rA)rCrDr2r2r3rE{scSsg|]}tj|��qSr2)�MSVSSettings�FixVCMacroSlashes)rCrDr2r2r3rE|scSsg|]}d|�qS)z"%s"r2)rCrDr2r2r3rE�s)rBr&r@�findrA�insert)�specr�Zcygwin_shell�has_input_path�	quote_cmd�do_setup_envZinput_dir_preambler�Z
direct_cmd�command�	argumentsr2r2r3�_BuildCommandLineForRuleRaw;sV

r�cCs^|jd�}|dkr$t|jdd��}nt|t�r6t|�}t|jdd��}t||d||||d�S)NrrZmsvs_quote_cmd�action)r�)r&�int�
isinstancerbr�)r��ruler�r�Zmcsr�r2r2r3�_BuildCommandLineForRule�s

r�cCs8||||d�}|d}||kr&g||<||j|�dS)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�rN)rN)�actions_dictr�r�r�r�r�Zchosen_inputr2r2r3�_AddActionStep�sr�c
Cslt|�}t|�}tjd|dj|�dj|�|d��}x4|dj�D]$\}}	|jt|�t||	�|gd�q@WdS)a8Add 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
  ZVCCustomBuildTool�;)ZDescription�AdditionalDependencies�Outputs�CommandLine�configurations)rYN)rGrQ�Toolr@�items�
AddFileConfigrBrq)
�pr��
primary_inputr�r�r�r�rfrn�c_datar2r2r3�_AddCustomBuildToolForMSVS�s


r�c
Cs�x�|D]�}t�}t�}g}g}xP||D]D}|jt|d��|jt|d��|j|d�|j|d�q(Wdj|�}	dj|�}
t||||||	|
d�qWdS)	aAdd 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�z, and also z
)r�r�r�r�r�N)r�updaterNr@r�)r�r�r�r�r�r��descriptions�commandsr�r�r�r2r2r3�_AddAccumulatedActionsToMSVS�s$	


r�cCs�|jdtjjtjj|�d�d�}|jdtjj|��}|jdtjjtjj|�d�d�}|jdtjj|�d�}|jd|�}|S)z�Given 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.
  z$(InputName)rrz$(InputDir)z$(InputExt)z$(InputFileName)z$(InputPath))rAr$r6�splitext�split�dirname)r6Z
input_filer2r2r3�_RuleExpandPath�s	r�cCs|jdg�S)z�Find 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_sources)r&)r�rSr2r2r3�_FindRuleTriggerFiless	r�cCszt|jdg��}t|jdg��}t�}t�}|j|�x|D]}|jt||��q<Wx|D]}|jt||��qZW||fS)z�Find 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�)rGr&r�addr�)r��trigger_fileZ
raw_inputsZraw_outputsr�r�rD�or2r2r3�_RuleInputsAndOutputss	


r�c
	Cs�d|d|jf}tjtjj||�|d�}x�|D]|}|d}|d}	t|jdg��}
t|jdg��}d|kr~|jdg�r~q2t||d	d	d
�}|j	||jd|�|	g|
||d�q2W|j
�|j|�d
S)z�Generate 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
%s%s.rules�target_name�	rule_name�	extensionr�r�r�r�T)r�r��message)�namer��
extensions�additional_dependenciesr�r�N)�suffix�MSVSToolFile�Writerr$r6r@rGr&r�ZAddCustomBuildRule�WriteIfChanged�AddToolFile)
r��rules�
output_dirr��optionsZrules_filenameZ
rules_file�rr�Zrule_extr�r�r�r2r2r3�_GenerateNativeRulesForMSVS&s*




r�cCs|jdd�}|jdd�}|S)Nz	$(OutDir)z$(OutDirCygwin)z	$(IntDir)z$(IntDirCygwin))rA)r6r2r2r3�
_CygwinifyLsr�csHd|d|jf}tjjtjj||��}|jd�|jd�t�}t�}	t�}
g}x�|D]~}t	||�}
xn|
D]f�t
|��\}}|jt|��|	jt|��|jt
|�d�dd�|D�}x|D]}|
j|�q�WqlWqXWdd�|D�}|jd	d
j|��x"|
D]}|�r|jd|��qW|jd�x�|D]�}t	||�}
x�|
D]��t
|��\}}d
d�|D�}dd�|D�}�fdd�|dD�}dd�|D�}d
j|�}|jdd
j|�d
j|�f�|jd|��qDW�q0W|j�|j|�dddddd|g}t||dddd�}t
|�}|jd|�t|t|�t|	�d|d|d�dS)aGGenerate 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
%s_rules%s.mkr�z.OutDirCygwin:=$(shell cygpath -u "$(OutDir)")
z.IntDirCygwin:=$(shell cygpath -u "$(IntDir)")
rcSsg|]}tjj|�d�qS)r)r$r6r�)rCrDr2r2r3rErsz*_GenerateExternalRules.<locals>.<listcomp>cSsg|]}t|��qSr2)r�)rCrDr2r2r3rEuszall: %s
r�z	mkdir -p `cygpath -u "%s"`
�
cSsg|]}t|��qSr2)r�)rCrDr2r2r3rE�scSsg|]}t|��qSr2)r�)rCrDr2r2r3rE�scsg|]}t|���qSr2)r�)rC�c)�tfr2r3rE�sr�cSsg|]}d|�qS)z"%s"r2)rCrDr2r2r3rE�sz%s: %s
z	%s

ZmakezOutDir=$(OutDir)zIntDir=$(IntDir)z-jz${NUMBER_OF_PROCESSORS_PLUS_1}z-fTFzRunning external rules for %s)r�r�r�r�N)r��gyp�commonZWriteOnDiffr$r6r@�writerr�r�r�rNrdr��closer�r�r�rG)r�r�r�rSr��actions_to_addrVZmk_fileZ
all_inputsZall_outputsZall_output_dirsZ
first_outputsr��
trigger_filesr�r�Zoutput_dirsZodZfirst_outputs_cygr�r2)r�r3�_GenerateExternalRulesRsf












r�cCs|jdd�}|S)a�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%%)rA)rUr2r2r3�#_EscapeEnvironmentVariableExpansion�sr�z(\\*)"cCs$dd�}tj||�}d|d}|S)awEscapes 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.
  cSsd|jd�dS)N�rz\")r.)�matchr2r2r3�_Replace�sz3_EscapeCommandLineArgumentForMSVS.<locals>._Replacer�)�quote_replacer_regex�sub)rUr�r2r2r3�!_EscapeCommandLineArgumentForMSVS�sr�z(\\*)([,;]+)cCspdd�}|jd�}x,tdt|�d�D]}tj|||�||<q$Wdj|�}t|�ddkrltd	|tjd�|S)
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.
  cSs d|jd�d|jd�dS)Nr�rr�)r.)r�r2r2r3r��sz5_EscapeVCProjCommandLineArgListItem.<locals>._Replacer�rr�z1Warning: MSVS may misinterpret the odd number of z
quotes in )�filez;Warning: MSVS may misinterpret the odd number of quotes in )	r��rangerM�delimiters_replacer_regexr�r@r~r �stderr)rUr�ZsegmentsrDr2r2r3�#_EscapeVCProjCommandLineArgListItem�s

r�cCs0t|�}t|�}t|�}|jddtd��}|S)zBEscapes a CPP define so that it will reach the compiler unaltered.�#z\%03o)r�r�r�rA�ord)rUr2r2r3�_EscapeCppDefineForMSVSs
r�z(\\+)"cCsdd�}tj||�}|S)z;Escapes a Windows command-line argument for use by MSBuild.cSst|jd��ddddS)Nrr��r<z\")rMr.)r�r2r2r3r�sz6_EscapeCommandLineArgumentForMSBuild.<locals>._Replace)�quote_replacer_regex2r�)rUr�r2r2r3�$_EscapeCommandLineArgumentForMSBuildsr�cs0dddddddd��d	j�fd
d�|D��}|S)Nz%25z%24z%40z%27z%3Bz%3Fz%2A)r�r5�@�'r��?�*rcsg|]}�j||��qSr2)r&)rCr�)�escape_dictionaryr2r3rE)sz3_EscapeMSBuildSpecialCharacters.<locals>.<listcomp>)r@)rUrTr2)r�r3�_EscapeMSBuildSpecialCharacterssr�cCs0t|�}t|�}t|�}|jddtd��}|S)zBEscapes a CPP define so that it will reach the compiler unaltered.r�z\%03o)r�r�r�rAr�)rUr2r2r3�_EscapeCppDefineForMSBuild-s
r�c
Csd|jdg�}dd�|D�}dd�|D�}	|r<t|||||�|	rRt|	|||||�t|||d�dS)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
  r�cSs g|]}t|jdd��s|�qS)�msvs_external_ruler)r�r&)rCr�r2r2r3rEGsz)_GenerateRulesForMSVS.<locals>.<listcomp>cSs g|]}t|jdd��r|�qS)r�r)r�r&)rCr�r2r2r3rEHsFN)r&r�r��_AdjustSourcesForRules)
r�r�r�r�rS�excluded_sourcesr�r��rules_native�rules_externalr2r2r3�_GenerateRulesForMSVS8s
r�c	Cs�x�|D]�}t||�}x�|D]x}|jt|��t|jdd��rt||�\}}tt|��}tt|��}|jt|��|j	|�|s�|j	|�|j	|�qWqWdS)N�process_outputs_as_sourcesF)
r��discardrBr�r&r�rrG�remover�)	r�rSr�Z
is_msbuildr�r�r�r�r�r2r2r3r�Us




r�cs"tt|j�����fdd�|D�S)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.
  csg|]}|�kr|�qSr2r2)rCrU)�	must_keepr2r3rEusz._FilterActionsFromExcluded.<locals>.<listcomp>)rrG�keys)r�r�r2)r�r3�_FilterActionsFromExcludedks	r�cCs|d|dS)Nr�Zdefault_configurationr2)r�r2r2r3�_GetDefaultConfigurationxsr�cCsPt|�}|jd�}|r>tj|�dkr6td|tjf��d|}|pJtj|�}|S)aGet 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.
  Z	msvs_guidNz1Invalid MSVS guid: "%s".  Must match regex: "%s".z{%s})r�r&�VALID_MSVS_GUID_CHARSr��
ValueError�pattern�MSVSNew�MakeGuid)�	proj_pathr��default_config�guidr2r2r3�_GetGuidOfProject|s
rcCs<t|�}|jd�}|r(|j�r(|j�}|ddkr8d}|S)aGet 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_toolsetra�windows_driverzWindowsKernelModeDriver10.0)r�r&ZDefaultToolset)r�r�rwr�toolsetr2r2r3�_GetMsbuildToolsetOfProject�s
rcCs@t|j�}|jd�rgS|j�r.t||||�St||||�SdS)aGenerates 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_vcprojN)r�r�r&rO�_GenerateMSBuildProject�_GenerateMSVSProject)�projectr�rw�generator_flagsrr2r2r3�_GenerateProject�s

rc
Cs�|jdd�dkrdS|jdg�}i}xH|D]@}tjj|�\}}|dk}|sLq*tjj|�}|j|g�j|�q*Wd}	x6|j�D]*\}}
t|
�dkr||	d|dj	|
�f7}	q|W|	r�t
d|d|	d�td��dS)z�Makes sure if duplicate basenames are not specified in the source list.

  Arguments:
    spec: The target dictionary containing the properties of the target.
    version: The VisualStudioVersion object.
  raN�static_library�shared_libraryrS�.c�.cc�.cpp�.cxx�.m�.mm�.s�.Srrz	  %s: %s
r�z<static library %s has several files with the same basename:
r�zMSVC08 cannot handle that.z6Duplicate basenames in sources section, see list above)r
r)rrrrrrrr)r&r$r6r��basename�
setdefaultrNr�rMr@r~r)r�rwrSZ	basenamesr9r��extZis_compiled_filer�error�filesr2r2r3�_ValidateSourcesForMSVSProject�s(
rcCs�|j}tjj|j�t|�}tj|j||d|j|�}t	jj
|j�d}t|j�}tjj
||�}	t||j�}
x(|dj�D]\}}t|||
||�qzWt||�t	jj
|j�d}
t|||
�\}}i}t|||||||�|jdd�}t|||||||�\}}}t||�}|j|�t||�t|||�t|||	�t||�t|j||�t||�}t|||||�t|||�|j �|S)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�rr�r�msvs_list_excluded_filesT)!r�r�r��EnsureDirExistsr6�_GetUniquePlatformsrQr�rr$r�r:�
build_file�RelativePath�_GetMSVSConfigurationTyper��_AddConfigurationToMSVSProjectr�_PrepareListOfSourcesr�r&�)_AdjustSourcesAndConvertToFilterHierarchy�_VerifySourcesExistZAddFiles�_AddToolFilesToMSVS�_HandlePreCompiledHeaders�_AddActions�
_AddCopies�_WriteMSVSUserFiler��_ExcludeFilesFromBeingBuiltr�r�)r
r�rwrr��	platformsr��project_dir�gyp_path�relative_path_of_gyp_file�config_typernr�gyp_filerSr�r�rI�excluded_idl�missing_sourcesr2r2r3r	�sJ	









r	cCs:t�}x&|dD]}|jt|d|��qWt|�}|S)z�Returns 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�)rr�rkrd)r�r-�
configurationr2r2r3r)s
	rcCs2t�\}}dj|||dg�}tj|||d�}|S)a�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�)r4r@�MSVSUserFiler�)r�rwr�r/r0Zvcuser_filename�	user_filer2r2r3�_CreateMSVSUserFile9s


r9c
Csryddddddd�|d}WnNtk
rl|jd�rTtd|d|d	|f��ntd
|d	|f��YnX|S)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)�
executabler�loadable_moduler
r�noneraz>Target type %s is not a valid target type for target %s in %s.r�z'Missing type field for target %s in %s.)�KeyErrorr&r)r�r r1r2r2r3r"Ks
r"cCst|�\}}}t|�}t|�}	t|dd�\}
}}t|�}
dd�|
D�}
t|�}|jd�}|jd�}t|�}|jd�}t�}|jdi�}t	j
|�t|d	d
dg�x8|D]0}|d|}x|D]}t|||||�q�Wq�Wt|dd
|�t|dd
|�t|dd
|�t|d	d
|�t|d	d|	�|
�r8t||d|
dd�t|dd|
�t|dd|
�t|ddddd�t|dd|�t|dd|�t|dd|�|�r�tj
j|�d}t|ddd�t|dd|�t|dd|�|d d!k�r�t|d	d"d#�|�rt|d	d$|�t||||||�d%S)&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)�msbuildcSsg|]}t|��qSr2)r�)rC�dr2r2r3rEsz2_AddConfigurationToMSVSProject.<locals>.<listcomp>�
msvs_prebuild�msvs_postbuildr�
msvs_settings�VCLinkerToolr�z$(NOINHERIT)�VCCLCompilerTool�AdditionalIncludeDirectoriesZ
VCMIDLToolZVCResourceCompilerTool�AdditionalLibraryDirectories�
OutputFileT)r]�PreprocessorDefinitionsZProgramDataBaseFileNamez $(IntDir)$(ProjectName)\vc80.pdb�DisableSpecificWarningsZVCPreBuildEventToolr�ZVCPostBuildEventToolr�UsePrecompiledHeaderr;ZPrecompiledHeaderThrough�ForcedIncludeFilesrar@�IgnoreImportLibrary�true�ModuleDefinitionFileN)�_GetIncludeDirs�
_GetLibraries�_GetLibraryDirs�_GetOutputFilePathAndTool�_GetDefines�_GetDisabledWarningsr&�_GetModuleDefinitionrcr�ZValidateMSVSSettingsr^r$r6r��_AddConfigurationToMSVS)r�r�r1rnr�include_dirs�midl_include_dirs�resource_include_dirs�	libraries�library_dirs�out_file�vc_toolrl�defines�disabled_warnings�prebuild�	postbuild�def_file�precompiled_headerrYrGrf�settingsr[r2r2r3r#jsf






r#cCs^|jdg�|jdg�}|jdg�|jdg�}|jd|�}t|�}t|�}t|�}|||fS)z�Returns 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\Zmsvs_system_include_dirsr]r^)r&rG)rr\r]r^r2r2r3rT�s

rTcCs|jdg�}t|�}|S)z�Returns 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&rG)rr`r2r2r3rV�s
rVcCsv|jdg�}t�}g}xRt|�D]F}tjdd|�}tjj|�dsJ|d7}||kr |j|�|j	|�q W|j
�|S)z�Returns 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^\-lrrz.lib)r&r�reversedr*r�r$r6r�r�rNrx)r�r_�foundZunique_libraries_list�entryZlibraryr2r2r3rU�s
rUcCs�d}d}d}dddddd�}|j|d
�}|r�t|jdd��r�|\}}}}|jdd�rZd}|jd|�}|jd�}	|	r~d|	}n|r�d}|jdd�}
|jdd�}tj||
||�}|||fS)aNReturns 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)
  rrH�Link�	$(OutDir)�.exe�.dll�.sys�VCLibrarianTool�Lib�
$(OutDir)lib\�.lib)r?rr@rr
raZmsvs_auto_output_filerZstandalone_static_libraryrZproduct_dir�product_extensionr�z$(TargetExt)�product_prefix�product_namez$(ProjectName))rHrmrnro)rHrmrnrp)rHrmrnrp)rHrmrnrq)rrrsrtru)r&r��ntpathr@)r�rCrarb�msbuild_toolZoutput_file_mapZoutput_file_propsZout_dirr�rvrLrxr2r2r3rWs.

rWcCs|jd�}|rd|SdS)aqReturns 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
  rvr�N)r&)r�Ztarget_extensionr2r2r3�_GetOutputTargetExt)s
r{cCsRg}xH|jdg�D]8}t|�tkr8djdd�|D��}nt|�}|j|�qW|S)z�Returns the list of preprocessor definitions for this configuation.

  Arguments:
    config: The dictionary that defines the special processing to be done
            for this configuration.
  Returns:
    The list of preprocessor definitions.
  rc�=cSsg|]}t|��qSr2)rb)rCZdpartr2r2r3rEGsz_GetDefines.<locals>.<listcomp>)r&rardr@rbrN)rrcrD�fdr2r2r3rX;s	rXcCsdd�|jdg�D�S)NcSsg|]}t|��qSr2)rb)rCrDr2r2r3rEOsz(_GetDisabledWarnings.<locals>.<listcomp>Zmsvs_disabled_warnings)r&)rr2r2r3rYNsrYcCsbd}|ddkr^dd�|jd	g�D�}t|�d
kr@t|d�}n|r^td|d
dj|�f��|S)Nrrarr@r?rcSsg|]}|jd�r|�qS)z.def)rm)rCrUr2r2r3rEVsz(_GetModuleDefinition.<locals>.<listcomp>rSrrzWMultiple module definition files in one target, target %s lists multiple .def files: %sr�r�)rr@r?r)r&rMrBr�r@)r�rgZ	def_filesr2r2r3rZRsrZcCs�g}x�|j�D]�\}}i}x`|j�D]T\}}t|�tkrp|dkrH|dksP|dkr`dj|�||<qxdj|�||<q$|||<q$W|jtj||��qW|S)z�Convert 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.
  rHr��AdditionalOptionsr�r�)r�rardr@rNrQr�)rY�	tool_listrfriZsettings_fixedr[r\r2r2r3�_ConvertToolsToExpectedFormasr�cCs.t|||�}t|�}|jt||�||d�dS)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.
  )ZattrsrYN)�_GetMSVSAttributesr�Z	AddConfigrq)r�r�rYrr1rn�
attributesrr2r2r3r[|sr[c	Cs�i}|jdi�}x|D]}||||<qW|jdg�}t|�}|rPdj|�|d<||d<|jdd�}t|�d|d<d	|kr�d
}t|�d|d	<n"t|d	�d}tj|�}||d	<|S)NZmsvs_configuration_attributesr
r�ZInheritedPropertySheets�ConfigurationType�OutputDirectoryz"$(SolutionDir)$(ConfigurationName)r<�IntermediateDirectoryz'$(ConfigurationName)\obj\$(ProjectName))r&rGr@rBr�r�)	r�rr1Zprepared_attrsZsource_attrs�aZvsprops_dirsr��intermediater2r2r3r��s&

r�cCs|jdd�|D��dS)Ncss|]}t|�VqdS)N)r:)rCrUr2r2r3�	<genexpr>�sz(_AddNormalizedSources.<locals>.<genexpr>)r�)Zsources_setZ
sources_arrayr2r2r3�_AddNormalizedSources�sr�cCs�t�}t||jdg��t�}|jd�s2|j|�xr|jdg�D]b}|d}dd�|D�}t|�}|j|�|jd�s�|j|�t|jdd	��r@t||jd
g��q@Wx&|jdg�D]}t||jdg��q�W||fS)
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.
  rSZ
standalone�actionsr�cSsg|]}t|��qSr2)r:)rCrDr2r2r3rE�sz)_PrepareListOfSources.<locals>.<listcomp>rr�Fr��copiesr)rr�r&r�r�r�)r�rr2rSr�r�r��cpyr2r2r3r$�s"




r$c	s�|jt|jdg���|j|�t|�}t|�}t||�}t|���fdd�|D�}dd�|D�}t||||d�}|j�r�xltdd�|D��r�t	t
dd�|D���dkr�d	d�|D�}q|Wn,x*t	|�dkr�t|d
tj
�r�|d
j}q�W|||fS)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)
  Zsources_excludedcsg|]}|�kr|�qSr2r2)rCrD)�precompiled_relatedr2r3rE�sz=_AdjustSourcesAndConvertToFilterHierarchy.<locals>.<listcomp>cSsg|]}|jd��qS)r<)r�)rCrDr2r2r3rE�s)rHrIrJcSsg|]}t|tj��qSr2)r�rQrR)rCrUr2r2r3rE�scSsg|]
}|j�qSr2)r�)rCrUr2r2r3rEsrcSsg|]}|jd�qS)r)rK)rCrUr2r2r3rEsr)r�rr&rG�_IdlFilesHandledNonNatively�_GetPrecompileRelatedFilesrPrO�allrM�setr�rQrRrK)	r�r��gyp_dirrSr�rIrwr3Zfully_excludedr2)r�r3r%�s$

r%cCsXd}x6|jdg�D]&}|ddkrt|jdd��rd}PqW|rPdd	�|D�}ng}|S)
NFr�r�Zidlr�rTcSsg|]}|jd�r|�qS)z.idl)rm)rCrDr2r2r3rEsz/_IdlFilesHandledNonNatively.<locals>.<listcomp>)r&r�)r�rSZ	using_idlr�r3r2r2r3r�
sr�cCsLg}xB|dj�D]2\}}x(tD] }|j|�}|r |jt|��q WqW|S)Nr�)r��precomp_keysr&rNrB)r�r�rlr�krWr2r2r3r�s

r�c
Cslt|||�}xZ|j�D]N\}}|r:t|�t|d�kr:qx(|D] \}}	|j|t||	�ddi�q@WqWdS)Nr��ExcludedFromBuildrR)�_GetExcludedFilesFromBuildr�rMr�rq)
r�r�r�r3rI�
exclusions�	file_name�excluded_configsrnrr2r2r3r,$sr,cs�i}xZ|D]R}g}x@|dj�D]0\}��fdd�tD�}||kr |j|�f�q W|||<q
Wx@|D]8}g}x&|dj�D]\}�|j|�f�q|W|||<qfW|S)Nr�csg|]}t�j|d���qS)r)rBr&)rCrD)rr2r3rE9sz._GetExcludedFilesFromBuild.<locals>.<listcomp>)r�r�rN)r�r�r3r�rWr�rnZ	precompedr2)rr3r�3s

r�cCs\t�}x8|dj�D](\}}x|jdg�D]}|j|�q*WqWx|D]}|j|�qFWdS)Nr��msvs_tool_files)rr�r&r�r�)r�r�Z
tool_filesrlrrWr2r2r3r'Hs
r'c	s�g�x��dj�D]r\}}|jd�}|rt|�}tjdddi�}�j|t||�i|gd�tjj	|�\}}|dkr~dd	d
g�qdg�qW����fdd���r��|�dS)
Nr�rrIrOr:)rYz.cz.ccz.cppz.cxxcs�x�|D]~}t|tj�r"�|j�qtjj|�\}}|�krxH�dj�D]8\}}tjdddd��}�j	t
|�t||�i|gd�qHWqWdS)Nr�rI�0z$(NOINHERIT))rOrP)rY)r�rQrRrKr$r6r�r�r�r�rBrq)Zsource_treer9rr�rnrrf)�DisableForSourceTree�#extensions_excluded_from_precompiler�r�r2r3r�fs


z7_HandlePreCompiledHeaders.<locals>.DisableForSourceTree)
r�r&rBrQr�r�rqr$r6r�)	r�rSr�rnrr9rfrr�r2)r�r�r�r�r3r(Rs 


r(c
	Cs�|jdg�}t�}xl|D]d}|jd�p*|g}|d}||k}t||d|d�}	|j|�t|||jdg�|jd|d�|	d	�qWdS)
Nr�r�rF)r�r�r�r�Zaction_name)r�r�r�r�)r&r�r�r�r�)
r�r�r0r�Zhave_setup_envr�r�Zattached_toZneed_setup_envr�r2r2r3r)ys


r)c
Cs�d|kr6|d}|jdg�}|jdg�}|jdd�}n&t|jdd��rXdd	g}g}d}ndSt|||�}x.|d
j�D]\}}	|jt||	�|||�qvW|j�dS)N�run_asr��environment�working_directoryr�Ztestrz
$(TargetPath)z--gtest_print_timer�)r&r�r9r�ZAddDebugSettingsrqr�)
Zproject_pathrwr�r�r�r�r�r8rnr�r2r2r3r+�sr+cCs4t|�}x&|D]\}}}}t|||||d�qWdS)N)r�r�r�r�)�
_GetCopiesr�)r�r�r�r�r�r�r�r2r2r3r*�sr*c	Csg}�x|jdg�D]�}x�|jdg�D]�}tjj|dtjj|��}|jd�r�|dd�}tj|�d}tj|�d}t|�}d||f}	d|	t|�||	f}
|j	|gd	|g|
d
||ff�q&t|d�}d|t|�t|�f}
|j	|g|g|
d
||ff�q&WqW|S)
Nr�rZdestinationr;rrz"%s\%s\"z2mkdir %s 2>nul & cd "%s" && xcopy /e /f /y "%s" %sZdummy_copieszCopying %s to %sz7mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"r=)
r&r$r6r@rrm�	posixpathr�rBrN)r�r�r��src�dstZsrc_bareZbase_dirZ	outer_dirZ	fixed_dstZfull_dstr�Zfix_dstr2r2r3r��s&
&r�cCsJ|s|jtj�r|Stjj|�\}}t||�}||krBt�||<||S)N)rmr$�sepr6r��_GetPathDictrc)�rootr6�parent�folderZparent_dictr2r2r3r��s

r�cCs�g}x||j�D]p\}}t|�tkrtttjj||�||�}|rF||7}q~tjtjj||�d|d|d�}|j	|�q|j	|�qW|S)N�(�))r��entries)
r�rarc�_DictsToFoldersr$r6r@r�Z
MSVSFolderrN)�	base_pathZbucket�flatZchildrenr�rKZfolder_childrenr2r2r3r��s

r�cCspt|�tkr<t|�dkr<tt|��|dkr<|tt|��St|�tkrL|Sx|D]}t|||�||<qRW|S)Nrz.vcproj)rarcrM�next�iter�_CollapseSingles)r��nodeZchildr2r2r3r��s
r�c	Cs�i}xJ|D]B}tjj|�dd�\}}tjj|�}t||�}||||d<q
Wx8t|�dkr�t|t	t
|���tkr�|t	t
|��}qRWtd|�}t
d||�S)Nrr�z.vcprojrr)r�r��ParseQualifiedTargetr$r6r�r�rMrar�r�rcr�r�)	�sln_projects�project_objectsr�r�r�r2�targetr�Z	path_dictr2r2r3�_GatherSolutionFolders�s

&
r�c
Cs�t|�}|jd�}|s,|d|j|j�}tjj|�}tjj	tjj
|�|�}d}|jr�tjj
tjj|��}	tjj	|j|�}tjj
|	tjj
|��}||fS)Nrr�)r�r&r�ZProjectExtensionr�r��	BuildFiler$r6r@r��generator_output�abspathr!)
�qualified_targetr�r�rJrZ
proj_filenamer r�Z
fix_prefixZproject_dir_pathr2r2r3�_GetPathOfProjects

r�cCsZi}xP|dj�D]@\}}t||�}|jdt|��}dt|t|��|f}|||<qW|S)Nr�Zmsvs_target_platformz%s|%s)r�rqr&rkrp)r��config_platform_overridesrnr�Zconfig_fullnamer!Zfixed_config_fullnamer2r2r3�_GetPlatformOverridesOfProjects
r�c

s�i�x�|D]�}||}|ddkr.td|��t||||�\}at||�}t|�}tjj|�}	tj	||d|||	|td�}
|j
�r�|
jt|||��|
�|<q
WxF�j
�D]:}|jjd�s�|jjdg�}�fdd	�|D�}|j|�q�W�S)
aXCreate 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.
  rr�z9Multiple toolsets not supported in msvs build (target %s)r�)r�rr�r r�r>r�dependenciescsg|]}�|�qSr2r2)rCrD)�projectsr2r3rESsz)_CreateProjectObjects.<locals>.<listcomp>)rr�r>rr�r�r�r�r�rQrOZset_msbuild_toolsetr�valuesr�r&Zset_dependencies)
�target_list�target_dictsr�rJr�r�r�rZ	overridesr �objr
Zdepsr2)r�r3�_CreateProjectObjects's<


r�c
Cs�x�|D]�}||}|jd�rq|jdd�}d|d<|jd�s�tjj|�\}}}tjj|�}d}	|jd�dkrt|	d	7}	tjjtjj|d
j	|�t
j|�|	�|d<|jd�s�|dd
dg|d<|jd�s|dd
ddg|d<qWdS)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Zmsvs_path_to_ninjaz	ninja.exe�ninjar
z$(Configuration)Ztarget_arch�x64Z_x64r�rz-Cz	$(OutDir)z$(ProjectName)rz-tcleanN)r&r�r�r�r$r6r�r@r!�toplevel_dir�ninja_generator�ComputeOutputDir)
�paramsr�r�r�r�Z
path_to_ninjar2rlr�r5r2r2r3�_InitNinjaFlavorXs6






r�cCs�|jdi�}tj|jdd��}||d<|j�|d<tjjdd�jd�dksbtjjd	d�jd�dkrld
|d<nd|d<tjj	|�d
kr�d|d<dS)z4Generated variables that require params to be known.rrJ�autoZMSVS_VERSION�PROCESSOR_ARCHITECTURErZ64r�PROCESSOR_ARCHITEW6432�@ZMSVS_OS_BITS� r�z$(OutDir)genrN)
r&rzZSelectVisualStudioVersionZ	ShortNamer$r%r�r�r�Z	GetFlavor)Zdefault_variablesr�rrJr2r2r3�CalculateVariables�s
r�cCs�|d}|d}tjj|jddd�}xR|j�D]F\}}tjj|�\}}	|	dkrPq.||jd}
|jr.tjj|j|
�}
q.Wx2|D]*}||
d|g}td	||f�tj	|�}
q~WdS)
Nr�rJZCommon7ZIDEz
devenv.comz.gypz.slnz/BuildzBuilding [%s]: %s)
r$r6r@r�r�r�r�r~r'Z
check_call)�datar�r�r�rJZdevenvr Zbuild_file_dictZbuild_file_rootZbuild_file_ext�sln_pathrr�Zrtnr2r2r3�PerformBuild�s
r�cCsD|jd�dkr@|dj}tjjtjj|tj|�d��}||d�adS)N�flavorr�r�zgypfiles-msvs-ninja)�toplevel�qualified_out_dir)	r&r�r$r6r7r@r�r��generator_filelist_paths)r�r�r�r2r2r3�CalculateGeneratorInputInfo�s

r�cCs�|d}|d}|jdi�}tj||�\}}tj||t�\}}|jd�dkrXt|||�t�}x>|D]6}||}	x(|	dj�D]\}
}|jt	|
|��q~WqdWt
|�}t||||�}g}
x*|j�D]}|j
a
|
jt||||��q�Wda
x�|D]�}|jd��sq�tjj|�d	|jd
}|j�r2tjj|j|�}tjj||�}|tjj||�7}t|||j�d�}tj|||d|d
�}|j�q�W|
�r�ddjt|
��}|jdd��r�t |��nt!d|�dS)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.
  r�rJrr�r�r�Nz.gyprz.sln)r�F)r�ZvariantsZwebsitePropertiesrwzMissing input files:
r�Zmsvs_error_on_missing_sourcesz	Warning: )"r&�MSVSUtilZShardTargetsZInsertLargePdbShims�generator_default_variablesr�r�r�r�rqrdr�r�r>�extendrrmr$r6r�r�r�r@r�r�ZBuildFileTargetsZDeepDependencyTargetsr�ZFlatSolutionr�ZMSVSSolutionZWriterr~)r�r�r�r�r�rJrZconfigsr�r�rnrr�r4r
r r�r�Zroot_entriesZslnZ
error_messager2r2r3�GenerateOutput�sX


r�cCsjg}g}td|||||�|rPdddd�dg|dg|g}tj||ddd�ntjj|�rftj|�d	S)
aVGenerate 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�Projectz4.0z3http://schemas.microsoft.com/developer/msbuild/2003)�ToolsVersion�xmlns�	ItemGroupT)�prettyrN)�_AppendFiltersForMSBuild�easy_xml�WriteXmlIfChangedr$r6�exists�unlink)Zfilters_pathZsource_files�rule_dependencies�extension_to_rule_name�filter_group�source_group�contentr2r2r3�_GenerateMSBuildFiltersFiles
r�cCs�x�|D]�}t|tj�rf|s"|j}nd||jf}|jdd|idtj|j�gg�t||j||||�qt	|||�\}}	|	d|ig}
|r�|
jd|g�|j|
�qWdS)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 appeneded.
  z%s\%srR�IncludeZUniqueIdentifierN)
r�rQrRr�rNr�r�r�rK�_MapFileToMsBuildSourceType)Zparent_filter_namerSr�r�r�r�r9Zfilter_namerl�elementZsource_entryr2r2r3r�3s"


r�cCs�tjj|�\}}||kr&d}||}nt|dkr8d}d}nb|dkrJd
}d}nP|dkr\d
}d}n>|dkrnd}d}n,|dkr�d}d}n||kr�d}d}nd}d}||fS)aReturns 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��.cc�.cpp�.c�.cxxr+�	ClCompile�.h�.hxx�includeZ	ClIncludez.rc�resource�ResourceCompilez.asm�masmZMASMz.idl�midl�Midl�rule_dependency�CustomBuildrA�None)r�r�r�r�)r�r�)r$r6r�)r9r�r�rlrr.r�r2r2r3r�Zs2
r�c
Cs6|jdg�}
dd�|
D�}dd�|
D�}g}
xV|D]N}d|krN|jdg�rNq2t||�}|
j|�|j|jjd��|j|	|j<q2W|
�r|d|j}|d	}|d
}|d}|j	|�|j	|�t
jj||�}t
jj||�}t
jj||�}t
||
�t||
�t||
�|�r$t||||||�t|
||d�dS)
Nr�cSs g|]}t|jdd��s|�qS)r�r)r�r&)rCr�r2r2r3rE�sz,_GenerateRulesForMSBuild.<locals>.<listcomp>cSs g|]}t|jdd��r|�qS)r�r)r�r&)rCr�r2r2r3rE�sr�r�r�r�z.propsz.targetsz.xmlT)r&�MSBuildRulerNr�r�r�r�r�r�r�r$r6r@�_GenerateMSBuildRulePropsFile�_GenerateMSBuildRuleTargetsFile�_GenerateMSBuildRuleXmlFiler�r�)r�r�r�rSr��props_files_of_rules�targets_files_of_rulesr�r�r�r�r�r��
msbuild_rulesr�Zmsbuild_rule�baseZ
props_nameZtargets_nameZxml_name�
props_path�targets_path�xml_pathr2r2r3�_GenerateRulesForMSBuild�s8	








rc@seZdZdZdd�ZdS)ra-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.
  cCs |d|_tjdd|j�|_d|j|_|jd|_|jd|_|jd|_d|j|_|jd|_	|jd	|_
|jd
|_|d|_|jj
d�s�d|j|_tj|jd
|j��|_t|jdg��}djdd�|D��|_t|jdg��}djdd�|D��|_t||ddd�}tj|�|_dS)Nr�z\Wrl�AfterTargets�
BeforeTargetsZ	DependsOnzCompute%sOutputZ
DirsToMakeZ_inputsZ_tlogr�r�r�r�r�cSsg|]}tj|��qSr2)r��ConvertVCMacrosToMSBuild)rCrDr2r2r3rE�sz(MSBuildRule.__init__.<locals>.<listcomp>r�cSsg|]}tj|��qSr2)r�r)rCrDr2r2r3rE�sT)r�r�)�display_namer*r�r�r��
after_targets�before_targets�
depends_on�compute_output�dirs_to_maker��tlogr�rur�rr&r�rGr@r�r�r�r�)�selfr�r�Zold_additional_dependenciesZold_outputsZold_commandr2r2r3�__init__�s0



zMSBuildRule.__init__N)�__name__�
__module__�__qualname__�__doc__rr2r2r2r3r�srcCs�dddig}x~|D]v}|jddd|j|jfi|jdg|jdggd|jdd	id
|jggd|jd|jgd
|jgd|jgd|jgggg�qWt	j
||ddd�dS)zGenerate the .props file.r�r�z3http://schemas.microsoft.com/developer/msbuild/2003�
PropertyGroup�	ConditionzH'$(%s)' == '' and '$(%s)' == '' and '$(ConfigurationType)' != 'Makefile'r�rz$'$(ConfigurationType)' != 'Makefile'z_SelectedFiles;$(%s)�ItemDefinitionGroup�CommandLineTemplater��ExecutionDescriptionr�T)r�rN)r�rrrr�r�r�r�r�r�r�)rr	r�r�r2r2r3r�s*



rcCs�dddig}ddddigg}x(|D] }|jdd|jid	|jgg�q"W|j|�x*|D]"}|jd
|jddd
�ddgg�qVW�x|D�]�}|j}d|}d||f}d|}d}	dddi|d|dd�gg}
d|jdd|igg}d|jd|d||fd�dd|gdd|jggg}dd d!|d"�g}
d#d$|j|jfd%d&|j|jfd'�g}d#d$|j|jfd(d)|j|jfd'�g}|d$||fd*d d d+|d,||d-�g}|jd.|jd/|jd/|jd0|d1|j|j	f||d2�|
|||
|||g	d3d4d5d6|j	gd7d8d6|j	ggd.|j	d0|d9�d|j
d$||fd|d:�gd;d|j
|	d�gd<d|j
|	d�gd=d|j
|	d�ggd>d?d@|j
iggg�q�Wtj||dAdAdB�dCS)DzGenerate the .targets file.r�r�z3http://schemas.microsoft.com/developer/msbuild/2003r�ZPropertyPageSchemar�z5$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xmlZAvailableItemName�TargetsZ	UsingTaskZXamlTaskFactoryzMicrosoft.Build.Tasks.v4.0)ZTaskNameZTaskFactoryZAssemblyNameZTaskz%%(%s.Outputs)zC%%(%s.Identity);%%(%s.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)')ZRemover z%%(%s.AdditionalDependencies)z?'%%(%s.Outputs)' != '' and '%%(%s.ExcludedFromBuild)' != 'true')r�r ZSourcez
@(%s, '|')�Inputsz@(%s -> '%%(Fullpath)', ';')�MessageZHighz%%(%s.ExecutionDescription))Z
ImportanceZTextZWriteLinesToFilez6'@(%s)' != '' and '%%(%s.ExcludedFromBuild)' != 'true'z$$(IntDir)$(ProjectName).write.1.tlogz$^%%(%s.Source);@(%s->'%%(Fullpath)'))r ZFileZLinesz#$(IntDir)$(ProjectName).read.1.tlogz^%%(%s.Source);%%(%s.Inputs)rRz%%(%s.CommandLineTemplate)z%%(%s.AdditionalOptions))r ZEchoOffZStandardOutputImportanceZStandardErrorImportancer"r~r%�Targetz$(%s)z
'@(%s)' != ''z$(%s);%s)�Namerrr ZDependsOnTargetsr�r%rZComputeLinkInputsTargetsz$(ComputeLinkInputsTargets);z%s;ZComputeLibInputsTargetsz$(ComputeLibInputsTargets);)r(r )r r�rmrsZImpLibZMakeDirr_z!@(%s->'%%(RootDir)%%(Directory)')T)r�rN)
rNr�r�r�rr�rrrrrr�r�)rr	r�Z
item_groupr�r�Ztarget_outputsZ
target_inputsZrule_inputsZextension_conditionZremove_sectionZinputs_sectionZlogging_sectionZmessage_sectionZwrite_tlog_sectionZread_tlog_sectionZcommand_and_input_sectionr2r2r3r	s�









rcCs�dddddd�g}�x�|D�]�}|jd|jd|jd	d
�ddd
|jd�ggddddidddgggdddd�dddggggdddddd�ddd
|jdd�gggd d!dd"d"d#�gd$|jdd%d"d&�d'dd(ggd)dd*ggd+d,d-d.|jd/�ggd0dd
dd1�gggd$|jdd%d"d&�d'dd2ggd)dd3ggd+d,d-d.|jd/�ggd0dd
d4dd5�gggdd6d6d"d"d#�gd d7d8d"d"d#�gdd9d:d"d;d<�gd d=d=dd>�d?dd@ggdAdd@ggggdB|j|jdC�gdDdE|j|jdF�gdG|jd4|jdH�gg�qWtj||dIdIdJ�dS)KNZProjectSchemaDefinitionszTclr-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�zxmlns:xz	xmlns:syszxmlns:transformCallbackZRulerfZ200)r(ZPageTemplate�DisplayNameZOrderzRule.DataSourceZ
DataSourceZProjectFile)�Persistence�ItemTypezRule.Categories�Categoryr(ZGeneralzCategory.DisplayNamez
sys:StringzCommand Liner�)r(�SubtypeZStringListPropertyr%rRr�)r(r,Z
IsRequiredZSwitchzStringListProperty.DataSourceZItem)r*r+Z
SourceTypeZStringPropertyr"�False)r(r)�Visible�IncludeInCommandLineZDynamicEnumPropertyr$)r(r,ZEnumProviderr0zDynamicEnumProperty.DisplayNamezExecute BeforezDynamicEnumProperty.Descriptionz@Specifies the targets for the build customization to run before.z$DynamicEnumProperty.ProviderSettingsZ
NameValuePairZExcludez^%s|^Compute)r(ZValuezDynamicEnumProperty.DataSource)r*�HasConfigurationConditionz
Execute Afterz?Specifies the targets for the build customization to run after.r)r*r+r1r�r#zExecution Descriptionr�zAdditional Dependencies�false)r(r)r0r/r~)r-r(r,zStringProperty.DisplayNamezAdditional OptionszStringProperty.Descriptionr+)r(r)Z
FileExtensionr�)r(�ContentTyper3)r(r)r+T)r�r)r�r�rrrr�r�r�)r
r	r�r�r2r2r3r�	s�



rcCs$|jdd�d}|jdd�}||fS)Nrlrrrirj)�rsplitr&)r�rir5r!r2r2r3�_GetConfigurationAndPlatformZ
sr5cCsdt||�S)Nz''$(Configuration)|$(Platform)'=='%s|%s')r5)r�rir2r2r3�_GetConfigurationCondition`
sr6cCsddddig}xPt|j��D]@\}}t||�\}}d||f}|jdd|id|gd|gg�qW|gS)	Nr��LabelZProjectConfigurationsz%s|%sZProjectConfigurationr��
ConfigurationZPlatform)r{r�r5rN)r�r.r�rir5r!Zdesignationr2r2r3� _GetMSBuildProjectConfigurationse
sr9cCstjj|�d}dddid|gddgd|gd	d
ggg}tjjd�dksVtjjd
�dkrh|djddg�|jd�r�|jd�}|djd|g�|jd�r�|jd�}|djd|g�n|djd|g�|jd��rf|djddg�|djdd
g�|jd��r"|jd�}|djd|g�n|djddg�|jd��rT|djddg�n|djddg�d}	d}
xB|dj�D]2}|	�p�t|�}	|
�p�t||�}
|	�r||
�r|P�q|W|
�r�|djdt	|
�g�n|j
�r�td |j|j
f��|	d!k�r|djd"d
g�|S)#Nrrr7ZGlobalsZProjectGuidZKeywordZ	Win32ProjZ
RootNamespaceZ#IgnoreWarnCompileDuplicatedFilenamerRr�ZAMD64r�ZPreferredToolArchitecturer�rZWindowsTargetPlatformVersionrZWindowsTargetPlatformMinVersionrZDefaultLanguagezen-USZAppContainerApplicationrZApplicationTypeRevisionz8.1rZApplicationTypez
Windows Phonez
Windows Storer�z6%s requires any SDK of %s version, but none were foundZARMZWindowsSDKDesktopARMSupport)
r$r6r�r%r&rNr�rkr�rbryrr�)r�rwrZ
gyp_file_name�	namespace�
propertiesZtarget_platform_versionZtarget_platform_minversionZapp_type_revisionrorrr5r2r2r3�_GetMSBuildGlobalPropertiesq
s\











r<c	Cs�i}x�|dj�D]�\}}t|||�}t||�}|jd�}|jd�}t||d|�|dkrzt||dd�t||dt|��|rd|krt||d|�qWt|d	|�S)
Nr��CharacterSetr��DriverZ
DriverTypeZWDMZ
TargetVersionrr8)r��_GetMSBuildAttributesr6r&�_AddConditionalPropertyrh�_GetMSBuildPropertyGroup)	r�r r;r�ri�msbuild_attributes�	conditionZ
character_setr1r2r2r3�_GetMSBuildConfigurationDetails�
s"




rDcCs i}|rdddid|ggg}|S)Nrr7ZLocalsZPlatformToolsetr2)rr;r2r2r3�_GetMSBuildLocalProperties�
s
rEcCs�d}i}d}xHt|j��D]8\}}t||�}d|krJt|d�||<d}qd||<qW|szdddid	|d
|dd�gggSg}x^|j�D]R\}}	dd|d
�d	|d
|dd�gg}
x|	D]}|
jd	d|ig�q�W|j|
�q�W|SdS)Nz3$(UserRootDir)\Microsoft.Cpp.$(Platform).user.propsFZ
msbuild_propsTr�ImportGroupr7ZPropertySheets�Importzexists('%s')ZLocalAppDataPlatform)r�r r7)r7r r�)r{r�r6rGrN)r�Z
user_propsZadditional_propsZprops_specifiedr�rir5ZsheetsrCZpropsZimport_group�
props_filer2r2r3�_GetMSBuildPropertySheets�
s:

rIcCs�t||�}t|||�}i}x~|D]v}|dkrVtj||�}|jd�sL|d7}|||<q |dkrpt||�||<q |dkr�t||�||<q td|�q W|S)Nr�r�r<r=r�z3Warning: Do not know how to convert MSVS attribute )r�r�)r"r�r�rrm�_ConvertMSVSCharacterSet�_ConvertMSVSConfigurationTyper~)r�rr r1Zmsvs_attributesrBr�Z	directoryr2r2r3�_ConvertMSVSBuildAttributes�
s



rLcCs|j�rdddd�|}|S)NZ	MultiByteZUnicode)r�r:r;)�isdigit)Zchar_setr2r2r3rJ
srJcCs |j�rdddddd�|}|S)NZApplicationZDynamicLibraryZ
StaticLibraryr>ZUtility)r:r;r<r=r>)rM)r1r2r2r3rKsrKcCszd|krt|||�}nzt||�}t|�}|jdi�}|jd|�|jdd�}t|�d|d<d|krxtd�d}||d<d|kr�t|d�|d<d	|kr�|jd
d�}|jdd
�}||}	|	|d	<d|kr�d|kr�|jd�}
d|
|d<|jd��r|jdd�}t|�d|d<dddddd�}|j|d�}
|
�rv|d}||
jd�}|�rZt|�|d<||
jd�}|�rv||d<|S)NZ msbuild_configuration_attributesr�r�z$(SolutionDir)$(Configuration)r<r�z$(Configuration)r=�
TargetNamerwrrxz$(ProjectName)�	TargetExtrvr�rr
rmrs)r?rr@rr
ra�finalized_msbuild_settingsrL�
TargetPath)rLr"rKr&rrBrJ)r�rr rBr1r�r�rLrxr�rZexternal_out_dirZmsbuild_tool_maprz�msbuild_settingsra�
target_extr2r2r3r?#sR

r?cCs�g}|jddg�d}|rXdt|�}|j|�|jdd�}|j|�|rXddj|�}i}�xt|j��D�]\}}	t||	�}
t||	|�}|	d	}t	||
d
|d�t	||
d|d
�t	||
d|d�d|kr�t	||
d|d�|jd��rt	||
d|d�|jd��r t	||
d|d�|�r4t	||
d|�|jdi�}
x4t|
j��D]$\}}t
d||�}t	||
||��qNWqlWt|d|�S)Nr	r�rz"$(MSBuildProjectDirectory)\%s\bin\z
cygwin\binZ	python_26z$(ExecutablePath);r�rPZIntDirr�ZOutDirr�rNrOrQZExecutablePathr)r&rBrNrAr@r{r�r6r?r@�_GetValueFormattedForMSBuildrA)r�r�r Z	new_pathsZcygwin_dirsZcyg_pathZpython_pathr;r�r5rCr�rR�
tool_settingsr\�formatted_valuer2r2r3�(_GetMSBuildConfigurationGlobalPropertiesXsJ








rWcCs>||kri||<||}||kr(g||<||}|j|�dS)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.
  N)rN)r;rCr�r\r��
conditionsr2r2r3r@�sr@z\$\(([a-zA-Z_][a-zA-Z0-9_]*)\)cs�dg}|r|jd|i�t|d�}�fdd�}tjj�j�|�}xpt|�D]d}�|}xVt|j��D]F\}	}
t|
�|kr�|j||	g�qfx |
D]}|j|d|i|	g�q�WqfWqLW|gS)a�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.
  rr7r�csHt�}x<t��j��D](}|jt��fdd�tj|�D���qW|S)Ncs g|]}|�kr|�kr|�qSr2r2)rC�v)r�r;r2r3rE�sz>_GetMSBuildPropertyGroup.<locals>.GetEdges.<locals>.<listcomp>)r�r{r�r��MSVS_VARIABLE_REFERENCE�findall)r�Zedgesr\)r;)r�r3�GetEdges�s	(z*_GetMSBuildPropertyGroup.<locals>.GetEdgesr )	rNrMr�r�ZTopologicallySortedr�rjr{r�)r�Zlabelr;r.Znum_configurationsr\Zproperties_orderedr�r�r\rXrCr2)r;r3rA�s

 rAcCs�g}x�t|j��D]�\}}|d}ddt||�ig}xdt|j��D]T\}}|rB|rB|g}	x2t|j��D]"\}}
t|||
�}|	j||g�qfW|j|	�qBW|j|�qW|S)NrPr!r )r{r�r6rTrN)r�r��groupsr�r5rRr.rZrUrfr\rVr2r2r3�_GetMSBuildToolSettingsSections�s r^cCs|d|kr d}|d}tj|�nd}|jdi�}tj|�}t|�\}}}t|�}t|�}	t|dd�\}
}}t|�}
t	|�}|r�dd�|D�}dg}x.|D]&}|j|�}|r�t
d	|t|�f�q�Wd
d�|D�}t|�}|jd�}|jd�}t
|�}|jd
�}t|dd|�t|dd|�t|dd|�t|dd|�t|dd|	�|
�r\t||d|
dd�|
�rtt||d|
dd�t|dd|�t|dd|�t|dd|�|�r�tjj|�d}t|ddd�t|dd|�t|dd|g�nt|ddd�t|dd d!�|jd"��rt|d#d$d!�|d%d&k�r4t|d#d$d'�|�rHt|dd(|�||d)<|�rdt|d*d+|�|�rxt|d,d+|�dS)-NrRFTrG)rCcSsg|]}|dkr|�qS)z
_HAS_TR1=0r2)rCrDr2r2r3rE�sz,_FinalizeMSBuildSettings.<locals>.<listcomp>r�zXWarning: The automatic conversion to MSBuild does not handle %s.  Ignoring setting of %scSsg|]}t|��qSr2)r�)rCrDr2r2r3rEsrErFrr�rJr�r�rmr�rKrL)r]rOrMrNr�PrecompiledHeaderZUseZPrecompiledHeaderFilerPZNotUsingr`r2rrrQrar@rRrSrPZ
PreBuildEvent�CommandZPostBuildEvent)r�ZValidateMSBuildSettingsr&ZConvertToMSBuildSettingsrTrUrVrWr{rXr~rbrYrZr^rXr$r6r�)r�r5Z	convertedrRrGr\r]r^r_r`rarlrzrSrcZignored_settingsZignored_settingr\rdrerfrgrhr2r2r3�_FinalizeMSBuildSettings�s�







racCsvt|�tkrh|d
kr"|jd|�dgdgdgd�}||krN|||krNd	}nd
}|jdd�|D��}n
tj|�}|S)NrJrKr~�
DelayLoadDLLsrNrMz%%(%s))r�rmrsr�r�cSsg|]}tj|��qSr2)r�r)rCrDr2r2r3rE[sz0_GetValueFormattedForMSBuild.<locals>.<listcomp>)rJrKr~rbrNrM)rardrNr@r�r)rZr�r\�
exceptions�charrVr2r2r3rTEs$

rTcCsbg}xX|D]P}t|tj�r.|jt|j|��q
d|kr
tjj||�}tjj	|�s
|j
|�q
W|S)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.
  r5)r�rQrRr�r&rKr$r6r@r�rN)rSZroot_dirr4r9�	full_pathr2r2r3r&as

r&c	Cs�ddddddddg}i}	x|D]}
g|	|
<qWt||||	||||�g}x(|D] }
|	|
rN|jd	g|	|
�qNW|r�|jd	g|�|S)
NrAr�r�r�r+r�r�rr�)�_AddSources2rN)r�rSr�r�r��actions_spec�sources_handled_by_actionrIr]�grouped_sources�gr2r2r3�_GetMSBuildSourceszs


rkc
Cs�g}�x�|D�]�}	t|	tj�r8t||	j||||||�q|	|krg}
|j|	g�}t|�t|d�krt|
jddg�n4x2t|�D]&\}}
t	||
�}|
jdd|idg�q~Wx�|dj
�D]�\}}
|
jdd�}|dk�rt|�}|�stj
j|�\}}|dk�rdd	d
g}ndg}||	k�r8t	||
�}|
jdd|idg�q�x6|D].}|	j|��r>|
jddg�|
jd
dg��q>Wq�Wt|	||�\}}||j|d|	ig|
�qWdS)Nr�r�rRr rrz.cz.ccz.cppz.cxxr_ZCreaterPr�)r�rQrRrfrKr&rMrNr{r6r�rBr$r6r�rmr�)r�rSr�rir�r�rhrIr�r9ZdetailZexcluded_configurationsrnr5rCZprecompiled_sourcerr�r.r�r2r2r3rf�sL







rfc	Cs�g}|jr�dg}x�|jD]�}|j}tjj|j�d}tjj|j|�}dd|id|gddgg}xR|jj	di�j
�D]<}|j	d	d�r�|jd
dg�P|j	dd�rp|jd
dg�PqpW|j|�qW|j|�|S)
Nr�rZProjectReferencer�r�ZReferenceOutputAssemblyr2r�Z"msvs_use_library_dependency_inputsZUseLibraryDependencyInputsrRZ&msvs_2010_disable_uldi_when_referenced)r�rr$r6r�r�r�r!r�r&r�rN)	r
Z
referencesr.Z
dependencyrr.Z
relative_pathZproject_refrr2r2r3�_GetMSBuildProjectReferences�s*

rlc!Cs�|j}|d}tjj|j�\}}tjj|j�t|j�}tjj	||�}	tjj|j�d}
t
|||
�\}}i}
t�}t�}t�}i}|jdd�}|jd�s�t
||||||||
||�
n|jdg�}t|||d�t|||||||�\}}}|jd��st|
||j�t|
|�t||
�}t|||�}t||
�\}}t|jd|||�t||�}x|j�D]}t||��qXWdd	d
igg}dd	digg}dd	digg}dd	d
igg}dd	digg}dddigg}d	d|j�dd�g} | t|�7} | t|||j|�7} | |7} | t||j�7} |jd��r&| td�7} n| t|j�7} | |7} | |7} | t |�7} | t!|�7} | |7} | t"|||j�7} | t#||�7} | t$||||||||�7} | t%|�7} | |7} | |7} | t&|�7} |jd��r�| t'|�7} t(j)| |jddd�|S)Nr�rrTrr�z.filtersrGr�z,$(VCTargetsPath)\Microsoft.Cpp.Default.propsz$$(VCTargetsPath)\Microsoft.Cpp.propsz&$(VCTargetsPath)\Microsoft.Cpp.targetsz/$(VCTargetsPath)\BuildCustomizations\masm.propsz1$(VCTargetsPath)\BuildCustomizations\masm.targetsrr7Z
UserMacrosz3http://schemas.microsoft.com/developer/msbuild/2003�Build)r�r�ZDefaultTargetsrZ	v120_wp81)r�r)*r�r$r6r�r�r�rr:r r!r$r�r&rr�r%r)r*r�r��_GenerateActionsForMSBuildr�r&r�raZProjectVersionr9r<rrDrEr�_GetMSBuildExtensionsrIrWr^rkrl�_GetMSBuildExtensionTargets�!_GetMSBuildExternalBuilderTargetsr�r�)!r
r�rwrr�r�r.Zproject_file_namer/r0r2rSr�r�rrr�r�rIr�r3r�rgrhr4r5Zimport_default_sectionZimport_cpp_props_sectionZimport_cpp_targets_sectionZimport_masm_props_sectionZimport_masm_targets_sectionZ
macro_sectionr�r2r2r3r�s�







rcCs�t||ddddd�}dddig}|jdd|ig�t||ddddd�}ddd	ig}|jdd|ig�||g}|jd
�r�t||d
dddd�}dddig}|jdd|ig�|j|�|S)anReturn 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.
  rFr'r(rmZExecr`rZCleanrr�)r�rNr&)r�Z	build_cmdZbuild_targetZ	clean_cmdZclean_targetZtargetsZ
clcompile_cmdZclcompile_targetr2r2r3rqX
s&

rqcCs2dddig}x|D]}|jdd|ig�qW|gS)NrFr7ZExtensionSettingsrGr�)rN)rr�rHr2r2r3ro}
s
rocCs6dddig}x"t|�D]}|jdd|ig�qW|gS)NrFr7ZExtensionTargetsrGr�)r{rN)rZtargets_nodeZtargets_filer2r2r3rp�
srpc
Cs�t�}g}x�|j�D]�\}}t�}t�}g}g}	xd|D]\}
|jt|
d��|jt|
d��|j|
d�|
d}|
jdd�r�d|}|	j|�q6Wdj|�}d	jd
d�|	D��}
t|||||
|||�qW||fS)aYAdd 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�r�r�r�Zmsbuild_use_callTzcall z, and also z
cSsg|]}|d�qS)z,
if %errorlevel% neq 0 exit /b %errorlevel%r2)rCr�r2r2r3rE�
sz._GenerateActionsForMSBuild.<locals>.<listcomp>)rr�r�rNr&r@�_AddMSBuildAction)r�r�rhrgr�r�r�r�r�r�r�r�r�r�r2r2r3rn�
s6




rnc
s�tj|�}t���t|�}	t|�}
dj�fdd�|	D��}dj|
�}|j��dd�ig}|jddgd|gd	|gd
|gg�|r�|jd|g�|j|�dS)Nr�csg|]}|�kr|�qSr2r2)rCrD)r�r2r3rE�
sz%_AddMSBuildAction.<locals>.<listcomp>rr�ZFileTypeZDocumentr`r&r�ZAdditionalInputs)r�rrBrGr@r�r�rN)
r�r�r�r�r�r�rhrgr�Zinputs_arrayZ
outputs_arrayZadditional_inputsZaction_specr2)r�r3rr�
s 


rr)NNTN)F)F)�Z
__future__r�collectionsr�copyryr$r�r*r'r Z
gyp.commonr�Zgyp.easy_xmlr�Zgyp.generator.ninja�	generatorr�r�Zgyp.MSVSNewr�Zgyp.MSVSProjectrQZgyp.MSVSSettingsr�Zgyp.MSVSToolFiler�Zgyp.MSVSUserFiler7Zgyp.MSVSUtilr�Zgyp.MSVSVersionrzrrr+r�r�Z"generator_additional_path_sectionsZ+generator_additional_non_configuration_keysr�r�r#r"r4r>r:rBrGrPr^rXrhrkrprqr�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�rrrrr	rr9r"r#rTrVrUrWr{rXrYrZr�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�r�r�r�r�r�objectrrrrr5r6r9r<rDrErIrLrJrKr?rWr@rZrAr^rarTr&rkrfrlrrqrorprnrrr2r2r2r3�<module>sp








@K#&Q

/

#FW''6
'
10
Q''-5 &3=,
50
2]9v%2