Updated build.bat to recognize Visual Studio 2019 installations. Still not supporting MSVC 2019

This commit is contained in:
klayoutmatthias 2021-07-10 17:59:05 +02:00
parent bad3232415
commit 7031c6faf4
1 changed files with 19 additions and 9 deletions

View File

@ -126,31 +126,41 @@ echo Analysing installation ...
echo. echo.
rem ---------------------------------------------------------- rem ----------------------------------------------------------
rem locate MSVC 2017 on the system rem locate MSVC on the system
set MSVC2017_COMPILER_INST=notfound set MSVC_COMPILER_INST=notfound
rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there. rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there.
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32 >nul 2>nul reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32 >nul 2>nul
if NOT ERRORLEVEL 1 ( if NOT ERRORLEVEL 1 (
for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') DO ( for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') do (
if "%%i"=="15.0" ( if "%%i"=="15.0" (
if exist "%%k\VC\Auxiliary\Build" ( if exist "%%k\VC\Auxiliary\Build" (
set "MSVC2017_COMPILER_INST=%%k\VC\Auxiliary\Build" set "MSVC_COMPILER_INST=%%k\VC\Auxiliary\Build"
set "msg=Found MSVC installation at !MSVC2017_COMPILER_INST!" set "msg=Found MSVC installation at !MSVC_COMPILER_INST!"
echo !msg! echo !msg!
) )
) )
) )
) )
if "%MSVC2017_COMPILER_INST%" == "notfound" ( rem alternative way (VS2019)
echo ERROR: Unable to find MSVC 2017 installation if "%MSVC_COMPILER_INST%" == "notfound" (
set vs_path=notfound
for /f "delims=" %%i in ('"c:\program files (x86)\microsoft visual studio\installer\vswhere" -latest -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -products *') do (
set "vs_path=%%i"
)
if not "vs_path" == "notfound" (
set "MSVC_COMPILER_INST=!vs_path!\vc\Auxiliary\Build"
)
)
if "%MSVC_COMPILER_INST%" == "notfound" (
echo ERROR: Unable to find MSVC installation
goto :eof goto :eof
) )
if %arch% equ x64 ( if %arch% equ x64 (
call "%MSVC2017_COMPILER_INST%\vcvars64" call "%MSVC_COMPILER_INST%\vcvars64"
) else ( ) else (
call "%MSVC2017_COMPILER_INST%\vcvars32" call "%MSVC_COMPILER_INST%\vcvars32"
) )
rem ---------------------------------------------------------- rem ----------------------------------------------------------