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:
authorJohan Lorensson <lateralusx.github@gmail.com>2019-10-17 09:55:50 +0300
committerGitHub <noreply@github.com>2019-10-17 09:55:50 +0300
commit4f8a82c9fdebd7e9dcc5392a8b3a0fd129789bc0 (patch)
tree58ee2741c97ef7972a05b54e9371524488eaf820 /msvc/scripts
parentedafa021d3b8e5b5762a297afa38ae58c21997b1 (diff)
Upgrade build scripts to support VS2019. (#17269)
Changes will default Windows SDK version as well as Platform Toolset to the default versions used in the targeted VS version. If the projects are opened up in VS2015, it should default to Windows SDK 8.1 and v140, but if the same projects are opened in VS2019, it will default to latest Windows SDK 10 and v142. This way the project files should adapt to used VS version, meaning that we could still build them using VS2015 (what's currently used on CI) but also using VS2017 and VS2019. There should not be a need to install any previous versions of build tools, unless an older version is targeted. It is also possible to set PlatformToolset when calling msbuild and that should adapt to corresponding default Windows SDK version for targeted toolset version. Commit makes many changes and adjustments, aligning all vcxproj files but changes should not affect build output.
Diffstat (limited to 'msvc/scripts')
-rw-r--r--msvc/scripts/tests/clang-vs2017-toolchain.bat2
-rw-r--r--msvc/scripts/tests/clang-vs2019-toolchain.bat62
-rw-r--r--msvc/scripts/tests/setup-toolchain.bat41
3 files changed, 91 insertions, 14 deletions
diff --git a/msvc/scripts/tests/clang-vs2017-toolchain.bat b/msvc/scripts/tests/clang-vs2017-toolchain.bat
index 4ea30e0cd72..b812722eca5 100644
--- a/msvc/scripts/tests/clang-vs2017-toolchain.bat
+++ b/msvc/scripts/tests/clang-vs2017-toolchain.bat
@@ -55,7 +55,7 @@ SET VSWHERE_TOOLS_BIN=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswh
ECHO Make sure to run this from a "x64 Native Tools Command Prompt for VS2017" command prompt.
IF EXIST "%VSWHERE_TOOLS_BIN%" (
- FOR /F "tokens=*" %%a IN ('"%VSWHERE_TOOLS_BIN%" -latest -property installationPath') DO (
+ FOR /F "tokens=*" %%a IN ('"%VSWHERE_TOOLS_BIN%" -version [15.0^,16.0] -property installationPath') DO (
ECHO Setup a "x64 Native Tools Command Prompt for VS2017" command prompt by using "%%a\VC\Auxiliary\Build\vcvars64.bat".
)
)
diff --git a/msvc/scripts/tests/clang-vs2019-toolchain.bat b/msvc/scripts/tests/clang-vs2019-toolchain.bat
new file mode 100644
index 00000000000..5376d000a2c
--- /dev/null
+++ b/msvc/scripts/tests/clang-vs2019-toolchain.bat
@@ -0,0 +1,62 @@
+REM Look for Clang VS2019 toolchain in VS installation folders.
+ECHO Searching for Clang in VS2019 toolchain...
+
+IF "%VCINSTALLDIR%" == "" (
+ ECHO VCINSTALLDIR environment variable not set.
+ GOTO ON_ENV_ERROR
+)
+
+IF /i NOT "%VSCMD_ARG_TGT_ARCH%" == "x64" (
+ ECHO VSCMD_ARG_TGT_ARCH environment variable not set to x64.
+ GOTO ON_ENV_ERROR
+)
+
+IF NOT "%VisualStudioVersion%" == "16.0" (
+ ECHO VisualStudioVersion environment variable not set to 16.0.
+ GOTO ON_ENV_ERROR
+)
+
+SET CLANG_TOOLS_BIN_PATH=%VCINSTALLDIR%Tools\llvm\bin\
+SET CLANG_TOOLS_BIN=%CLANG_TOOLS_BIN_PATH%clang.exe
+IF NOT EXIST "%CLANG_TOOLS_BIN%" (
+ ECHO Could not find "%CLANG_TOOLS_BIN%".
+ GOTO ON_ERROR
+)
+
+ECHO Found "%CLANG_TOOLS_BIN%".
+
+ECHO Searching for Linker in VS2019 toolchain...
+
+SET LINK_TOOLS_BIN_PATH=%VCToolsInstallDir%bin\HostX64\x64\
+SET LINK_TOOLS_BIN=%LINK_TOOLS_BIN_PATH%link.exe
+IF NOT EXIST "%LINK_TOOLS_BIN%" (
+ ECHO Could not find "%LINK_TOOLS_BIN%".
+ GOTO ON_ERROR
+)
+
+ECHO Found "%LINK_TOOLS_BIN%".
+
+SET COMPILER_TOOLS_BIN="%LINK_TOOLS_BIN_PATH%";"%CLANGC2_TOOLS_BIN_PATH%"
+SET PATH=%COMPILER_TOOLS_BIN%;%PATH%
+
+SET MONO_RESULT=0
+GOTO ON_EXIT
+
+:ON_ENV_ERROR
+
+SET VSWHERE_TOOLS_BIN=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
+
+ECHO Make sure to run this from a "x64 Native Tools Command Prompt for VS2019" command prompt.
+IF EXIST "%VSWHERE_TOOLS_BIN%" (
+ FOR /F "tokens=*" %%a IN ('"%VSWHERE_TOOLS_BIN%" -version [16.0^,17.0] -property installationPath') DO (
+ ECHO Setup a "x64 Native Tools Command Prompt for VS2019 command prompt by using "%%a\VC\Auxiliary\Build\vcvars64.bat".
+ )
+)
+
+:ON_ERROR
+
+SET MONO_RESULT=1
+
+:ON_EXIT
+
+EXIT /b %MONO_RESULT%
diff --git a/msvc/scripts/tests/setup-toolchain.bat b/msvc/scripts/tests/setup-toolchain.bat
index d5dd6e61402..422119d2104 100644
--- a/msvc/scripts/tests/setup-toolchain.bat
+++ b/msvc/scripts/tests/setup-toolchain.bat
@@ -4,7 +4,7 @@ REM Look for Mono toolchain.
ECHO Searching for Mono toolchain...
IF NOT EXIST "%MONO_CROSS_COMPILER_HOME%\mono-sgen.exe" (
ECHO Could not find "%MONO_CROSS_COMPILER_HOME%\mono-sgen.exe".
- EXIT /b 1
+ GOTO ON_ERROR
)
ECHO Found "%MONO_CROSS_COMPILER_HOME%\mono-sgen.exe".
@@ -19,22 +19,37 @@ SET MONO_LLVM_EXECUTABLES=%MONO_DIST_DIR%\llvm\bin
REM Setup toolchain.
IF "%VisualStudioVersion%" == "14.0" (
- CALL %SCRIPT_DIR%clang-vs2015-toolchain.bat
-) ELSE (
- IF "%VisualStudioVersion%" == "15.0" (
- CALL %SCRIPT_DIR%clang-vs2017-toolchain.bat
- ) ELSE (
- ECHO Failed to identify supported Visual Studio toolchain. Environment variable VisualStudioVersion must be set to 14.0 for VS2015 or 15.0 for VS2017. Checking supported toolchains for more error diagnostics...
- CALL %SCRIPT_DIR%clang-vs2015-toolchain.bat
- CALL %SCRIPT_DIR%clang-vs2017-toolchain.bat
- EXIT /b 1
+ CALL %SCRIPT_DIR%clang-vs2015-toolchain.bat || (
+ GOTO ON_ERROR
)
+ GOTO SETUP_PATH
)
-IF NOT ERRORLEVEL == 0 (
- EXIT /b %ERRORLEVEL%
+IF "%VisualStudioVersion%" == "15.0" (
+ CALL %SCRIPT_DIR%clang-vs2017-toolchain.bat || (
+ GOTO ON_ERROR
+ )
+ GOTO SETUP_PATH
+)
+
+IF "%VisualStudioVersion%" == "16.0" (
+ CALL %SCRIPT_DIR%clang-vs2019-toolchain.bat || (
+ GOTO ON_ERROR
+ )
+ GOTO SETUP_PATH
)
+ECHO Failed to identify supported Visual Studio toolchain. Environment variable VisualStudioVersion must be set to 14.0 for VS2015, 15.0 for VS2017 or 16.0 for VS2019. Checking supported toolchains for more error diagnostics...
+GOTO ON_ERROR
+
+:SETUP_PATH
+
SET PATH=%MONO_JIT_EXECUTABLE_PATH%;%MONO_AOT_RUNTIME_PATH%;%MONO_AOT_COMPILER_PATH%;%MONO_LLVM_EXECUTABLES%;%PATH%
-EXIT /b 0 \ No newline at end of file
+GOTO ON_EXIT
+
+:ON_ERROR
+ EXIT /b 1
+
+:ON_EXIT
+ EXIT /b 0