Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 82f263d

Browse filesBrowse files
committed
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: #28781 Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com>
1 parent cf071a0 commit 82f263d
Copy full SHA for 82f263d

File tree

Expand file treeCollapse file tree

3 files changed

+42
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+42
-4
lines changed
Open diff view settings
Collapse file

‎tools/gyp/pylib/gyp/MSVSVersion.py‎

Copy file name to clipboardExpand all lines: tools/gyp/pylib/gyp/MSVSVersion.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
475475
if version == 'auto':
476476
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
477477
version_map = {
478-
'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
478+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
479479
'2005': ('8.0',),
480480
'2005e': ('8.0',),
481481
'2008': ('9.0',),
@@ -488,6 +488,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
488488
'2013e': ('12.0',),
489489
'2015': ('14.0',),
490490
'2017': ('15.0',),
491+
'2019': ('16.0',),
491492
}
492493
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
493494
if override_path:
Collapse file

‎tools/msvs/vswhere_usability_wrapper.cmd‎

Copy file name to clipboardExpand all lines: tools/msvs/vswhere_usability_wrapper.cmd
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ where vswhere 2> nul > nul
1515
if errorlevel 1 goto :no-vswhere
1616
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
1717
set VSWHERE_PRP=-property installationPath
18-
set VSWHERE_LMT=-version "[15.0,16.0)"
18+
set VSWHERE_LMT=-version %1
1919
vswhere -prerelease > nul
2020
if not errorlevel 1 if "%VSWHERE_WITH_PRERELEASE%"=="1" set "VSWHERE_LMT=%VSWHERE_LMT% -prerelease"
2121
SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
Collapse file

‎vcbuild.bat‎

Copy file name to clipboardExpand all lines: vcbuild.bat
+39-2Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ if /i "%1"=="x86" set target_arch=x86&goto arg-ok
7474
if /i "%1"=="x64" set target_arch=x64&goto arg-ok
7575
if /i "%1"=="arm64" set target_arch=arm64&goto arg-ok
7676
if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok
77+
if /i "%1"=="vs2019" set target_env=vs2019&goto arg-ok
7778
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
7879
if /i "%1"=="projgen" set projgen=1&goto arg-ok
7980
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
@@ -174,6 +175,7 @@ set "node_exe=%config%\node.exe"
174175
set "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp"
175176
set "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js"
176177
if "%target_env%"=="vs2017" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2017"
178+
if "%target_env%"=="vs2019" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2019"
177179

178180
if "%config%"=="Debug" set configure_flags=%configure_flags% --debug
179181
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
229231

230232
@rem Look for Visual Studio 2017
231233
:vs-set-2017
232-
if defined target_env if "%target_env%" NEQ "vs2017" goto msbuild-not-found
234+
if defined target_env if "%target_env%" NEQ "vs2017" goto vs-set-2019
233235
echo Looking for Visual Studio 2017
234-
call tools\msvs\vswhere_usability_wrapper.cmd
236+
call tools\msvs\vswhere_usability_wrapper.cmd "[15.0,16.0)"
235237
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
236238
if defined msi (
237239
echo Looking for WiX installation for Visual Studio 2017...
@@ -262,6 +264,41 @@ set GYP_MSVS_VERSION=2017
262264
set PLATFORM_TOOLSET=v141
263265
goto msbuild-found
264266

267+
@rem Look for Visual Studio 2019
268+
:vs-set-2019
269+
if defined target_env if "%target_env%" NEQ "vs2019" goto msbuild-not-found
270+
echo Looking for Visual Studio 2019
271+
call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)"
272+
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
273+
if defined msi (
274+
echo Looking for WiX installation for Visual Studio 2019...
275+
if not exist "%WIX%\SDK\VS2017" (
276+
echo Failed to find WiX install for Visual Studio 2019
277+
echo VS2019 support for WiX is only present starting at version 3.11
278+
goto msbuild-not-found
279+
)
280+
if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" (
281+
echo Failed to find the WiX Toolset Visual Studio 2019 Extension
282+
goto msbuild-not-found
283+
)
284+
)
285+
@rem check if VS2019 is already setup, and for the requested arch
286+
if "_%VisualStudioVersion%_" == "_16.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2019
287+
@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
288+
set "VSINSTALLDIR="
289+
@rem prevent VsDevCmd.bat from changing the current working directory
290+
set "VSCMD_START_DIR=%CD%"
291+
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
292+
echo calling: %vcvars_call%
293+
call %vcvars_call%
294+
if errorlevel 1 goto msbuild-not-found
295+
if defined DEBUG_HELPER @ECHO ON
296+
:found_vs2019
297+
echo Found MSVS version %VisualStudioVersion%
298+
set GYP_MSVS_VERSION=2019
299+
set PLATFORM_TOOLSET=v142
300+
goto msbuild-found
301+
265302
:msbuild-not-found
266303
echo Failed to find a suitable Visual Studio installation.
267304
echo Try to run in a "Developer Command Prompt" or consult

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.