Skip to content

Commit

Permalink
build: default Windows build to Visual Studio 2019
Browse files Browse the repository at this point in the history
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: #27214

PR-URL: #30022
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Beth Griggs <[email protected]>
  • Loading branch information
targos authored and MylesBorins committed Oct 23, 2019
1 parent e110d81 commit e04d058
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
9 changes: 5 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):

Expand Down
64 changes: 32 additions & 32 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -236,61 +236,61 @@ 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 2017
:vs-set-2017
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 "[15.0,16.0)"
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
@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 2017...
echo Looking for WiX installation for Visual Studio 2019...
if not exist "%WIX%\SDK\VS2017" (
echo Failed to find WiX install for Visual Studio 2017
echo VS2017 support for WiX is only present starting at version 3.11
goto msbuild-not-found
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 2017 Extension
goto msbuild-not-found
echo Failed to find the WiX Toolset Visual Studio 2019 Extension
goto vs-set-2017
)
)
@rem check if VS2017 is already setup, and for the requested arch
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2017
@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 errorlevel 1 goto vs-set-2017
if defined DEBUG_HELPER @ECHO ON
:found_vs2017
:found_vs2019
echo Found MSVS version %VisualStudioVersion%
set GYP_MSVS_VERSION=2017
set PLATFORM_TOOLSET=v141
set GYP_MSVS_VERSION=2019
set PLATFORM_TOOLSET=v142
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)"
@rem Look for Visual Studio 2017
:vs-set-2017
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
if defined msi (
echo Looking for WiX installation for Visual Studio 2019...
echo Looking for WiX installation for Visual Studio 2017...
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
echo Failed to find WiX install for Visual Studio 2017
echo VS2017 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
echo Failed to find the WiX Toolset Visual Studio 2017 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 check if VS2017 is already setup, and for the requested arch
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2017
@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
set "VSINSTALLDIR="
@rem prevent VsDevCmd.bat from changing the current working directory
Expand All @@ -300,10 +300,10 @@ echo calling: %vcvars_call%
call %vcvars_call%
if errorlevel 1 goto msbuild-not-found
if defined DEBUG_HELPER @ECHO ON
:found_vs2019
:found_vs2017
echo Found MSVS version %VisualStudioVersion%
set GYP_MSVS_VERSION=2019
set PLATFORM_TOOLSET=v142
set GYP_MSVS_VERSION=2017
set PLATFORM_TOOLSET=v141
goto msbuild-found

:msbuild-not-found
Expand Down

0 comments on commit e04d058

Please sign in to comment.