Fossil SCM
Make detection and use of VsWhere tool consistent and support 32-bit installs.
Commit
9fef4e01ba474d53388ff5b5b1b7d1f315ac61b3da93cf751d3e2a559e60802e
Parent
4c561266129d6b0…
1 file changed
+37
-21
+37
-21
| --- win/buildmsvc.bat | ||
| +++ win/buildmsvc.bat | ||
| @@ -46,20 +46,20 @@ | ||
| 46 | 46 | %_AECHO% Build environment batch file manually overridden to "%VSVARS32%"... |
| 47 | 47 | GOTO skip_detectVisualStudio |
| 48 | 48 | ) |
| 49 | 49 | |
| 50 | 50 | REM |
| 51 | -REM Visual Studio at least 2017 | |
| 51 | +REM Visual Studio 2017 / 2019 | |
| 52 | 52 | REM |
| 53 | -SET VSWHERE=%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe | |
| 54 | -IF NOT EXIST "%VSWHERE%" GOTO skip_detectVisualStudioAtLeast2017 | |
| 55 | -FOR /f "usebackq delims=#" %%a IN (`"%VSWHERE%" -latest -property installationPath`) DO SET VSDEVCMD_PATH=%%a\Common7\Tools\VsDevCmd.bat | |
| 56 | -FOR /f "usebackq delims=#" %%a IN (`"%VSWHERE%" -latest -property catalog_productLineVersion`) DO SET VS_LINEVER=%%a | |
| 57 | -call :fn_SetVsAtLeast2017 | |
| 58 | -%_AECHO% Using Visual Studio %VS_LINEVER%... | |
| 59 | -GOTO skip_detectVisualStudio | |
| 60 | -:skip_detectVisualStudioAtLeast2017 | |
| 53 | +CALL :fn_TryUseVsWhereExe | |
| 54 | +IF NOT DEFINED VSWHEREINSTALLDIR GOTO skip_detectVisualStudio2017 | |
| 55 | +SET VSVARS32=%VSWHEREINSTALLDIR%\Common7\Tools\VsDevCmd.bat | |
| 56 | +IF EXIST "%VSVARS32%" ( | |
| 57 | + %_AECHO% Using Visual Studio 2017 / 2019... | |
| 58 | + GOTO skip_detectVisualStudio | |
| 59 | +) | |
| 60 | +:skip_detectVisualStudio2017 | |
| 61 | 61 | |
| 62 | 62 | REM |
| 63 | 63 | REM Visual Studio 2015 |
| 64 | 64 | REM |
| 65 | 65 | IF NOT DEFINED VS140COMNTOOLS GOTO skip_detectVisualStudio2015 |
| @@ -177,22 +177,14 @@ | ||
| 177 | 177 | |
| 178 | 178 | REM |
| 179 | 179 | REM NOTE: Attempt to call the selected batch file to setup the environment |
| 180 | 180 | REM variables for building with MSVC. |
| 181 | 181 | REM |
| 182 | -IF DEFINED VS_ATLEAST_2017 ( | |
| 183 | - %__ECHO3% CALL "%VSDEVCMD_PATH%" | |
| 184 | -) ELSE ( | |
| 185 | - %__ECHO3% CALL "%VSVARS32%" | |
| 186 | -) | |
| 182 | +%__ECHO3% CALL "%VSVARS32%" | |
| 187 | 183 | |
| 188 | 184 | IF ERRORLEVEL 1 ( |
| 189 | - IF DEFINED VS_ATLEAST_2017 ( | |
| 190 | - ECHO Visual Studio build environment batch file "%VSDEVCMD_PATH%" failed. | |
| 191 | - ) ELSE ( | |
| 192 | - ECHO Visual Studio build environment batch file "%VSVARS32%" failed. | |
| 193 | - ) | |
| 185 | + ECHO Visual Studio build environment batch file "%VSVARS32%" failed. | |
| 194 | 186 | GOTO errors |
| 195 | 187 | ) |
| 196 | 188 | |
| 197 | 189 | REM |
| 198 | 190 | REM NOTE: After this point, the environment should already be setup for |
| @@ -362,12 +354,36 @@ | ||
| 362 | 354 | |
| 363 | 355 | :fn_SetErrorLevel |
| 364 | 356 | VERIFY MAYBE 2> NUL |
| 365 | 357 | GOTO :EOF |
| 366 | 358 | |
| 367 | -:fn_SetVsAtLeast2017 | |
| 368 | - SET VS_ATLEAST_2017=1 | |
| 359 | +:fn_TryUseVsWhereExe | |
| 360 | + IF DEFINED VSWHERE_EXE GOTO skip_setVsWhereExe | |
| 361 | + SET VSWHERE_EXE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe | |
| 362 | + IF NOT EXIST "%VSWHERE_EXE%" SET VSWHERE_EXE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe | |
| 363 | + :skip_setVsWhereExe | |
| 364 | + IF NOT EXIST "%VSWHERE_EXE%" ( | |
| 365 | + %_AECHO% The "VsWhere" tool does not appear to be installed. | |
| 366 | + GOTO :EOF | |
| 367 | + ) | |
| 368 | + SET VS_WHEREIS_CMD="%VSWHERE_EXE%" -products * -requires Microsoft.Component.MSBuild -property installationPath -latest | |
| 369 | + IF DEFINED __ECHO ( | |
| 370 | + %__ECHO% %VS_WHEREIS_CMD% | |
| 371 | + REM | |
| 372 | + REM NOTE: This will not be executed, any reasonable fake path will work. | |
| 373 | + REM | |
| 374 | + SET VSWHEREINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2017\Community | |
| 375 | + GOTO skip_setVsWhereInstallDir | |
| 376 | + ) | |
| 377 | + FOR /F "delims=" %%D IN ('%VS_WHEREIS_CMD%') DO (SET VSWHEREINSTALLDIR=%%D) | |
| 378 | + :skip_setVsWhereInstallDir | |
| 379 | + %_VECHO% VsWhereInstallDir = '%VSWHEREINSTALLDIR%' | |
| 380 | + IF NOT DEFINED VSWHEREINSTALLDIR ( | |
| 381 | + %_AECHO% Visual Studio 2017 / 2019 is not installed. | |
| 382 | + GOTO :EOF | |
| 383 | + ) | |
| 384 | + %_AECHO% Visual Studio 2017 / 2019 is installed. | |
| 369 | 385 | GOTO :EOF |
| 370 | 386 | |
| 371 | 387 | :usage |
| 372 | 388 | ECHO. |
| 373 | 389 | ECHO Usage: %~nx0 [...] |
| 374 | 390 |
| --- win/buildmsvc.bat | |
| +++ win/buildmsvc.bat | |
| @@ -46,20 +46,20 @@ | |
| 46 | %_AECHO% Build environment batch file manually overridden to "%VSVARS32%"... |
| 47 | GOTO skip_detectVisualStudio |
| 48 | ) |
| 49 | |
| 50 | REM |
| 51 | REM Visual Studio at least 2017 |
| 52 | REM |
| 53 | SET VSWHERE=%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe |
| 54 | IF NOT EXIST "%VSWHERE%" GOTO skip_detectVisualStudioAtLeast2017 |
| 55 | FOR /f "usebackq delims=#" %%a IN (`"%VSWHERE%" -latest -property installationPath`) DO SET VSDEVCMD_PATH=%%a\Common7\Tools\VsDevCmd.bat |
| 56 | FOR /f "usebackq delims=#" %%a IN (`"%VSWHERE%" -latest -property catalog_productLineVersion`) DO SET VS_LINEVER=%%a |
| 57 | call :fn_SetVsAtLeast2017 |
| 58 | %_AECHO% Using Visual Studio %VS_LINEVER%... |
| 59 | GOTO skip_detectVisualStudio |
| 60 | :skip_detectVisualStudioAtLeast2017 |
| 61 | |
| 62 | REM |
| 63 | REM Visual Studio 2015 |
| 64 | REM |
| 65 | IF NOT DEFINED VS140COMNTOOLS GOTO skip_detectVisualStudio2015 |
| @@ -177,22 +177,14 @@ | |
| 177 | |
| 178 | REM |
| 179 | REM NOTE: Attempt to call the selected batch file to setup the environment |
| 180 | REM variables for building with MSVC. |
| 181 | REM |
| 182 | IF DEFINED VS_ATLEAST_2017 ( |
| 183 | %__ECHO3% CALL "%VSDEVCMD_PATH%" |
| 184 | ) ELSE ( |
| 185 | %__ECHO3% CALL "%VSVARS32%" |
| 186 | ) |
| 187 | |
| 188 | IF ERRORLEVEL 1 ( |
| 189 | IF DEFINED VS_ATLEAST_2017 ( |
| 190 | ECHO Visual Studio build environment batch file "%VSDEVCMD_PATH%" failed. |
| 191 | ) ELSE ( |
| 192 | ECHO Visual Studio build environment batch file "%VSVARS32%" failed. |
| 193 | ) |
| 194 | GOTO errors |
| 195 | ) |
| 196 | |
| 197 | REM |
| 198 | REM NOTE: After this point, the environment should already be setup for |
| @@ -362,12 +354,36 @@ | |
| 362 | |
| 363 | :fn_SetErrorLevel |
| 364 | VERIFY MAYBE 2> NUL |
| 365 | GOTO :EOF |
| 366 | |
| 367 | :fn_SetVsAtLeast2017 |
| 368 | SET VS_ATLEAST_2017=1 |
| 369 | GOTO :EOF |
| 370 | |
| 371 | :usage |
| 372 | ECHO. |
| 373 | ECHO Usage: %~nx0 [...] |
| 374 |
| --- win/buildmsvc.bat | |
| +++ win/buildmsvc.bat | |
| @@ -46,20 +46,20 @@ | |
| 46 | %_AECHO% Build environment batch file manually overridden to "%VSVARS32%"... |
| 47 | GOTO skip_detectVisualStudio |
| 48 | ) |
| 49 | |
| 50 | REM |
| 51 | REM Visual Studio 2017 / 2019 |
| 52 | REM |
| 53 | CALL :fn_TryUseVsWhereExe |
| 54 | IF NOT DEFINED VSWHEREINSTALLDIR GOTO skip_detectVisualStudio2017 |
| 55 | SET VSVARS32=%VSWHEREINSTALLDIR%\Common7\Tools\VsDevCmd.bat |
| 56 | IF EXIST "%VSVARS32%" ( |
| 57 | %_AECHO% Using Visual Studio 2017 / 2019... |
| 58 | GOTO skip_detectVisualStudio |
| 59 | ) |
| 60 | :skip_detectVisualStudio2017 |
| 61 | |
| 62 | REM |
| 63 | REM Visual Studio 2015 |
| 64 | REM |
| 65 | IF NOT DEFINED VS140COMNTOOLS GOTO skip_detectVisualStudio2015 |
| @@ -177,22 +177,14 @@ | |
| 177 | |
| 178 | REM |
| 179 | REM NOTE: Attempt to call the selected batch file to setup the environment |
| 180 | REM variables for building with MSVC. |
| 181 | REM |
| 182 | %__ECHO3% CALL "%VSVARS32%" |
| 183 | |
| 184 | IF ERRORLEVEL 1 ( |
| 185 | ECHO Visual Studio build environment batch file "%VSVARS32%" failed. |
| 186 | GOTO errors |
| 187 | ) |
| 188 | |
| 189 | REM |
| 190 | REM NOTE: After this point, the environment should already be setup for |
| @@ -362,12 +354,36 @@ | |
| 354 | |
| 355 | :fn_SetErrorLevel |
| 356 | VERIFY MAYBE 2> NUL |
| 357 | GOTO :EOF |
| 358 | |
| 359 | :fn_TryUseVsWhereExe |
| 360 | IF DEFINED VSWHERE_EXE GOTO skip_setVsWhereExe |
| 361 | SET VSWHERE_EXE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe |
| 362 | IF NOT EXIST "%VSWHERE_EXE%" SET VSWHERE_EXE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe |
| 363 | :skip_setVsWhereExe |
| 364 | IF NOT EXIST "%VSWHERE_EXE%" ( |
| 365 | %_AECHO% The "VsWhere" tool does not appear to be installed. |
| 366 | GOTO :EOF |
| 367 | ) |
| 368 | SET VS_WHEREIS_CMD="%VSWHERE_EXE%" -products * -requires Microsoft.Component.MSBuild -property installationPath -latest |
| 369 | IF DEFINED __ECHO ( |
| 370 | %__ECHO% %VS_WHEREIS_CMD% |
| 371 | REM |
| 372 | REM NOTE: This will not be executed, any reasonable fake path will work. |
| 373 | REM |
| 374 | SET VSWHEREINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2017\Community |
| 375 | GOTO skip_setVsWhereInstallDir |
| 376 | ) |
| 377 | FOR /F "delims=" %%D IN ('%VS_WHEREIS_CMD%') DO (SET VSWHEREINSTALLDIR=%%D) |
| 378 | :skip_setVsWhereInstallDir |
| 379 | %_VECHO% VsWhereInstallDir = '%VSWHEREINSTALLDIR%' |
| 380 | IF NOT DEFINED VSWHEREINSTALLDIR ( |
| 381 | %_AECHO% Visual Studio 2017 / 2019 is not installed. |
| 382 | GOTO :EOF |
| 383 | ) |
| 384 | %_AECHO% Visual Studio 2017 / 2019 is installed. |
| 385 | GOTO :EOF |
| 386 | |
| 387 | :usage |
| 388 | ECHO. |
| 389 | ECHO Usage: %~nx0 [...] |
| 390 |