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/__pycache__/msvs_emulation.cpython-36.pyc
3

��S]���@s4dZddlZddlZddlZddlZddlZddlmZddlZ	ddl
Z	yeWnek
rhe
ZYnXejd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�ZGdd�de�Zdd�ZGdd�de�Zdadd�Zdd �Zd!d"�Z d#d$�Z!d%d&�Z"d'd(�Z#d)d*�Z$d+d,�Z%d-d.�Z&dS)/zg
This module helps emulate Visual Studio 2008 behavior on top of other
build systems, primarily ninja.
�N)�
OrderedSetz(\\*)"cCsP|jd�dks|jd�dkr(tjj|�}tjdd�|�}|jdd�}d|dS)	z�Quote a command line argument so that it appears as one argument when
  processed via cmd.exe and parsed by CommandLineToArgvW (as is typical for
  Windows programs).�/r�cSsd|jd�dS)N�rz\")�group)�mo�r�$/usr/lib/python3.6/msvs_emulation.py�<lambda>/sz!QuoteForRspFile.<locals>.<lambda>�%z%%�")�find�count�os�path�normpath�windows_quoter_regex�sub�replace)�argrrr	�QuoteForRspFiles
rcCst|sdS|djd�r@|djdd�\}}|dtjj|�}ntjj|d�}|ddjdd�|dd�D��S)	z6Process a list of arguments using QuoteCmdExeArgument.�rzcall � rcss|]}t|�VqdS)N)r)�.0rrrr	�	<genexpr>Msz$EncodeRspFileList.<locals>.<genexpr>N)�
startswith�splitrrr�join)�argsZcallZprogramrrr	�EncodeRspFileList@srcCs.|s|S|s|St|j|d�||dd��S)z�Given a list of dictionary keys |path| and a tree of dicts |root|, find
  value at path, or return |default| if any of the path doesn't exist.rrN)�_GenericRetrieve�get)�root�defaultrrrr	r Ps
r csB|dkr|St|tj�r6t|t�r6�fdd�|D�S�|SdS)zDAdd |prefix| to |element| or each subelement if element is iterable.Ncsg|]}�|�qSrr)r�e)�prefixrr	�
<listcomp>`sz_AddPrefix.<locals>.<listcomp>)�
isinstance�collections�Iterable�
basestring)�elementr%r)r%r	�
_AddPrefixZsr,cs\�dk	rX|dk	rXt��s�j�t|tj�rPt|t�rPtd�fdd�|D��}n�|�}|S)z�If |element| then remap it through |map|. If |element| is iterable then
  each item will be remapped. Any elements not found will be removed.Ncsg|]}�|��qSrr)r�elem)�maprr	r&msz _DoRemapping.<locals>.<listcomp>)�callabler!r'r(r)r*�filter)r+r.r)r.r	�_DoRemappingesr1cCsH|dk	r@|dk	r@t|tj�r4t|t�r4|j|�qD|j|�n|SdS)z�If |append| is None, simply return |element|. If |append| is not None,
  then add |element| to it, adding each item in |element| if it's a list or
  tuple.N)r'r(r)r*�extend�append)r3r+rrr	�_AppendOrReturnssr4cCs~ttd�rtjStjjd�}|stddddg}tj|tjtjd�}x2|j	�dj
�D]}d	|krR|jd
�dd}qRW|t_|S)
z�Try to find an installation location for the DirectX SDK. Check for the
  standard environment variable, and if that doesn't exist, try to find
  via the registry. May return None if not found in either location.�	dxsdk_dirZ	DXSDK_DIRzreg.exeZqueryzHKLM\Software\Microsoft\DirectXz/s)�stdout�stderrrZInstallPathz    ��\)�hasattr�_FindDirectXInstallationr5r�environr!�
subprocess�Popen�PIPE�communicate�
splitlinesr)r5�cmd�p�linerrr	r;�s
r;cCs^i}|j�r2|j�|d<tjj|j�d�d|d<t�}|r@|nd|d<tjjdd�|d<|S)	z�Get a dict of variables mapping internal VS macro names to their gyp
  equivalents. Returns all variables that are independent of the target.z$(VSInstallDir)ZVCr9z$(VCInstallDir)rz$(DXSDK_DIR)ZWDK_DIRz
$(WDK_DIR))ZPathrrrr;r<r!)�
vs_version�envr5rrr	�GetGlobalVSMacroEnv�srGcs�t|djdg���x,|dd�D]}|jdg�}�t|�@�q"W�sJdStt|���t�fdd��D��}tdd�|D��r�dSx6|D].}|jdg�}|r��fdd�|D�}||d<q�W|S)	z�Finds msvs_system_include_dirs that are common to all targets, removes
  them from all targets, and returns an OrderedSet containing them.r�msvs_system_include_dirsrNcsg|]}t|���qSr)�ExpandMacros)r�include)rFrr	r&�sz3ExtractSharedMSVSSystemIncludes.<locals>.<listcomp>cSsg|]}d|k�qS)�$r)rrJrrr	r&�scsg|]}|�kr|�qSrr)r�i)�all_system_includesrr	r&�s)rr!rG�GetVSVersion�any)�configs�generator_flags�config�system_includesZexpanded_system_includes�includesZnew_includesr)rMrFr	�ExtractSharedMSVSSystemIncludes�s$

rUc@sxeZdZdZdd�Zdd�ZdZdd�Zd[d	d
�Zdd�Zd
d�Z	Gdd�de
�Zdd�Zdd�Z
d\dd�Zd]dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dS)^�MsvsSettingsz�A class that understands the gyp 'msvs_...' values (especially the
  msvs_settings field). They largely correpond to the VS2008 IDE DOM. This
  class helps map those settings to command line options.c	Cs
||_t|�|_dtfdtfdtfdtfdtfdtfdtfdtfg}|d	}xJ|D]B\}}t||i�x,|j�D] \}}|j||��t	||�|<qpWqRW|jd
dg�|_
dd
g}	g}
x<|	D]4}x.|j�D]"}||kr�|
d||dfg7}
q�Wq�W|
�rtdj
|
���dS)N�msvs_configuration_attributes�
msvs_settingsrH�msvs_disabled_warnings�msvs_precompiled_header�msvs_precompiled_source�msvs_configuration_platform�msvs_target_platformZconfigurations�msvs_cygwin_dirs�.Z
msvs_prebuildZmsvs_postbuildz%s not supported (target %s).�target_name�
)�specrNrE�dict�list�str�setattr�itemsr!�getattrr^�values�	Exceptionr)�selfrbrQZsupported_fieldsrP�fieldr#Z
confignamerRZunsupported_fieldsZunsupportedrrr	�__init__�s4

 
zMsvsSettings.__init__cCs,|jjdd�}|r|Stjjj|jdd�S)z�Returns the extension for the target, with no leading dot.

    Uses 'product_extension' if specified, otherwise uses MSVS defaults based on
    the target type.
    Zproduct_extensionN�typer)rbr!�gypZMSVSUtilZTARGET_TYPE_EXT)rkZextrrr	�GetExtension�szMsvsSettings.GetExtensionNc	Cs�|j|�dkrdnd}|jjdd�|jjd|jd�}|rD|dnd}d	|j�}||}d
dd||d|jd||||tjj||�d
�}|jt|j	��|S)zUGet a dict of variables mapping internal VS macro names to their gyp
    equivalents.�x86�Win32�x64Zproduct_prefixrZproduct_namer`r9r_z${root}z	${source}z$!INTERMEDIATE_DIR)z$(InputName)z$(InputPath)z	$(IntDir)z
