-
Notifications
You must be signed in to change notification settings - Fork 50
/
build_win_set_env.bat
69 lines (56 loc) · 1.55 KB
/
build_win_set_env.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@echo off
setlocal
pushd "%~dp0"
:: Put in the base path in which Visual Studio is installed, examples:
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\BuildTools"
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\Community"
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
set "vs_static_path="
set "vswhere_exe=third-party\common\win\vswhere\vswhere.exe"
if not exist "%vswhere_exe%" (
call :err_msg "vswhere.exe wasn't found"
goto :end_script_with_err
)
set "arch="
if "%~1"=="32" (
set "arch=32"
) else if "%~1"=="64" (
set "arch=64"
) else (
call :err_msg "First arg may be any of [32 64]"
goto :end_script_with_err
)
set "my_vs_path=%vs_static_path%"
if "%my_vs_path%"=="" (
for /f "tokens=* delims=" %%A in ('"%vswhere_exe%" -prerelease -latest -nocolor -nologo -property installationPath 2^>nul') do (
set "my_vs_path=%%~A\VC\Auxiliary\Build"
)
)
if not exist "%my_vs_path%\vcvars%arch%.bat" (
set "my_vs_path="
)
if "%my_vs_path%"=="" (
call :err_msg "Visual Studio couldn't be found, set its path in the script %~nx0"
goto :end_script_with_err
)
echo:
echo Using Visual Studio found in: "%my_vs_path%"
popd
endlocal & (
call "%my_vs_path%\vcvars%arch%.bat" && (
echo: & echo:
exit /b 0
) || (
1>&2 echo [X] Visual Studio script "vcvars%arch%.bat" failed
echo: & echo:
exit /b 1
)
)
:err_msg
1>&2 echo [X] %~1
exit /b
:end_script_with_err
popd
endlocal & (
exit /b 1
)