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: //lib/python3.6/site-packages/gyp/__pycache__/win_tool.cpython-36.pyc
3

��S]64�@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ej
jej
je
��Zejdej�Zdd�ZGdd�de�Zed	kr�e	jee	jd
d���dS)zuUtility functions for Windows builds.

These functions are executed via gyp-win-tool when using the ninja generator.
�)�print_functionNz/OUT:(?P<out>.+)$cCs&t�}|j|�}|dk	r"tj|�dS)N)�WinTool�Dispatch�sys�exit)�args�executorZ	exit_code�r	�/usr/lib/python3.6/win_tool.py�mains
rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!rz�This class performs all the Windows tooling steps. The methods can either
  be executed directly, or dispatched from an argument list.cCs~t|�dkrtd��|ddkr$dSd}x<|D]4}tj|�}|r.tjddd|jd	�tj�f�}Pq.W|dkrrdS||d
<dS)zWAllows to use a unique instance of mspdbsrv.exe per linker instead of a
    shared one.�zNot enough argumentsrzlink.exeNz\W+�z%s_%d�outZ_MSPDBSRV_ENDPOINT_)	�len�	Exception�_LINK_EXE_OUT_ARG�match�re�sub�group�os�getpid)�self�envrZ
endpoint_name�arg�mr	r	r
�_UseSeparateMspdbsrv&s

zWinTool._UseSeparateMspdbsrvcCs<t|�dkrtd��d|j|d�}t||�|dd��S)z(Dispatches a string command to a method.rzNot enough argumentszExec%srN)rr�_CommandifyName�getattr)rr�methodr	r	r
rAszWinTool.DispatchcCs|j�jdd�S)z@Transforms a tool name like recursive-mirror to RecursiveMirror.�-r
)�title�replace)rZname_stringr	r	r
rIszWinTool._CommandifyNamecCs0t|�j�dd�jd�}dd�|D�}t|�S)z@Gets the saved environment from a file for a given architecture.N��cSsg|]}|jdd��qS)�=r)�split)�.0�itemr	r	r
�
<listcomp>Ssz#WinTool._GetEnv.<locals>.<listcomp>���)�open�readr&�dict)r�archZpairsZkvsr	r	r
�_GetEnvMszWinTool._GetEnvcCst|d�j�dS)zSimple stamp command.�wN)r+�close)r�pathr	r	r
�	ExecStampVszWinTool.ExecStampcCs�tjj|�rVtjj|�r0dd�}tj||d�n&tj|tj�sLtj|t	j
�tj|�tjj|�rptj||�ntj
||�dS)z)Emulation of rm -rf out && cp -af in out.cSs(tj|tj�stj|tj�||�dS)N)r�access�W_OK�chmod�stat�S_IWRITE)�fnr2Zexcinfor	r	r
�	_on_error^sz.WinTool.ExecRecursiveMirror.<locals>._on_error)�onerrorN)rr2�exists�isdir�shutilZrmtreer4r5r6r7r8�unlinkZcopytreeZcopy2)r�source�destr:r	r	r
�ExecRecursiveMirrorZs
zWinTool.ExecRecursiveMirrorc	Gs�|j|�}|dkr|j||�tjdkrDt|�}|djdd�|d<tj|tjdk|tjtj	d�}|j
�\}}x<|j�D]0}|jd�rx|jd�rx|jd	�rxt
|�qxW|jS)
z�Filter diagnostic output from link that looks like:
    '   Creating library ui.dll.lib and object ui.dll.exp'
    This happens when there are exports from the dll or exe.
    �TrueZwin32r�/�\)�shellr�stdout�stderrz   Creating library zGenerating codezFinished generating code)r/rr�platform�listr"�
subprocess�Popen�PIPE�STDOUT�communicate�
splitlines�
startswith�print�
returncode)	rr.Zuse_separate_mspdbsrvrr�linkr�_�liner	r	r
�ExecLinkWrapperps

	zWinTool.ExecLinkWrapperc	Gs6tj|||||||dj|	�d�	}
d}|	rbtjd|
�|dkrbtjd|
�tjd|
�d|
}tj||�|	�r2tjd	|
�d
|
}d|
}
t|
d��@}t|d��*}|j�jd
tj	�}|j�jd
tj	�}Wd
QRXWd
QRX||k�r2t
j|�dd�}||�||
�||�tjj
d||
|f�dSd
S)zZA wrapper for handling creating a manifest resource and then executing
    a link command.� )	�pythonr.r�ldcmd�resname�mt�rc�intermediate_manifest�	manifestsr
zn%(python)s gyp-win-tool manifest-wrapper %(arch)s %(mt)s -nologo -manifest %(manifests)s -out:%(out)s.manifestrCz`%(python)s gyp-win-tool manifest-to-rc %(arch)s %(out)s.manifest %(out)s.manifest.rc %(resname)szF%(python)s gyp-win-tool rc-wrapper %(arch)s %(rc)s %(out)s.manifest.rcz %(out)s.manifest.resz�%(python)s gyp-win-tool manifest-wrapper %(arch)s %(mt)s -nologo -manifest %(out)s.manifest %(intermediate_manifest)s -out:%(out)s.assert.manifestz%(out)s.assert.manifestz%(out)s.manifest�rNcSsVt|tjd�tdtjd�t|d��&}t|j�tjd�tdtjd�WdQRXdS)N)�filez-----r`)rRrrHr+r,)�filename�fr	r	r
�dump�s
z+WinTool.ExecLinkWithManifests.<locals>.dumpz�Linker generated manifest "%s" added to final manifest "%s" (result in "%s"). Were /MANIFEST switches used in #pragma statements? r)r�
executable�joinrKZ
check_callr+r,�	translate�stringZ
whitespacerr?rH�write)rr.Zembed_manifestrrZr[r\r]r^r_�	variablesZ	add_to_ldZassert_manifestZour_manifestZour_fZassert_fZour_dataZassert_datardr	r	r
�ExecLinkWithManifests�sV&

