1 :: Set up VS MSVC environment when running MSVC build mono-sgen.exe with all supplied arguments.
\r
2 :: Simplify the setup of VS and MSVC toolchain, when running Mono AOT compiler
\r
3 :: since it need to locate correct compiler and OS libraries as well as clang.exe and link.exe
\r
4 :: from VS setup for the corresponding architecture.
\r
11 :: Get path for current running script.
\r
12 set RUN_MONO_SGEN_MSVC_SCRIPT_PATH=%~dp0
\r
14 :: Optimization, check if we need to setup full build environment, only needed when running mono-sgen.exe as AOT compiler.
\r
15 if "%MONO_AS_AOT_COMPILER%" == "1" (
\r
19 set MONO_AS_AOT_COMPILER=0
\r
20 :: Look for --aot or --aot=, --aot-path alone should not trigger setup of VS env.
\r
21 echo.%* | findstr /r /c:".*--aot[^-a-zA-Z0-9].*" > nul && (
\r
22 set MONO_AS_AOT_COMPILER=1
\r
25 if %MONO_AS_AOT_COMPILER% == 1 (
\r
29 :: mono-sgen.exe not invoked as a AOT compiler, no need to setup full build environment.
\r
32 :: Try setting up VS MSVC build environment.
\r
35 :: Optimization, check if we have something that looks like a VS MSVC build environment
\r
36 :: already available.
\r
37 if /i not "%VCINSTALLDIR%" == "" (
\r
38 if /i not "%INCLUDE%" == "" (
\r
39 if /i not "%LIB%" == "" (
\r
45 :: Setup Windows environment.
\r
46 call %RUN_MONO_SGEN_MSVC_SCRIPT_PATH%setup-windows-env.bat
\r
48 if "%MONO_VS_MSVCBUILD_ENV_FILE%" == "" (
\r
49 set MONO_VS_MSVCBUILD_ENV_FILE=%RUN_MONO_SGEN_MSVC_SCRIPT_PATH%mono-sgen.exe.env
\r
52 :: Check import of VS MSVC build environment using a file instead of running all commands.
\r
53 :: NOTE, this is an optimization since setting up a development command
\r
54 :: prompt could take some time.
\r
55 if /i "%MONO_IMPORT_VS_MSVCBUILD_ENV_FILE%" == "true" (
\r
56 if exist "%MONO_VS_MSVCBUILD_ENV_FILE%" (
\r
57 for /f "delims=" %%a in (%MONO_VS_MSVCBUILD_ENV_FILE%) do SET %%a
\r
61 if not "%MONO_MSVC_PATH%" == "" (
\r
62 set "PATH=%MONO_MSVC_PATH%;%PATH%"
\r
66 :: Setup VS MSVC build environment.
\r
67 set TEMP_PATH=%PATH%
\r
68 call %RUN_MONO_SGEN_MSVC_SCRIPT_PATH%setup-vs-msvcbuild-env.bat
\r
69 call set MONO_MSVC_PATH=%%PATH:%TEMP_PATH%=%%
\r
71 :: Check if msvc env should be exported into file for later import.
\r
72 for /f %%a in ('uuidgen.exe') do set NEW_UUID=%%a
\r
73 if /i "%MONO_EXPORT_VS_MSVCBUILD_ENV_FILE%" == "true" (
\r
74 SET VCINSTALLDIR >> "%TEMP%\%NEW_UUID%.env"
\r
75 SET INCLUDE >> "%TEMP%\%NEW_UUID%.env"
\r
76 SET LIB >> "%TEMP%\%NEW_UUID%.env"
\r
77 SET MONO_MSVC_PATH >> "%TEMP%\%NEW_UUID%.env"
\r
78 move /Y "%TEMP%\%NEW_UUID%.env" "%MONO_VS_MSVCBUILD_ENV_FILE%" >nul 2>&1
\r
83 :: Add mono.sgen.exe (needed for optional LLVM tooling) to PATH
\r
84 set "PATH=%RUN_MONO_SGEN_MSVC_SCRIPT_PATH%;%PATH%"
\r
86 call "%RUN_MONO_SGEN_MSVC_SCRIPT_PATH%mono-sgen.exe" %* && (
\r
87 set EXECUTE_RESULT=0
\r
89 set EXECUTE_RESULT=1
\r
90 if not %ERRORLEVEL% == 0 (
\r
91 set EXECUTE_RESULT=%ERRORLEVEL%
\r
95 exit /b %EXECUTE_RESULT%
\r