Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlateralusX <lateralusx.github@gmail.com>2019-05-03 15:19:14 +0300
committerlateralusX <lateralusx.github@gmail.com>2019-05-03 16:14:22 +0300
commitf42c1e0a679326c00a64413b146ad44e3d507c95 (patch)
treea59bf9b680e994c52f3a505ff0afcc0956527890 /msvc/mono-sgen-msvc.bat
parent568813b93bdd3f5f000bc4bdbc88e71f8158d9ca (diff)
Add option to restore VS build env from file.
Diffstat (limited to 'msvc/mono-sgen-msvc.bat')
-rw-r--r--msvc/mono-sgen-msvc.bat45
1 files changed, 41 insertions, 4 deletions
diff --git a/msvc/mono-sgen-msvc.bat b/msvc/mono-sgen-msvc.bat
index 6a3d82f7d6f..5458a8fe7a1 100644
--- a/msvc/mono-sgen-msvc.bat
+++ b/msvc/mono-sgen-msvc.bat
@@ -11,10 +11,14 @@ set EXECUTE_RESULT=1
:: Get path for current running script.
set RUN_MONO_SGEN_MSVC_SCRIPT_PATH=%~dp0
-set MONO_AS_AOT_COMPILER=0
-
:: Optimization, check if we need to setup full build environment, only needed when running mono-sgen.exe as AOT compiler.
-echo.%* | findstr /c:"--aot=" > nul && (
+if "%MONO_AS_AOT_COMPILER%" == "1" (
+ goto SETUP_VS_ENV
+)
+
+set MONO_AS_AOT_COMPILER=0
+:: Look for --aot or --aot=, --aot-path alone should not trigger setup of VS env.
+echo.%* | findstr /r /c:".*--aot[^-a-zA-Z0-9].*" > nul && (
set MONO_AS_AOT_COMPILER=1
)
@@ -28,7 +32,8 @@ goto ON_EXECUTE
:: Try setting up VS MSVC build environment.
:SETUP_VS_ENV
-:: Optimization, check if we have something that looks like a MSVC build environment already available.
+:: Optimization, check if we have something that looks like a VS MSVC build environment
+:: already available.
if /i not "%VCINSTALLDIR%" == "" (
if /i not "%INCLUDE%" == "" (
if /i not "%LIB%" == "" (
@@ -40,8 +45,40 @@ if /i not "%VCINSTALLDIR%" == "" (
:: Setup Windows environment.
call %RUN_MONO_SGEN_MSVC_SCRIPT_PATH%setup-windows-env.bat
+if "%MONO_VS_MSVCBUILD_ENV_FILE%" == "" (
+ set MONO_VS_MSVCBUILD_ENV_FILE=%RUN_MONO_SGEN_MSVC_SCRIPT_PATH%mono-sgen.exe.env
+)
+
+:: Check import of VS MSVC build environment using a file instead of running all commands.
+:: NOTE, this is an optimization since setting up a development command
+:: prompt could take some time.
+if /i "%MONO_IMPORT_VS_MSVCBUILD_ENV_FILE%" == "true" (
+ if exist "%MONO_VS_MSVCBUILD_ENV_FILE%" (
+ for /f "delims=" %%a in (%MONO_VS_MSVCBUILD_ENV_FILE%) do SET %%a
+ )
+)
+
+if not "%MONO_MSVC_PATH%" == "" (
+ set "PATH=%MONO_MSVC_PATH%;%PATH%"
+ goto ON_EXECUTE
+)
+
:: Setup VS MSVC build environment.
+set TEMP_PATH=%PATH%
call %RUN_MONO_SGEN_MSVC_SCRIPT_PATH%setup-vs-msvcbuild-env.bat
+call set MONO_MSVC_PATH=%%PATH:%TEMP_PATH%=%%
+
+:: Check if msvc env should be exported into file for later import.
+for /f %%a in ('uuidgen.exe') do set NEW_UUID=%%a
+if /i "%MONO_EXPORT_VS_MSVCBUILD_ENV_FILE%" == "true" (
+ SET VCINSTALLDIR >> "%TEMP%\%NEW_UUID%.env"
+ SET INCLUDE >> "%TEMP%\%NEW_UUID%.env"
+ SET LIB >> "%TEMP%\%NEW_UUID%.env"
+ SET MONO_MSVC_PATH >> "%TEMP%\%NEW_UUID%.env"
+ move /Y "%TEMP%\%NEW_UUID%.env" "%MONO_VS_MSVCBUILD_ENV_FILE%" >nul 2>&1
+)
+
+:ON_EXECUTE
:: Add mono.sgen.exe (needed for optional LLVM tooling) to PATH
set "PATH=%RUN_MONO_SGEN_MSVC_SCRIPT_PATH%;%PATH%"