@@ -82,6 +82,7 @@ if /i "%1"=="x86" set target_arch=x86&goto arg-ok
8282if /i " %1 " == " x64" set target_arch = x64& goto arg-ok
8383if /i " %1 " == " arm64" set target_arch = arm64& goto arg-ok
8484if /i " %1 " == " vs2019" set target_env = vs2019& goto arg-ok
85+ if /i " %1 " == " vs2022" set target_env = vs2022& goto arg-ok
8586if /i " %1 " == " noprojgen" set noprojgen = 1& goto arg-ok
8687if /i " %1 " == " projgen" set projgen = 1& goto arg-ok
8788if /i " %1 " == " nobuild" set nobuild = 1& goto arg-ok
@@ -176,6 +177,7 @@ set "node_exe=%config%\node.exe"
176177set " node_gyp_exe = " %node_exe% " deps\npm\node_modules\node-gyp\bin\node-gyp"
177178set " npm_exe = " %~dp0 %node_exe% " %~dp0 deps\npm\bin\npm-cli.js"
178179if " %target_env% " == " vs2019" set " node_gyp_exe = %node_gyp_exe% --msvs_version=2019"
180+ if " %target_env% " == " vs2022" set " node_gyp_exe = %node_gyp_exe% --msvs_version=2022"
179181
180182:: skip building if the only argument received was lint
181183if " %* " == " lint" if exist " %node_exe% " goto lint-cpp
@@ -239,6 +241,46 @@ if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64
239241@ rem also if both are x86
240242if %target_arch% == x86 if %msvs_host_arch% == x86 set vcvarsall_arg = x86
241243
244+ @ rem Look for Visual Studio 2022
245+ :vs-set-2022
246+ if defined target_env if " %target_env% " NEQ " vs2022" goto vs-set-2019
247+ echo Looking for Visual Studio 2022
248+ @ rem VCINSTALLDIR may be set if run from a VS Command Prompt and needs to be
249+ @ rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
250+ @ rem detect the version searched for
251+ if not defined target_env set " VCINSTALLDIR = "
252+ call tools\msvs\vswhere_usability_wrapper.cmd " [17.0,18.0)" " prerelease"
253+ if " _%VCINSTALLDIR% _" == " __" goto vs-set-2019
254+ set " WIXSDKDIR = %WIX% \SDK\VS2017"
255+ if defined msi (
256+ echo Looking for WiX installation for Visual Studio 2022...
257+ if not exist " %WIXSDKDIR% " (
258+ echo Failed to find WiX install for Visual Studio 2022
259+ echo VS2022 support for WiX is only present starting at version 3.XX
260+ goto vs-set-2019
261+ )
262+ if not exist " %VCINSTALLDIR% \..\MSBuild\Microsoft\WiX" (
263+ echo Failed to find the WiX Toolset Visual Studio 2022 Extension
264+ goto vs-set-2019
265+ )
266+ )
267+ @ rem check if VS2022 is already setup, and for the requested arch
268+ if " _%VisualStudioVersion% _" == " _17.0_" if " _%VSCMD_ARG_TGT_ARCH% _" == " _%target_arch% _" goto found_vs2022
269+ @ rem need to clear VSINSTALLDIR for vcvarsall to work as expected
270+ set " VSINSTALLDIR = "
271+ @ rem prevent VsDevCmd.bat from changing the current working directory
272+ set " VSCMD_START_DIR = %CD% "
273+ set vcvars_call = " %VCINSTALLDIR% \Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
274+ echo calling: %vcvars_call%
275+ call %vcvars_call%
276+ if errorlevel 1 goto vs-set-2019
277+ if defined DEBUG_HELPER @ ECHO ON
278+ :found_vs2022
279+ echo Found MSVS version %VisualStudioVersion%
280+ set GYP_MSVS_VERSION = 2022
281+ set PLATFORM_TOOLSET = v143
282+ goto msbuild-found
283+
242284@ rem Look for Visual Studio 2019
243285:vs-set-2019
244286if defined target_env if " %target_env% " NEQ " vs2019" goto msbuild-not-found
@@ -691,7 +733,7 @@ set exit_code=1
691733goto exit
692734
693735:help
694- echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-benchmark/test-internet/test-pummel/test-simple/test-message/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2019] [download-all] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm]
736+ echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-benchmark/test-internet/test-pummel/test-simple/test-message/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2019/vs2022 ] [download-all] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm]
695737echo Examples:
696738echo vcbuild.bat : builds release build
697739echo vcbuild.bat debug : builds debug build
0 commit comments