mirror of https://github.com/nodejs/node.git
build,tools: support building with Visual Studio 2019
Add a `vs2019` option to `vcbuild.bat` to use VS 2019 instead of VS 2017 PR-URL: https://github.com/nodejs/node/pull/28781 Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com>pull/28878/head
parent
147b9d9792
commit
4e2d1a1433
|
@ -475,7 +475,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
|
|||
if version == 'auto':
|
||||
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
|
||||
version_map = {
|
||||
'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
|
||||
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
|
||||
'2005': ('8.0',),
|
||||
'2005e': ('8.0',),
|
||||
'2008': ('9.0',),
|
||||
|
@ -488,6 +488,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
|
|||
'2013e': ('12.0',),
|
||||
'2015': ('14.0',),
|
||||
'2017': ('15.0',),
|
||||
'2019': ('16.0',),
|
||||
}
|
||||
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
|
||||
if override_path:
|
||||
|
|
|
@ -15,7 +15,7 @@ where vswhere 2> nul > nul
|
|||
if errorlevel 1 goto :no-vswhere
|
||||
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
|
||||
set VSWHERE_PRP=-property installationPath
|
||||
set VSWHERE_LMT=-version "[15.0,16.0)"
|
||||
set VSWHERE_LMT=-version %1
|
||||
vswhere -prerelease > nul
|
||||
if not errorlevel 1 if "%VSWHERE_WITH_PRERELEASE%"=="1" set "VSWHERE_LMT=%VSWHERE_LMT% -prerelease"
|
||||
SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
|
||||
|
|
41
vcbuild.bat
41
vcbuild.bat
|
@ -74,6 +74,7 @@ if /i "%1"=="x86" set target_arch=x86&goto arg-ok
|
|||
if /i "%1"=="x64" set target_arch=x64&goto arg-ok
|
||||
if /i "%1"=="arm64" set target_arch=arm64&goto arg-ok
|
||||
if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok
|
||||
if /i "%1"=="vs2019" set target_env=vs2019&goto arg-ok
|
||||
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
|
||||
if /i "%1"=="projgen" set projgen=1&goto arg-ok
|
||||
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
|
||||
|
@ -174,6 +175,7 @@ set "node_exe=%config%\node.exe"
|
|||
set "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp"
|
||||
set "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js"
|
||||
if "%target_env%"=="vs2017" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2017"
|
||||
if "%target_env%"=="vs2019" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2019"
|
||||
|
||||
if "%config%"=="Debug" set configure_flags=%configure_flags% --debug
|
||||
if defined nosnapshot set configure_flags=%configure_flags% --without-snapshot
|
||||
|
@ -229,9 +231,9 @@ if %target_arch%==x86 if %msvs_host_arch%==x86 set vcvarsall_arg=x86
|
|||
|
||||
@rem Look for Visual Studio 2017
|
||||
:vs-set-2017
|
||||
if defined target_env if "%target_env%" NEQ "vs2017" goto msbuild-not-found
|
||||
if defined target_env if "%target_env%" NEQ "vs2017" goto vs-set-2019
|
||||
echo Looking for Visual Studio 2017
|
||||
call tools\msvs\vswhere_usability_wrapper.cmd
|
||||
call tools\msvs\vswhere_usability_wrapper.cmd "[15.0,16.0)"
|
||||
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
|
||||
if defined msi (
|
||||
echo Looking for WiX installation for Visual Studio 2017...
|
||||
|
@ -262,6 +264,41 @@ set GYP_MSVS_VERSION=2017
|
|||
set PLATFORM_TOOLSET=v141
|
||||
goto msbuild-found
|
||||
|
||||
@rem Look for Visual Studio 2019
|
||||
:vs-set-2019
|
||||
if defined target_env if "%target_env%" NEQ "vs2019" goto msbuild-not-found
|
||||
echo Looking for Visual Studio 2019
|
||||
call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)"
|
||||
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
|
||||
if defined msi (
|
||||
echo Looking for WiX installation for Visual Studio 2019...
|
||||
if not exist "%WIX%\SDK\VS2017" (
|
||||
echo Failed to find WiX install for Visual Studio 2019
|
||||
echo VS2019 support for WiX is only present starting at version 3.11
|
||||
goto msbuild-not-found
|
||||
)
|
||||
if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" (
|
||||
echo Failed to find the WiX Toolset Visual Studio 2019 Extension
|
||||
goto msbuild-not-found
|
||||
)
|
||||
)
|
||||
@rem check if VS2019 is already setup, and for the requested arch
|
||||
if "_%VisualStudioVersion%_" == "_16.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2019
|
||||
@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
|
||||
set "VSINSTALLDIR="
|
||||
@rem prevent VsDevCmd.bat from changing the current working directory
|
||||
set "VSCMD_START_DIR=%CD%"
|
||||
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
|
||||
echo calling: %vcvars_call%
|
||||
call %vcvars_call%
|
||||
if errorlevel 1 goto msbuild-not-found
|
||||
if defined DEBUG_HELPER @ECHO ON
|
||||
:found_vs2019
|
||||
echo Found MSVS version %VisualStudioVersion%
|
||||
set GYP_MSVS_VERSION=2019
|
||||
set PLATFORM_TOOLSET=v142
|
||||
goto msbuild-found
|
||||
|
||||
:msbuild-not-found
|
||||
echo Failed to find a suitable Visual Studio installation.
|
||||
echo Try to run in a "Developer Command Prompt" or consult
|
||||
|
|
Loading…
Reference in New Issue