$(OutDir)\z$(PlatformName)z$(ProjectDir)\z$(ProjectName)z
$(TargetDir)\z$(TargetExt)z$(TargetFileName)z
$(TargetName)z
$(TargetPath))
�GetArchrbr!rprrr�updaterGrE)	rk�
base_to_buildrR�target_platformr`Z
target_dirZ
target_extZtarget_file_nameZreplacementsrrr	�
GetVSMacroEnv�s(zMsvsSettings.GetVSMacroEnvcCs|j||d�}t||�S)z4Convert from VS macro names to something equivalent.)rR)rxrI)rk�srvrRrFrrr	�ConvertVSMacrosszMsvsSettings.ConvertVSMacroscCsdd�|D�}dd�|D�S)z2Strip -l from library if it's specified with that.cSs&g|]}|jd�r|dd�n|�qS)z-lrN)r)r�librrr	r&sz0MsvsSettings.AdjustLibraries.<locals>.<listcomp>cSs&g|]}|j�jd�s|dn|�qS)z.lib)�lower�endswith)rr{rrr	r&sr)rkZ	librariesZlibsrrr	�AdjustLibrariesszMsvsSettings.AdjustLibrariescCs*t|||�}t||�}t||�}t||�S)aRetrieve a value from |field| at |path| or return |default|. If
    |append| is specified, and the item is found, it will be appended to that
    object instead of returned. If |map| is specified, results will be
    remapped through |map| before being returned or appended.)r r1r,r4)rkrlrr#r%r3r.�resultrrr	�_GetAndMunge s

zMsvsSettings._GetAndMungec@s eZdZddd�Zddd�ZdS)	zMsvsSettings._GetWrapperNcCs||_||_|g|_||_dS)N)�parentrl�	base_pathr3)rkr�rlr�r3rrr	rm+sz!MsvsSettings._GetWrapper.__init__rcCs$|jj|j|j|g|||j|d�S)N)r#r%r3r.)r�r�rlr�r3)rk�namer.r%r#rrr	�__call__0sz!MsvsSettings._GetWrapper.__call__)N)NrN)�__name__�
__module__�__qualname__rmr�rrrr	�_GetWrapper*s
r�cCs6|jj|d�}|jj|d�}|s$|}ddd�j|d�S)zrGet architecture based on msvs_configuration_platform and
    msvs_target_platform. Returns either 'x86' or 'x64'.rrqrs)rrrs)r\r!r])rkrRZconfiguration_platform�platformrrr	rt4s
zMsvsSettings.GetArchcCs\|jjdkr|S|j|�}|dkr6|jd�r6|d7}|dkrX|jd�rX|jdd�d}|S)z*Returns the target-specific configuration.i�rsZ_x64rq�_rr)rEZ
short_namertr}�rsplit)rkrR�archrrr	�
_TargetConfig>s
zMsvsSettings._TargetConfigrcCs|j|j||||||�S)z_GetAndMunge for msvs_settings.)r�rX)rkrrRr#r%r3r.rrr	�_SettingPszMsvsSettings._SettingcCs|j|j||||||�S)z/_GetAndMunge for msvs_configuration_attributes.)r�rW)rkrrRr#r%r3r.rrr	�
_ConfigAttribVszMsvsSettings._ConfigAttribcsB�j���|�j�}|j�jd�gd����fdd�|D�S)zyUpdates include_dirs to expand VS specific paths, and adds the system
    include dirs used for platform SDK and similar.�VCCLCompilerTool�AdditionalIncludeDirectories)r#csg|]}�j|�d��qS))rR)rz)rrC)rRrkrr	r&dsz2MsvsSettings.AdjustIncludeDirs.<locals>.<listcomp>)r�r�)r�rHr2r�)rkZinclude_dirsrRrTr)rRrkr	�AdjustIncludeDirs]s

zMsvsSettings.AdjustIncludeDirscsB�j���|�j�}|j�jd�gd����fdd�|D�S)z~Updates midl_include_dirs to expand VS specific paths, and adds the
    system include dirs used for platform SDK and similar.�
VCMIDLToolr�)r#csg|]}�j|�d��qS))rR)rz)rrC)rRrkrr	r&msz6MsvsSettings.AdjustMidlIncludeDirs.<locals>.<listcomp>)r�r�)r�rHr2r�)rkZmidl_include_dirsrRrTr)rRrkr	�AdjustMidlIncludeDirsfs

z"MsvsSettings.AdjustMidlIncludeDirscCs`|j|�}g}|jdg|�dkr*|jd
�|jdg|�dkrF|jd�|j|jd|gd	��|S)z`Returns the set of defines that are injected to the defines list based
    on other VS settings.ZCharacterSet�1�_UNICODE�UNICODE�2Z_MBCSr��PreprocessorDefinitions)r#)r�r�)r�r�)r�r�r2r3r�)rkrRZdefinesrrr	�GetComputedDefinesos


zMsvsSettings.GetComputedDefinescCs,|j|�}|jd|�}|r(||j|��}|S)zvGet the pdb file name that should be used for compiler invocations, or
    None if there's no explicit name specified.r��ProgramDataBaseFileName)r�r�)r�r�rz)rkrR�expand_specialZpdbnamerrr	�GetCompilerPdbName|s
zMsvsSettings.GetCompilerPdbNamecCs0|j|�}|jd|�}|r,||j||d��}|S)z]Gets the explicitly overriden map file name for a target or returns None
    if it's not set.�VCLinkerTool�MapFileName)rR)r�r�)r�r�rz)rkrRr��map_filerrr	�GetMapFileName�s

zMsvsSettings.GetMapFileNamecCsN|j|�}|jd}|dkr dnd}|j|df|�}|rJ||j||d��}|S)zcGets the explicitly overridden output name for a target or returns None
    if it's not overridden.rnZstatic_library�VCLibrarianToolr�Z
OutputFile)rR)r�rbr�rz)rkrRr�rnr"�output_filerrr	�
GetOutputName�s

zMsvsSettings.GetOutputNamecCsN|j|�}|jd|�}|jd|�}|dkrF|r@||j||d��S|SndSdS)	z�Gets the explicitly overridden pdb name for a target or returns
    default if it's not overridden, or if no pdb will be generated.r��ProgramDatabaseFile�GenerateDebugInformation�true)rRN)r�r�)r�r�)r�r�rz)rkrRr�r#r�Zgenerate_debug_inforrr	�
GetPDBName�s
zMsvsSettings.GetPDBNamecCs|j|�}|jd|�}|dkS)z\If NoImportLibrary: true, ninja will not expect the output to include
    an import library.�NoImportLibraryr�)r�)r�r�)rkrRZnoimplibrrr	�GetNoImportLibrary�s
zMsvsSettings.GetNoImportLibrarycCs0|j|�}g}|jd|�}|dkr,|jd�|S)z:Returns the flags that need to be added to ml invocations.�MASM�UseSafeExceptionHandlersr�z/safeseh)r�r�)r�r�r3)rkrRZasmflagsZsafesehrrr	�GetAsmflags�s

zMsvsSettings.GetAsmflagscCs~|j|�}g}|jdd�|j|D��|j||j|d|d�}|ddddd	d
�ddd�|d
dd�|ddd�|dddid�|dddid�|dddd�dd�|dddd�dd�|d d!d"d#�dd�|d$d%d&d'd(�d)d*d�|d+dd,d�d�|d-dd.id�|d/d0d�|d1dd2id�|d3dd4d5d6d
�d7d�|d8d9d:d;d<�d=d�|d>d?d@dA�d�|dBdCdDdA�d�|dEddFid�|dGdHdIdA�d�|dJd"dKddL�dMd�|dNdOdPdQdRd
�dSd�|dTdUdVd#�dWd�|dXddYid�|dZddd�d[d�|d\dd]id�|d^dd�|d_d`dadbdcddde�dfd�|jdgd�|jdm|gdi�D��|jjdjk�rl|jdk�dld�|D�}|S)nzCReturns the flags that need to be added to .c and .cc compilations.cSsg|]}d|�qS)z/wdr)r�wrrr	r&�sz*MsvsSettings.GetCflags.<locals>.<listcomp>r�)r3ZOptimization�dr�r��x)�0r�r��3z/O)r.r%r#ZInlineFunctionExpansionz/Ob)r%ZDisableSpecificWarningsz/wdZ
StringPoolingr�z/GF)r.ZEnableFiberSafeOptimizationsz/GTZOmitFramePointers�-r)�falser�z/Oy)r.r%ZEnableIntrinsicFunctionsz/OiZFavorSizeOrSpeed�try)r�r�ZFloatingPointModelZprecise�strictZfast)r�r�r�z/fp:r�ZCompileAsManagedz/clrZWholeProgramOptimizationz/GLZWarningLevelz/WZWarnAsErrorz/WXZCallingConvention�r�z�vz/GZDebugInformationFormat�7rL�I)r�r��4z/ZZRuntimeTypeInfoz/GRz/GR-)r�r�ZEnableFunctionLevelLinkingz/Gyz/Gy-ZMinimalRebuildz/GmZBufferSecurityCheckz/GSz/GS-ZBasicRuntimeChecks�u)r�r�r�z/RTCZRuntimeLibrary�TZTd�DZDdz/MZExceptionHandlingZsc�az/EHZDefaultCharIsUnsignedz/JZTreatWChar_tAsBuiltInTypez/Zc:wchar_tZ
EnablePREfastz/analyze�AdditionalOptionsZEnableEnhancedInstructionSetZSSEZSSE2ZAVXZIA32ZAVX2)r�r�r�r��5z/arch:cSsg|]}d|�qS)z/FIr)r�frrr	r&�s�ForcedIncludeFiles)r#g(@z/FScSsg|]}|jd�s|�qS)z/MP)r)rr�rrr	r&�s)r�r�)	r�r2rYr�rXr�rEZproject_versionr3)rkrRZcflagsZclrrr	�	GetCflags�s^