zWinTool.ExecLinkWithManifestscGsZ|j|�}tj|d|tjtjd�}|j�\}}x$|j�D]}|r8d|kr8t|�q8W|jS)z�Run manifest tool with environment set. Strip out undesirable warning
    (some XML blocks are recognized by the OS loader, but not the manifest
    tool).T)rFrrGrHz#manifest authoring warning 81010002)	r/rKrLrMrNrOrPrRrS)rr.rr�popenrrUrVr	r	r
�ExecManifestWrapper�s

zWinTool.ExecManifestWrapperc
GsF|\}}}t|d��(}|jd|tjj|�jdd�f�WdQRXdS)z�Creates a resource file pointing a SxS assembly manifest.
    |args| is tuple containing path to resource file, path to manifest file
    and resource name which can be "1" (for executables) or "2" (for DLLs).r0z(#include <windows.h>
%s RT_MANIFEST "%s"rErDN)r+rirr2�abspathr")rr.rZ
manifest_pathZ
resource_pathZ
resource_name�outputr	r	r
�ExecManifestToRc�s

zWinTool.ExecManifestToRcc	s�ddgt|	�d|d|d|d|d|d||g
}
|j|�}tj|
d	|tjtjd
�}|j�\}
}|
j�}d�t�fd
d�|D��}x(|D] }|j	��r�||kr�t
|�q�W|jS)zjFilter noisy filenames output from MIDL compile step that isn't
    quietable via command line flags.
    Zmidlz/nologoz/outz/tlbz/hz/dlldataz/iidz/proxyT)rFrrGrH�Processing �64 bit Processing c3s$|]}|j��rtjj|�VqdS)N)rQrr2�basename)r'�x)�prefixesr	r
�	<genexpr>	sz*WinTool.ExecMidlWrapper.<locals>.<genexpr>)rqrr)rJr/rKrLrMrNrOrP�setrQrRrS)rr.ZoutdirZtlb�hZdlldataZiid�proxyZidl�flagsrrrlrrU�linesZ
processingrVr	)rur
�ExecMidlWrapper�s(



zWinTool.ExecMidlWrappercGsv|j|�}tj|d|tjtjd�}|j�\}}x@|j�D]4}|jd�r8|jd�r8|jd�r8|r8t|�q8W|j	S)z/Filter logo banner from invocations of asm.exe.T)rFrrGrHz#Copyright (C) Microsoft CorporationzMicrosoft (R) Macro Assemblerz
 Assembling: )
r/rKrLrMrNrOrPrQrRrS)rr.rrrlrrUrVr	r	r
�ExecAsmWrappers

zWinTool.ExecAsmWrappercGsj|j|�}tj|d|tjtjd�}|j�\}}x4|j�D](}|jd�r8|jd�r8|r8t|�q8W|j	S)zgFilter logo banner from invocations of rc.exe. Older versions of RC
    don't support the /nologo flag.T)rFrrGrHz+Microsoft (R) Windows (R) Resource Compilerz#Copyright (C) Microsoft Corporation)
r/rKrLrMrNrOrPrQrRrS)rr.rrrlrrUrVr	r	r
�
ExecRcWrappers

zWinTool.ExecRcWrappercGs`|j|�}x&tjj�D]\}}||kr|||<qWt|�j�}|rJ|dnd}tj|d||d�S)z�Runs an action command line from a response file using the environment
    for |arch|. If |dir| is supplied, use that as the working directory.rNT)rFr�cwd)r/r�environ�itemsr+r,rK�call)rr.Zrspfile�dirr�k�vrr	r	r
�ExecActionWrapper,s
zWinTool.ExecActionWrappercsJtjj�t��|jd�}�fdd�|D�}dg}|j|�tj|dtd�S)zfExecuted by msvs-ninja projects when the 'ClCompile' target is used to
    build selected C/C++ files.�;csg|]}tjj�|�d�qS)z^^)rr2rf)r'rb)�project_dirr	r
r)>sz)WinTool.ExecClCompile.<locals>.<listcomp>z	ninja.exeT)rFr)rr2�relpath�BASE_DIRr&�extendrKr�)rr�Zselected_filesZ
ninja_targets�cmdr	)r�r
�
ExecClCompile9s


zWinTool.ExecClCompileN)�__name__�
__module__�__qualname__�__doc__rrrr/r3rBrWrkrmrpr|r}r~r�r�r	r	r	r
r"s 	N


r�__main__r)r�Z
__future__rrrr>rKr7rhrr2�dirnamern�__file__r��compile�
IGNORECASErr�objectrr�r�argvr	r	r	r
�<module>	s $