Fossil SCM
Detect and use Visual Studio 2017 and later in buildmsvc.bat.
Commit
bf5df255d8d93fa0ea50b53fe47e39a9fb312a0ac5c64ab3e82b24ffeb58f399
Parent
a498b132b25ca7f…
1 file changed
+27
-3
+27
-3
| --- win/buildmsvc.bat | ||
| +++ win/buildmsvc.bat | ||
| @@ -33,11 +33,11 @@ | ||
| 33 | 33 | |
| 34 | 34 | REM |
| 35 | 35 | REM Visual C++ ???? |
| 36 | 36 | REM |
| 37 | 37 | IF DEFINED VCINSTALLDIR IF EXIST "%VCINSTALLDIR%" ( |
| 38 | - %_AECHO% Build environment appears to be setup. | |
| 38 | + %_AECHO% Build environment appears to be set up. | |
| 39 | 39 | GOTO skip_setupVisualStudio |
| 40 | 40 | ) |
| 41 | 41 | |
| 42 | 42 | REM |
| 43 | 43 | REM Visual Studio ???? |
| @@ -45,10 +45,22 @@ | ||
| 45 | 45 | IF DEFINED VSVARS32 IF EXIST "%VSVARS32%" ( |
| 46 | 46 | %_AECHO% Build environment batch file manually overridden to "%VSVARS32%"... |
| 47 | 47 | GOTO skip_detectVisualStudio |
| 48 | 48 | ) |
| 49 | 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 | + | |
| 50 | 62 | REM |
| 51 | 63 | REM Visual Studio 2015 |
| 52 | 64 | REM |
| 53 | 65 | IF NOT DEFINED VS140COMNTOOLS GOTO skip_detectVisualStudio2015 |
| 54 | 66 | SET VSVARS32=%VS140COMNTOOLS%\vsvars32.bat |
| @@ -165,14 +177,22 @@ | ||
| 165 | 177 | |
| 166 | 178 | REM |
| 167 | 179 | REM NOTE: Attempt to call the selected batch file to setup the environment |
| 168 | 180 | REM variables for building with MSVC. |
| 169 | 181 | REM |
| 170 | -%__ECHO3% CALL "%VSVARS32%" | |
| 182 | +IF DEFINED VS_ATLEAST_2017 ( | |
| 183 | + %__ECHO3% CALL "%VSDEVCMD_PATH%" | |
| 184 | +) ELSE ( | |
| 185 | + %__ECHO3% CALL "%VSVARS32%" | |
| 186 | +) | |
| 171 | 187 | |
| 172 | 188 | IF ERRORLEVEL 1 ( |
| 173 | - ECHO Visual Studio build environment batch file "%VSVARS32%" failed. | |
| 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 | + ) | |
| 174 | 194 | GOTO errors |
| 175 | 195 | ) |
| 176 | 196 | |
| 177 | 197 | REM |
| 178 | 198 | REM NOTE: After this point, the environment should already be setup for |
| @@ -341,10 +361,14 @@ | ||
| 341 | 361 | GOTO :EOF |
| 342 | 362 | |
| 343 | 363 | :fn_SetErrorLevel |
| 344 | 364 | VERIFY MAYBE 2> NUL |
| 345 | 365 | GOTO :EOF |
| 366 | + | |
| 367 | +:fn_SetVsAtLeast2017 | |
| 368 | + SET VS_ATLEAST_2017=1 | |
| 369 | + GOTO :EOF | |
| 346 | 370 | |
| 347 | 371 | :usage |
| 348 | 372 | ECHO. |
| 349 | 373 | ECHO Usage: %~nx0 [...] |
| 350 | 374 | ECHO. |
| 351 | 375 |
| --- win/buildmsvc.bat | |
| +++ win/buildmsvc.bat | |
| @@ -33,11 +33,11 @@ | |
| 33 | |
| 34 | REM |
| 35 | REM Visual C++ ???? |
| 36 | REM |
| 37 | IF DEFINED VCINSTALLDIR IF EXIST "%VCINSTALLDIR%" ( |
| 38 | %_AECHO% Build environment appears to be setup. |
| 39 | GOTO skip_setupVisualStudio |
| 40 | ) |
| 41 | |
| 42 | REM |
| 43 | REM Visual Studio ???? |
| @@ -45,10 +45,22 @@ | |
| 45 | IF DEFINED VSVARS32 IF EXIST "%VSVARS32%" ( |
| 46 | %_AECHO% Build environment batch file manually overridden to "%VSVARS32%"... |
| 47 | GOTO skip_detectVisualStudio |
| 48 | ) |
| 49 | |
| 50 | REM |
| 51 | REM Visual Studio 2015 |
| 52 | REM |
| 53 | IF NOT DEFINED VS140COMNTOOLS GOTO skip_detectVisualStudio2015 |
| 54 | SET VSVARS32=%VS140COMNTOOLS%\vsvars32.bat |
| @@ -165,14 +177,22 @@ | |
| 165 | |
| 166 | REM |
| 167 | REM NOTE: Attempt to call the selected batch file to setup the environment |
| 168 | REM variables for building with MSVC. |
| 169 | REM |
| 170 | %__ECHO3% CALL "%VSVARS32%" |
| 171 | |
| 172 | IF ERRORLEVEL 1 ( |
| 173 | ECHO Visual Studio build environment batch file "%VSVARS32%" failed. |
| 174 | GOTO errors |
| 175 | ) |
| 176 | |
| 177 | REM |
| 178 | REM NOTE: After this point, the environment should already be setup for |
| @@ -341,10 +361,14 @@ | |
| 341 | GOTO :EOF |
| 342 | |
| 343 | :fn_SetErrorLevel |
| 344 | VERIFY MAYBE 2> NUL |
| 345 | GOTO :EOF |
| 346 | |
| 347 | :usage |
| 348 | ECHO. |
| 349 | ECHO Usage: %~nx0 [...] |
| 350 | ECHO. |
| 351 |
| --- win/buildmsvc.bat | |
| +++ win/buildmsvc.bat | |
| @@ -33,11 +33,11 @@ | |
| 33 | |
| 34 | REM |
| 35 | REM Visual C++ ???? |
| 36 | REM |
| 37 | IF DEFINED VCINSTALLDIR IF EXIST "%VCINSTALLDIR%" ( |
| 38 | %_AECHO% Build environment appears to be set up. |
| 39 | GOTO skip_setupVisualStudio |
| 40 | ) |
| 41 | |
| 42 | REM |
| 43 | REM Visual Studio ???? |
| @@ -45,10 +45,22 @@ | |
| 45 | IF DEFINED VSVARS32 IF EXIST "%VSVARS32%" ( |
| 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 |
| 66 | SET VSVARS32=%VS140COMNTOOLS%\vsvars32.bat |
| @@ -165,14 +177,22 @@ | |
| 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 |
| @@ -341,10 +361,14 @@ | |
| 361 | GOTO :EOF |
| 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 | ECHO. |
| 375 |