zMsvsSettings.GetCflagscCsl|j|�}|j|rhtjj|j|�d}t||�rh|j|}tjj|�d}d|d|d|dgSgS)zLGet the flags to be added to the cflags for precompiled header support.
    rz/Yuz/FIz/Fp${pchprefix}.z.pch)r�rZrr�splitextr[�_LanguageMatchesForPchr)rkrR�	extension�
source_extZpchZpchbaserrr	�_GetPchFlags�s



zMsvsSettings._GetPchFlagscCs|j|�}|j|d�S)z;Returns the flags that need to be added to .c compilations.z.c)r�r�)rkrRrrr	�
GetCflagsCs
zMsvsSettings.GetCflagsCcCs|j|�}dg|j|d�S)z<Returns the flags that need to be added to .cc compilations.z/TPz.cc)r�r�)rkrRrrr	�GetCflagsCCs
zMsvsSettings.GetCflagsCCcsB�j����j|df�gd�}���fdd�|D�}dd�|D�S)zPGet and normalize the list of paths in AdditionalLibraryDirectories
    setting.ZAdditionalLibraryDirectories)r#cs&g|]}tjj��j|�d����qS))rR)rrrrz)rrC)rR�gyp_to_build_pathrkrr	r&szAMsvsSettings._GetAdditionalLibraryDirectories.<locals>.<listcomp>cSsg|]}d|d�qS)z
