From b554214249b4d03ca68f98f2a2715511a7049397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 18 Oct 2019 11:04:35 +0200 Subject: [PATCH] build: default Windows build to Visual Studio 2019 Building and testing Node.js with Visual Studio 2019 is now working as expected. Fallback to VS 2017 if VS 2019 was not found. Fixes: https://github.com/nodejs/node/issues/27214 PR-URL: https://github.com/nodejs/node/pull/30022 Reviewed-By: Jiawen Geng Reviewed-By: Richard Lau Reviewed-By: Beth Griggs --- BUILDING.md | 9 ++++--- vcbuild.bat | 72 ++++++++++++++++++++++++++--------------------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index aadba460200..006c21521df 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -498,9 +498,9 @@ $ backtrace * [Python 2.7](https://www.python.org/downloads/) * The "Desktop development with C++" workload from - [Visual Studio 2017](https://www.visualstudio.com/downloads/) or the - "Visual C++ build tools" workload from the - [Build Tools](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017), + [Visual Studio 2017 or 2019](https://visualstudio.microsoft.com/downloads/) or + the "Visual C++ build tools" workload from the + [Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019), with the default optional components. * Basic Unix tools required for some tests, [Git for Windows](https://git-scm.com/download/win) includes Git Bash @@ -513,7 +513,8 @@ $ backtrace Optional requirements to build the MSI installer package: * The [WiX Toolset v3.11](https://wixtoolset.org/releases/) and the - [Wix Toolset Visual Studio 2017 Extension](https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension). + [Wix Toolset Visual Studio 2017 Extension](https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension) + or the [Wix Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension). Optional requirements for compiling for Windows 10 on ARM (ARM64): diff --git a/vcbuild.bat b/vcbuild.bat index 7613bd8b5ab..5ddc04aeb25 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -236,9 +236,44 @@ if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64 @rem also if both are x86 if %target_arch%==x86 if %msvs_host_arch%==x86 set vcvarsall_arg=x86 +@rem Look for Visual Studio 2019 +:vs-set-2019 +if defined target_env if "%target_env%" NEQ "vs2019" goto vs-set-2017 +echo Looking for Visual Studio 2019 +call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)" +if "_%VCINSTALLDIR%_" == "__" goto vs-set-2017 +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 vs-set-2017 + ) + if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" ( + echo Failed to find the WiX Toolset Visual Studio 2019 Extension + goto vs-set-2017 + ) +) +@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 vs-set-2017 +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 + @rem Look for Visual Studio 2017 :vs-set-2017 -if defined target_env if "%target_env%" NEQ "vs2017" goto vs-set-2019 +if defined target_env if "%target_env%" NEQ "vs2017" goto msbuild-not-found echo Looking for Visual Studio 2017 call tools\msvs\vswhere_usability_wrapper.cmd "[15.0,16.0)" if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found @@ -271,41 +306,6 @@ 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