2017-04-07 12:53:45 +00:00
|
|
|
:: Copyright 2017 - Refael Ackermann
|
|
|
|
:: Distributed under MIT style license
|
|
|
|
:: See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
|
2017-07-31 18:17:23 +00:00
|
|
|
:: version: 2.0.0
|
2017-04-07 12:53:45 +00:00
|
|
|
|
|
|
|
@if not defined DEBUG_HELPER @ECHO OFF
|
|
|
|
setlocal
|
2023-03-02 13:23:11 +00:00
|
|
|
if "%~3"=="prerelease" set VSWHERE_WITH_PRERELEASE=1
|
2017-07-31 18:17:23 +00:00
|
|
|
set "InstallerPath=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
|
|
|
|
if not exist "%InstallerPath%" set "InstallerPath=%ProgramFiles%\Microsoft Visual Studio\Installer"
|
|
|
|
if not exist "%InstallerPath%" goto :no-vswhere
|
2024-10-15 13:59:49 +00:00
|
|
|
:: Manipulate %Path% for easier " handling
|
2017-07-31 18:17:23 +00:00
|
|
|
set "Path=%Path%;%InstallerPath%"
|
|
|
|
where vswhere 2> nul > nul
|
|
|
|
if errorlevel 1 goto :no-vswhere
|
2024-06-11 17:37:26 +00:00
|
|
|
:: VC.Tools are needed even when using clang because of the vcvarsall.bat usage
|
2023-03-02 13:23:11 +00:00
|
|
|
if "%2"=="arm64" (
|
|
|
|
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.ARM64
|
|
|
|
) else (
|
|
|
|
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
|
|
|
|
)
|
2024-06-11 17:37:26 +00:00
|
|
|
if "%4"=="1" (
|
|
|
|
set VSWHERE_REQ=%VSWHERE_REQ% -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang
|
|
|
|
set VSWHERE_REQ=%VSWHERE_REQ% -requires Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset
|
|
|
|
)
|
2017-04-07 12:53:45 +00:00
|
|
|
set VSWHERE_PRP=-property installationPath
|
2019-07-20 16:33:09 +00:00
|
|
|
set VSWHERE_LMT=-version %1
|
2017-07-31 18:17:23 +00:00
|
|
|
vswhere -prerelease > nul
|
|
|
|
if not errorlevel 1 if "%VSWHERE_WITH_PRERELEASE%"=="1" set "VSWHERE_LMT=%VSWHERE_LMT% -prerelease"
|
2017-04-07 12:53:45 +00:00
|
|
|
SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
|
|
|
|
for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (
|
|
|
|
endlocal
|
|
|
|
set "VCINSTALLDIR=%%i\VC\"
|
|
|
|
set "VS150COMNTOOLS=%%i\Common7\Tools\"
|
2017-07-31 18:17:23 +00:00
|
|
|
exit /B 0
|
|
|
|
)
|
|
|
|
|
|
|
|
:no-vswhere
|
|
|
|
endlocal
|
|
|
|
exit /B 1
|