/LIBPATH:"rr)rrCrrr	r&s)r�r�)rkr"rRr�Zlibpathsr)rRr�rkr	� _GetAdditionalLibraryDirectories
s


z-MsvsSettings._GetAdditionalLibraryDirectoriescCsl|j|�}g}|j||j|d|d�}|j|jd||��|dddid�|ddd	d
d�dd
�|d�|S)z8Returns the flags that need to be added to lib commands.r�)r3�LinkTimeCodeGenerationr�z/LTCG)r.�
TargetMachine�X86�X64�ARM)r��17r�z	/MACHINE:)r.r%r�)r�r�rXr2r�)rkrRr�Zlibflagsr{rrr	�GetLibFlagss

zMsvsSettings.GetLibFlagscCsX|j}|ddkrTdd�|jdg�D�}t|�dkr@||d	�St|�dkrTtd
��dS)
zDReturns the .def file from sources, if any.  Otherwise returns None.rn�shared_library�loadable_module�
executablecSsg|]}|j�jd�r|�qS)z.def)r|r})rryrrr	r&'sz+MsvsSettings.GetDefFile.<locals>.<listcomp>�sourcesrrzMultiple .def filesN)r�r�r�)rbr!�lenrj)rkr�rbZ	def_filesrrr	�
GetDefFile#szMsvsSettings.GetDefFilecCs |j|�}|r|jd|�dS)z�.def files get implicitly converted to a ModuleDefinitionFile for the
    linker in the VS generator. Emulate that behaviour here.z	/DEF:"%s"N)r�r3)rk�ldflagsr�Zdef_filerrr	�_GetDefFileAsLdflags/s
