Rac@sdZddlZddlZddlZddlZddlZddlZddlZdefdYZ dZ ddZ dZ dZed Zd Zd Zd ed ZdS(s3Handle version information related to Visual Stuio.iNtVisualStudioVersioncBs}eZdZd dZdZdZdZdZdZ dZ dZ d Z d Z d Zd ZRS(s1Information regarding a version of Visual Studio.c CsU||_||_||_||_||_||_||_||_| |_dS(N( t short_namet descriptiontsolution_versiontproject_versiontflat_slnt uses_vcxprojtpatht sdk_basedtdefault_toolset( tselfRRRRRRRRR ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt__init__s        cCs|jS(N(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt ShortName scCs|jS(s(Get the full description of the version.(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt Description#scCs|jS(s(Get the version number of the sln files.(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytSolutionVersion'scCs|jS(s6Get the version number of the vcproj or vcxproj files.(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytProjectVersion+scCs|jS(N(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt FlatSolution/scCs|jS(s1Returns true if this version uses a vcxproj file.(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt UsesVcxproj2scCs|jrdpdS(s+Returns the file extension for the project.s.vcxprojs.vcproj(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytProjectExtension6scCs|jS(s/Returns the path to Visual Studio installation.(R(R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytPath:scCs%tjjtjj|jd|S(s+Returns the path to a given compiler tool. sVC/bin(tosRtnormpathtjoin(R ttool((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytToolPath>scCs|jS(s\Returns the msbuild toolset version that will be used in the absence of a user override.(R (R ((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytDefaultToolsetBscCs|dksttjjd}|jr\|r\tjjtjj|dd|gS|dkr|jdkr|jddkrtjjd d kstjjd d krtjjtjj|jd d gStjjtjj|jdgS|dkstd}|jddkrktjjd d ksbtjjd d krkd}ntjjtjj|jd |gSdS(sLReturns a command (with arguments) to be used to set up the environment.tx86tx64t WindowsSDKDirsBin/SetEnv.Cmdt/t2013itetPROCESSOR_ARCHITECTUREtAMD64tPROCESSOR_ARCHITEW6432sVC/vcvarsall.batt amd64_x86sCommon7/Tools/vsvars32.batt x86_amd64tamd64N(RR( tAssertionErrorRtenvirontgetRRRRR(R t target_archtsdk_dirtarg((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt SetupScriptGs*  "    N(t__name__t __module__t__doc__tNoneR R R RRRRRRRRR,(((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyRs          cCstjd krd Stjjtjjdd|dd|g}|r_|jd|gnt j |dt j d t j }|j d }|j rd S|S( sUse reg.exe to read a particular key. While ideally we might use the win32 module, we would like gyp to be python neutral, so for instance cygwin python lacks this module. Arguments: sysdir: The system subdirectory to attempt to launch reg.exe from. key: The registry key to read from. value: The particular value to read. Return: stdout from reg.exe, or None for failure. twin32tcygwintWINDIRtsreg.exetquerys/vtstdouttstderri(R1R2N(tsystplatformR0RRRR'R(textendt subprocesstPopentPIPEt communicatet returncode(tsysdirtkeytvaluetcmdtpttext((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt_RegistryQueryBasens$ ! cCs`d}ytd||}Wn=tk r[}|jtjkrUtd||}q\nX|S(sUse reg.exe to read a particular key through _RegistryQueryBase. First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If that fails, it falls back to System32. Sysnative is available on Vista and up and available on Windows Server 2003 and XP through KB patch 942589. Note that Sysnative will always fail if using 64-bit python due to it being a virtual directory and System32 will work correctly in the first place. KB 942589 - http://support.microsoft.com/kb/942589/en-us. Arguments: key: The registry key. value: The particular registry value to read (optional). Return: stdout from reg.exe, or None for failure. t SysnativetSystem32N(R0RFtOSErrorterrnotENOENT(RARBRER((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt_RegistryQueryscCsy ddlm}m}m}Wn-tk rOddlm}m}m}nXyW|jdd\}}|dks}t|||}|||dSWdQXWntk rdSXdS(sUse the _winreg module to obtain the value of a registry key. Args: key: The registry key. value: The particular registry value to read. Return: contents of the registry key's value, or None on failure. Throws ImportError if _winreg is unavailable. i(tHKEY_LOCAL_MACHINEtOpenKeyt QueryValueExs\itHKLMiN( t_winregRMRNROt ImportErrortwinregtsplitR&t WindowsErrorR0(RARBRMRNROtroottsubkeythkey((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt_RegistryGetValueUsingWinRegs     cCsgyt||SWntk r$nXt||}|s>dStjd|}|sZdS|jdS(sUse _winreg or reg.exe to obtain the value of a registry key. Using _winreg is preferable because it solves an issue on some corporate environments where access to reg.exe is locked down. However, we still need to fallback to reg.exe for the case where the _winreg module is not available (for example in cygwin python). Args: key: The registry key. value: The particular registry value to read. Return: contents of the registry key's value, or None on failure. sREG_\w+\s+([^\r]+)\r\niN(RYRRRLR0tretsearchtgroup(RARBREtmatch((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt_RegistryGetValues cCs|rtjj|}ni tdddddddtdtd |d |d d d6td ddddddtdtd |d |d dd 6tdddddddtdtd |d |d dd6tdddddddtdtd |d |d dd6tdddddddtdtd |d |d dd6tdddddddtdtd |d |d6tdddddddtdtd |d |d6tdddddd dtdtd |d |d6td!ddddd dtdtd |d |d!6td"d#dd dd$dtdtd |d |d"6td%d#dd dd$dtdtd |d |d%6}|t|S(&sSets up MSVS project generation. Setup is based off the GYP_MSVS_VERSION environment variable or whatever is autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is passed in that doesn't match a value in versions python will throw a error. t2015sVisual Studio 2015Rs12.00Rs14.0RRRRR tv140RsVisual Studio 2013s13.00s12.0tv120t2013et2012sVisual Studio 2012s4.0tv110t2012et2010sVisual Studio 2010s11.00t2010esVisual C++ Express 2010t2008sVisual Studio 2008s10.00s9.00t2008et2005sVisual Studio 2005s8.00t2005e(RRRRtFalsetTruetstr(tnameRRtversions((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt_CreateVersions           cCsJtjdkrFtjd|gdtj}|jdj}n|S(s.Convert to cygwin path if we are using cygwin.R2tcygpathR6i(R8R9R;R<R=R>tstrip(RRD((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt_ConvertToCygpathLsc Csidd6dd6dd6dd6d d 6d d 6}g}x|D]}d |d|d|d|g}xtt|D]}t||d}|sqxnt|}tjj|d}tjj|d} | rtjj|r|jt ||tjj|ddqxt j | rx|jt ||dtjj|ddqxqxWddg}xtt|D]s}t|||}|sqnt|}|d kr|jt ||dtjj|ddt qqWq=W|S(sWCollect the list of installed visual studio versions. Returns: A list of visual studio versions installed in descending order of usage preference. Base this on the registry and a quick check if devenv.exe exists. Only versions 8-10 are considered. Possibilities are: 2005(e) - Visual Studio 2005 (8) 2008(e) - Visual Studio 2008 (9) 2010(e) - Visual Studio 2010 (10) 2012(e) - Visual Studio 2012 (11) 2013(e) - Visual Studio 2013 (12) 2015 - Visual Studio 2015 (14) Where (e) is e for express editions of MSVS and blank otherwise. Rjs8.0Rhs9.0Rfs10.0Rcs11.0Rs12.0R_s14.0s'HKLM\Software\Microsoft\VisualStudio\%ss3HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%ss$HKLM\Software\Microsoft\VCExpress\%ss0HKLM\Software\Wow6432Node\Microsoft\VCExpress\%st InstallDirs devenv.exes *express.exes..Rs,HKLM\Software\Microsoft\VisualStudio\SxS\VC7s8HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7R( trangetlenR^RtRRRtexiststappendRqtglobRm( tversions_to_checkt force_expresstversion_to_yearRptversiontkeystindexRt full_patht express_path((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyt_DetectVisualStudioVersionsTsJ    #   *tautocCsA|dkr$tjjdd}ni dd6dd 6dd 6dd 6dd 6dd 6d d6d!d6d"d6d#d6d$d6d%d6}tjjd}|rtjjd}|stdnt||dtSt|}t||d|k}|s9|stdn|dkr)td d&St|d&Sn|dS('sSelect which version of Visual Studio projects to generate. Arguments: version: Hook to allow caller to force a particular version (vs auto). Returns: An object representing a visual studio project format version. RtGYP_MSVS_VERSIONs14.0s12.0s10.0s9.0s8.0s11.0RjRkRhRiRfRgRcReRRbR_tGYP_MSVS_OVERRIDE_PATHs`GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be set to a particular version (e.g. 2010e).RRs,Could not locate Visual Studio installation.i(s14.0s12.0s10.0s9.0s8.0s11.0(s8.0(s8.0(s9.0(s9.0(s10.0(s10.0(s11.0(s11.0(s12.0(s12.0(s14.0N( RR'R(t ValueErrorRqRmRnRR0(R~tallow_fallbackt version_mapt override_patht msvs_versionRp((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytSelectVisualStudioVersions<     (R/RJRRZR;R8tgypRztobjectRRFR0RLRYR^RlRqRtRRmR(((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyts        ^     k  C