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.pytDefaultToolsetBscCsstjjd}|jrJ|rJtjjtjj|dd|gS|dkr|jdkr|jddkrtjjdd kstjjd d krtjjtjj|jd d gStjjtjj|jd gSd}|jddkrGtjjdd ks>tjjd d krGd}ntjjtjj|jd |gSdS(sLReturns a command (with arguments) to be used to set up the environment.t WindowsSDKDirsBin/SetEnv.Cmdt/tx86t2013itetPROCESSOR_ARCHITECTUREtAMD64tPROCESSOR_ARCHITEW6432sVC/vcvarsall.batt amd64_x86sCommon7/Tools/vsvars32.batt x86_amd64tamd64N(RtenvirontgetRRRRR(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(R/R0N(tsystplatformR.RRRR%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(R.RDtOSErrorterrnotENOENT(R?R@RCR((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}nXyE|jdd\}}|||}|||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\iiN( t_winregRKRLRMt ImportErrortwinregtsplitt WindowsErrorR.(R?R@RKRLRMtroottsubkeythkey((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(RVRORJR.tretsearchtgroup(R?R@RCtmatch((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.R0tcygpathR4i(R6R7R9R:R;R<tstrip(RRB((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. Rgs8.0Res9.0Rcs10.0R`s11.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[RqRRRtexiststappendRntglobRj( tversions_to_checkt force_expresstversion_to_yearRmtversiontkeystindexRt 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.0RgRhReRfRcRdR`RbRR_R\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 ValueErrorRnRjRkRR.(R{tallow_fallbackt version_mapt override_patht msvs_versionRm((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pytSelectVisualStudioVersions<     (R-RHRRWR9R6tgypRwtobjectRRDR.RJRVR[RiRnRqRRjR(((sm/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/pylib/gyp/MSVSVersion.pyts        ^     k  C