z!MsvsSettings._GetDefFileAsLdflagscCs0|j|�}|jd|�}|r,||j||d��}|S)z`Gets the explicitly overridden pgd name for a target or returns None
    if it's not overridden.r��ProfileGuidedDatabase)rR)r�r�)r�r�rz)rkrRr�r�rrr	�
GetPGDName6s
zMsvsSettings.GetPGDNamecCsx|j|�}g}|j||j|d|d�}	|j||�|	dddid�|	ddd	d
d�dd
�|j|jd||��|	ddd�|	ddddd�d�|j||�}
|
r�|jd|
�|j|||d�}|r�|jd|�|j	||�}|r�|jd|�|j
||�}
|	dd|
�rd|
ndid�|	dddid�|	d dd�|jd\|dd"�}|�rPd#|}|	d$d%|d&|d'�d(d
�|jd]|dd"�}|�r�|jd^|dd"�}|�r�d#|}|jd+||f�|	d,ddd'�d-d
�|	d.ddd'�d/d
�|	d0d1d�|	d2ddd'�d3d
�|	d4ddd'�d5d
�|	d6ddd'�d7d
�|	d8d9d:d'�d;d
�|	d<d=d�|	d>d?d@d'�d;d
�|	dAddBdCdDdE�dFd
�|	dGdHd�|	dIddJid�|	dKdLd�|	dMddNid�|	dOddd'�dPd
�|	dQdd�|j|�dRk�r�d}ndS}|	dTdddU�dV|dW�t
dXdY�|D���s|jd5�t
dZdY�|D���s2|jd7�t
d[dY�|D��}|j||||�oX||�\}}}|j|�|||fS)_zUReturns the flags that need to be added to link commands, and the
    manifest files.r�)r3r�r�z/DEBUG)r.r�r�r�r�)r�r�r�z	/MACHINE:)r.r%Z
DelayLoadDLLsz/DELAYLOAD:)r%ZTreatLinkerWarningAsErrorsz/WXrz:NO)r�r�)r%r.z/OUT:z.pdbz/PDB:z/PGD:ZGenerateMapFilez/MAP:z/MAPZ
MapExportsz/MAPINFO:EXPORTSr��MinimumRequiredVersion)r#�,Z	SubSystemz	CONSOLE%sz	WINDOWS%s)r�r�z/SUBSYSTEM:�StackReserveSize�StackCommitSizez/STACK:%s%sZTerminalServerAwarez/TSAWARE�LinkIncrementalz/INCREMENTALZBaseAddressz/BASE:ZFixedBaseAddressz/FIXEDZRandomizedBaseAddressz/DYNAMICBASEZDataExecutionPreventionz	/NXCOMPATZOptimizeReferencesZNOREFZREFz/OPT:ZForceSymbolReferencesz	/INCLUDE:ZEnableCOMDATFoldingZNOICFZICFr�z
:PGINSTRUMENTz:PGOPTIMIZEz	:PGUPDATE)r�r�r�r�z/LTCGZIgnoreDefaultLibraryNamesz/NODEFAULTLIB:ZResourceOnlyDLLz/NOENTRYZEntryPointSymbolz/ENTRY:ZProfilez/PROFILEZLargeAddressAwarez/LARGEADDRESSAWAREZAdditionalDependenciesrqNZImageHasSafeExceptionHandlers)r�r�z/SAFESEH)r.r%r#css|]}d|kp|dkVqdS)ZDYNAMICBASEz/FIXEDNr)r�flagrrr	r�sz*MsvsSettings.GetLdflags.<locals>.<genexpr>css|]}d|kVqdS)ZNXCOMPATNr)rr�rrr	r�scss|]}|jd�VqdS)z/DEF:N)r)rr�rrr	r�s)r�r�)r�r�)r�r�)r�r�rXr�r2r�r�r3r�r�r�r�rtrO�_GetLdManifestFlags)rkrRr�r�Zmanifest_base_name�output_nameZ
is_executable�	build_dirr�Zld�outZpdbZpgdr�Zminimum_required_versionZstack_reserve_sizeZstack_commit_sizeZsafeseh_defaultZ
have_def_fileZmanifest_flagsZintermediate_manifest�manifest_filesrrr	�
GetLdflagsAs�








zMsvsSettings.GetLdflagscCs&|jd|dd�}|dkr$dgggfS|d}dd|g}|jd	�|j|�}|jd|dd�}	g}
d}|	dkr�|jd|d
d�}dddd�}
|jd|dd�}d|
||f}nd}||}|d}tjj||�}tjj|�tjj	|�}|j
|�|j�|g}
|�r|jd�|
|j||�7}
|||
fS)ajReturns a 3-tuple:
    - the set of flags that need to be added to the link to generate
      a default manifest
    - the intermediate manifest that the linker will generate that should be
      used to assert it doesn't add anything to the merged one.
    - the list of all the manifest files to be merged by the manifest tool and
      included into the link.r��GenerateManifestr�)r#z/MANIFEST:NOz.intermediate.manifestz	/MANIFESTz/ManifestFile:z/MANIFESTUAC:NO�	EnableUACz�<?xml version='1.0' encoding='UTF-8' standalone='yes'?><assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>%s</assembly>�UACExecutionLevelr�Z	asInvokerZhighestAvailableZrequireAdministrator)r�r�r��UACUIAccessr�z�
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  <security>
    <requestedPrivileges>
      <requestedExecutionLevel level='%s' uiAccess='%s' />
    </requestedPrivileges>
  </security>
</trustInfo>rz.generated.manifestz/ALLOWISOLATION)r�r�)r�r�)r�r�)r�r�)
r�r3r�rrrro�commonZEnsureDirExistsZWriteOnDiff�write�close�_GetAdditionalManifestFiles)rkrRr�r�Zallow_isolationr�Zgenerate_manifestr��flagsZ
enable_uacr�Zgenerated_manifest_outerZexecution_levelZexecution_level_mapZ	ui_access�innerZgenerated_manifest_contentsZgenerated_nameZbuild_dir_generated_namer�rrr	r��sJ	



	

z MsvsSettings._GetLdManifestFlagscs:�jd�gd�}t|t�r$|jd�}���fdd�|D�S)z]Gets additional manifest files that are added to the default one
    generated by the linker.�VCManifestTool�AdditionalManifestFiles)r#�;cs&g|]}tjj��j|�d����qS))rR)rrrrz)rr�)rRr�rkrr	r&sz<MsvsSettings._GetAdditionalManifestFiles.<locals>.<listcomp>)r�r�)r�r'rer)rkrRr��filesr)rRr�rkr	r��s

z(MsvsSettings._GetAdditionalManifestFilescCs|j|�}|jd|�}|dkS)zzReturns whether the target should be linked via Use Library Dependency
    Inputs (using component .objs of a given .lib).r��UseLibraryDependencyInputsr�)r�r�)r�r�)rkrRZuldirrr	�IsUseLibraryDependencyInputss
z)MsvsSettings.IsUseLibraryDependencyInputscCs"|j|�}|jd|dd�}|dkS)z6Returns whether manifest should be linked into binary.r��
EmbedManifestr�)r#)r�r�)r�r�)rkrRZembedrrr	�IsEmbedManifests
zMsvsSettings.IsEmbedManifestcCs|j|�}|jd|�}|dkS)z:Returns whether the target should be linked incrementally.r�r�r�)r�r�)r�r�)rkrRZlink_incrrr	�IsLinkIncrementals
zMsvsSettings.IsLinkIncrementalcCsh|j|�}g}|j||j|d|d�}|d|dd�|jd|d��|ddd	�|d
ddd
�d�|S)zTReturns the flags that need to be added to invocations of the resource
    compiler.ZVCResourceCompilerTool)r3r�z/I)r.r%r_r�z/d)r%ZCulturez/lcSstt|��dd�S)Nr)�hex�int)r�rrr	r
'sz)MsvsSettings.GetRcflags.<locals>.<lambda>)r%r.)r�r�rXr3)rkrRZgyp_to_ninja_pathZrcflagsZrcrrr	�
GetRcflagss

zMsvsSettings.GetRcflagscCsjtjjtjj||jd��}d|jdd�}dd�|D�}dd�|D�}dj|�}d	|d
||f}|S)aOBuild a command line that runs args via cygwin bash. We assume that all
    incoming paths are in Windows normpath'd form, so they need to be
    converted to posix style for the part of the command line that's passed to
    bash. We also have to do some Visual Studio macro emulation here because
    various rules use magic VS names for things. Also note that rules that
    contain ninja variables cannot be fixed here (for example ${source}), so
    the outer generator needs to make sure that the paths that are written out
    are in posix style, if the command line will be used here.rzcd %sr9rcSs g|]}|jdd�jdd��qS)r9rrz\")r)rr�rrr	r&6sz;MsvsSettings.BuildCygwinBashCommandLine.<locals>.<listcomp>cSsg|]}d|jdd��qS)z'%s'�'z'\'')r)rr�rrr	r&7srz1call "%s\setup_env.bat" && set CYGWIN=nontsec && zbash -c "%s ; %s")rrrrr^r)rkrZpath_to_baseZ
cygwin_dirZcdZbash_cmdrBrrr	�BuildCygwinBashCommandLine*s	
z'MsvsSettings.BuildCygwinBashCommandLinecCst|jd|jjdd���dkS)zkDetermine if an action should be run under cygwin. If the variable is
    unset, or set to 1 we use cygwin.Zmsvs_cygwin_shellrr)rr!rb)rk�rulerrr	�IsRuleRunUnderCygwin>sz!MsvsSettings.IsRuleRunUnderCygwincCs*x$|jdg�D]}|d|krdSqWdS)zADetermine if there's an explicit rule for a particular extension.Zrulesr�TF)r!)rkrbr�rrrr	�_HasExplicitRuleForExtensionDsz)MsvsSettings._HasExplicitRuleForExtensioncCstdd�|jdg�D��S)z:Determine if an action should not run midl for .idl files.cSsg|]}|jdd��qS)Zexplicit_idl_actionr)r!)r�actionrrr	r&Msz7MsvsSettings._HasExplicitIdlActions.<locals>.<listcomp>Zactions)rOr!)rkrbrrr	�_HasExplicitIdlActionsKsz#MsvsSettings._HasExplicitIdlActionscCs|j|d�p|j|�S)z�Determine if there's an explicit rule or action for idl files. When
    there isn't we need to generate implicit rules to build MIDL .idl files.Zidl)rr)rkrbrrr	�HasExplicitIdlRulesOrActionsPsz)MsvsSettings.HasExplicitIdlRulesOrActionscCs|j|d�S)z�Determine if there's an explicit rule for asm files. When there isn't we
    need to generate implicit rules to assemble .asm files.Zasm)r)rkrbrrr	�HasExplicitAsmRulesVsz MsvsSettings.HasExplicitAsmRulescs��j����j��j�d��d���fdd�	}|ddd�}|dd	d�}|d
dd�}|dd
d�}|ddd�}|ddd�}	||||g}
d|fd|fd|fd|fd|fg}�j��dkr�dnd}ddd|dg}
|	|
||
fS)z�Determine the implicit outputs for an idl file. Returns output
    directory, outputs, and variables and flags that are required.r�Ncs�j�||d��d�S)N)r#)rR)rz)r�r#)rR�midl_getrkrr	�midl`sz*MsvsSettings.GetIdlBuildData.<locals>.midlZTypeLibraryNamez${root}.tlb)r#ZHeaderFileNamez	${root}.hZDLLDataFileNamez	dlldata.cZInterfaceIdentifierFileNamez${root}_i.cZ
ProxyFileNamez${root}_p.cZOutputDirectoryr�tlb�h�dlldata�iid�proxyrqZwin32rsz/charZsignedz/envz/Oicf)N)r�r�rXrt)rk�sourcerRrr
�headerrrrZoutdir�output�	variablesrwr�r)rRrrkr	�GetIdlBuildData[s$

zMsvsSettings.GetIdlBuildData)NN)NN)NrNN)NrNN)0r�r�r��__doc__rmrprxrzr~r��objectr�rtr�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�rrrrrr	r
rrrrr	rV�sX#






		

	
	6eWrVcCs(d}d}||kr||kp&||ko&||kS)N�.c�.cc�.cxx�.cpp)r)rrrr)r�Zpch_source_extZc_extsZcc_extsrrr	r�wsr�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�PrecompiledHeaderz�Helper to generate dependencies and build rules to handle generation of
  precompiled headers. Interface matches the GCH handler in xcode_emulation.py.
  c	CsJ||_||_|jj|j}||�|_tjj|�\}}|||�j�|_dS)N)	�settingsrRr[�
pch_sourcerrr�r|�
output_obj)	rkrrRr�Zgyp_to_unique_outputZobj_extr�filenamer�rrr	rm�s
zPrecompiledHeader.__init__cCs|jj|jS)zMGet the header that will appear in an #include line for all source
    files.)rrZrR)rkrrr	�
_PchHeader�szPrecompiledHeader._PchHeadercCs`|dkst�|j�sgStjj|j�d}x0|D](}ttjj|�d|�r0dd|jfgSq0WgS)aGiven a list of sources files and the corresponding object files,
    returns a list of the pch files that should be depended upon. The
    additional wrapping in the return value is for interface compatibility
    with make.py on Mac, and xcode_emulation.py.Nr)�AssertionErrorr"rrr�rr�r )rkr�Zobjsr�Zpch_extrrrr	�GetObjDependencies�s
z$PrecompiledHeader.GetObjDependenciescCsgS)z�Not used on Windows as there are no additional build steps required
    (instead, existing steps are modified in GetFlagsModifications below).r)rkr�rrr	�GetPchBuildCommands�sz%PrecompiledHeader.GetPchBuildCommandsc	Csj||jkr`d|j�g}|dkr<dt|||�fg|jgfS|dkr`dt|||�fg|jgfSg||fS)zgGet the modified cflags and implicit dependencies that should be used
    for the pch compilation step.z/YcZcxx�	cflags_ccZcc�cflags_c)rr"r.r )	rk�inputrZimplicitZcommandr'r&r�Z
pch_outputrrr	�GetFlagsModifications�s


z'PrecompiledHeader.GetFlagsModificationsN)	r�r�r�rrmr"r$r%r)rrrr	r~s	rcCs tstjj|jdd�dd�atS)N�msvs_version�autoF)Zallow_fallback)rEroZMSVSVersionZSelectVisualStudioVersionr!)rQrrr	rN�s

rNcCst|�}|j�S)N)rN�SetupScript)rQr��vsrrr	�_GetVsvarsSetupArgs�sr.cCs>d|kr:x0|j�D]$\}}d|ks*t|��|j||�}qW|S)z{Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv
  for the canonical way to retrieve a suitable dict.rKz$()rgr#r)�stringZ
expansions�old�newrrr	rI�s
rIc	Cs�d}i}|jd
�dkr"td|��xp|j�D]d}x^|D]V}tj|d
|j��r6|jd
d
�\}}|dkr~tjj	t
j�tj|}|||j
�<Pq6Wq,Wx dD]}||kr�td|��q�W|S)z{Extracts environment variables required for the toolchain to run from
  a textual dump output by the cmd.exe 'set' command.�goma_.*rJr{�libpathr�pathext�
systemroot�temp�tmp�=rz#Invalid output_of_set. Value is:
%sr�
SYSTEMROOT�TEMP�TMPz:Environment variable "%s" required to be set to valid path)	r2rJr{r3rr4r5r6r7)r9r:r;)rrjrA�re�matchr|rrr�dirname�sysr��pathsep�upper)Z
output_of_setZenvvars_to_saverFrDZenvvar�varZsettingZrequiredrrr	�_ExtractImportantEnvironment�s2


rCcCs>d}d}x(|j�D]\}}||d||7}qW||7}|S)z�Format as an 'environment block' directly suitable for CreateProcess.
  Briefly this is a list of key=value, terminated by an additional . See
  CreateProcess documentation for more details.r�r8)rg)Zenvvar_dict�blockZnul�key�valuerrr	�_FormatAsEnvironmentBlock�srHcCs8x2|j�j�D]"}|jd�r|td�d�j�SqWdS)z�Gets the path to cl.exe based on the output of calling the environment
  setup batch file, followed by the equivalent of `where`.zLOC:N)�striprArr�)Zoutput_of_whererDrrr	�_ExtractCLPath�s
rJc
CsFd}|jdd�r.i}x|D]}d||<qW|St|�}i}�x|D�]�}|j|�}|jd�tj|dtjtjd	�}	|	j�\}
}|	j	dkr�t
d
||	j	f��t|
�}|r�|t|jdd�j
d
��B}d
j|�|d<t|�}
|tjj|d|�d�}|j|
�|j�|j|�}|jd�tj|dtjd�}	|	j�\}}t|�||<qBW|S)a�It's not sufficient to have the absolute path to the compiler, linker,
  etc. on Windows, as those tools rely on .dlls being in the PATH. We also
  need to support both x86 and x64 compilers within the same build (to support
  msvs_target_platform hackery). Different architectures require a different
  compiler binary, and different supporting environment variables (INCLUDE,
  LIB, LIBPATH). So, we extract the environment here, wrap all invocations
  of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which
  sets up the environment, and then we do not prefix the compiler with
  an absolute path, instead preferring something like "cl.exe" in the rule
  which will then run whichever the environment setup has put in the path.
  When the following procedure to generate environment files does not
  meet your requirement (e.g. for custom toolchains), you can pass
  "-G ninja_use_custom_environment_files" to the gyp to suppress file
  generation and use custom environment files prepared by yourself.rqrsZ"ninja_use_custom_environment_filesrzcl.exe�&&�setT)�shellr6r7z"%s" failed with error %dZINCLUDErr�zenvironment.r��for�%i�in�(cl.exe)�do�@echo�
LOC:%~$PATH:i)rMr6)rqrs)rKrL)rKrNrOrPrQrRrSrT)r!rNr,r2r=r>r?ZSTDOUTr@�
returncoderjrCrrrrHrrr�r�rJ)Ztoplevel_build_dirrQrSZopen_outZarchsZcl_pathsr�r-r�popenrr�rFZ	env_blockr�rrrr	�GenerateEnvironmentFiless@





rWcsht|jdd��rdtdd�|�}��fdd�|D�}dd�|D�}|rddd�|D�}td	d
j|���dS)aeEmulate behavior of msvs_error_on_missing_sources present in the msvs
  generator: Check that all regular source files, i.e. not created at run time,
  exist on disk. Missing files cause needless recompilation when building via
  VS, and we want this check to match for people/bots that build using ninja,
  so they're not surprised when the VS build fails.Zmsvs_error_on_missing_sourcesrcSsd|kS)NrKr)r�rrr	r
>sz&VerifyMissingSources.<locals>.<lambda>csg|]}tjj��|���qSr)rrr)rry)r��gyp_to_ninjarr	r&?sz(VerifyMissingSources.<locals>.<listcomp>cSsg|]}tjj|�s|�qSr)rr�exists)rr�rrr	r&@scSsg|]}tjj|��qSr)rrr)rr�rrr	r&DszMissing input files:
%sraN)rr!r0rjr)r�r�rQrXZno_specialsZrelativeZmissingZ
cleaned_upr)r�rXr	�VerifyMissingSources7srZcCs^|jdi�}tjj|�}|j�|d<dtjjdd�ksHdtjjdd�krRd|d<nd	|d<dS)
NrQZMSVS_VERSIONZ64ZPROCESSOR_ARCHITECTURErZPROCESSOR_ARCHITEW6432�@ZMSVS_OS_BITS� )r!roZmsvs_emulationrNZ	ShortNamerr<)Zdefault_variablesZparamsrQr*rrr	�CalculateCommonVariablesIs
r])'rr(rr<r=r?Z
gyp.commonrZgyp.MSVSUtilroZgyp.MSVSVersionr*�	NameErrorre�compilerrrr r,r1r4r;rGrUrrVr�rrErNr.rIrCrHrJrWrZr]rrrr	�<module>sP

"
54	%7