Skip to content

Commit

Permalink
Support building with VS2019 Preview (dotnet/coreclr#22525)
Browse files Browse the repository at this point in the history
* Support building with VS2019 Preview

* Fixing gen-buildsys-win to only set the architecture for the VS generator

* Refactoring Dev11/147911/fpcw.cpp so that it compiles under VS2019

* Removing the remaining traces of VS2015 build support


Commit migrated from dotnet/coreclr@f077060
  • Loading branch information
tannergooding authored Feb 12, 2019
1 parent 494665d commit f28a4f0
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 159 deletions.
12 changes: 3 additions & 9 deletions docs/coreclr/building/windows-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ You must install several components to build the CoreCLR and CoreFX repos. These
## Visual Studio

Visual Studio must be installed. Supported versions:
- [Visual Studio 2015](https://www.visualstudio.com/vs/older-downloads/) (Community, Professional, Enterprise). The community version is completely free.
- [Visual Studio 2017](https://www.visualstudio.com/downloads/) (Community, Professional, Enterprise). The community version is completely free.

For Visual Studio 2015:
* Ensure you have installed at least [Visual Studio 2015 Update 3](https://www.visualstudio.com/en-us/news/releasenotes/vs2015-update3-vs).
* Make sure that you install "VC++ Tools". By default, they will not be installed.
* To build for Arm32, Make sure that you have the Windows SDK for Windows 10 installed (or selected to be installed as part of VS installation). To explicitly install Windows SDK, download it from here: [Windows SDK for Windows 10](https://developer.microsoft.com/en-us/windows/downloads)
- [Visual Studio 2019 Preview](https://visualstudio.microsoft.com/vs/preview/) (Community, Professional, Enterprise). The community version is completely free.

For Visual Studio 2017:
* When doing a 'Workloads' based install, the following are the minimum requirements:
Expand Down Expand Up @@ -50,7 +45,6 @@ For Visual Studio 2017:
* **Important:** You must have the `msdia120.dll` COM Library registered in order to build the repository.
* This binary is registered by default when installing the "VC++ Tools" with Visual Studio 2015
* You can also manually register the binary by launching the "Developer Command Prompt for VS2017" with Administrative privileges and running `regsvr32.exe "%VSINSTALLDIR%\Common7\IDE\msdia120.dll"`
* **Important:** By default, the build will attempt to use VS2015 as the toolset for the build. To build using VS2017 as your toolset, you must use the "Developer Command Prompt for VS2017".

Visual Studio Express is not supported.

Expand All @@ -75,7 +69,7 @@ any recent (2.4+) version of Python should work, including Python 3.

## Git

For actual user operations, it is often more convenient to use the GIT features built into Visual Studio 2015.
For actual user operations, it is often more convenient to use the GIT features built into Visual Studio.
However the CoreCLR and the tests use the GIT command line utilities directly so you need to install them
for these to work properly. You can get it from

Expand All @@ -93,7 +87,7 @@ Powershell version must be 3.0 or higher. This should be the case for Windows 8

## DotNet Core SDK
While not strictly needed to build or test the .NET Core repository, having the .NET Core SDK installed lets you use the dotnet.exe command to run .NET Core applications in the 'normal' way. We use this in the
[Using Your Build](../workflow/UsingYourBuild.md) instructions. Visual Studio 2015 (update 3) should have
[Using Your Build](../workflow/UsingYourBuild.md) instructions. Visual Studio should have
installed the .NET Core SDK, but in case it did not you can get it from the [Installing the .Net Core SDK](https://www.microsoft.com/net/core) page.

## Adding to the default PATH variable
Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ if (WIN32)
endif()

# Explicitly specify the assembler to be used for Arm32 compile
if($ENV{__VSVersion} STREQUAL "vs2015")
file(TO_CMAKE_PATH "$ENV{VCINSTALLDIR}\\bin\\x86_arm\\armasm.exe" CMAKE_ASM_COMPILER)
else()
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
endif()
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)

set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/build-test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ set __ThisScriptDir="%~dp0"
call "%__ThisScriptDir%"\setup_vs_tools.cmd
if NOT '%ERRORLEVEL%' == '0' exit /b 1

if defined VS150COMNTOOLS (
if defined VS160COMNTOOLS (
set "__VSToolsRoot=%VS160COMNTOOLS%"
set "__VCToolsRoot=%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build"
set __VSVersion=vs2019
) else if defined VS150COMNTOOLS (
set "__VSToolsRoot=%VS150COMNTOOLS%"
set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"
set __VSVersion=vs2017
) else (
set "__VSToolsRoot=%VS140COMNTOOLS%"
set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC"
set __VSVersion=vs2015
)

:: Set the default arguments for build
Expand Down Expand Up @@ -633,7 +633,7 @@ at the install location of previous Visual Studio version. The workaround is to
of the previous version to "%VSINSTALLDIR%" and then build.
REM DIA SDK not included in Express editions
echo Visual Studio Express does not include the DIA SDK. ^
You need Visual Studio 2015 or 2017 (Community is free).
You need Visual Studio 2017 or 2019 (Community is free).
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
exit /b 1

Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ set __ThisScriptDir="%~dp0"
call "%__ThisScriptDir%"\setup_vs_tools.cmd
if NOT '%ERRORLEVEL%' == '0' exit /b 1

if defined VS150COMNTOOLS (
if defined VS160COMNTOOLS (
set "__VSToolsRoot=%VS160COMNTOOLS%"
set "__VCToolsRoot=%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build"
set __VSVersion=vs2019
) else if defined VS150COMNTOOLS (
set "__VSToolsRoot=%VS150COMNTOOLS%"
set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"
set __VSVersion=vs2017
) else (
set "__VSToolsRoot=%VS140COMNTOOLS%"
set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC"
set __VSVersion=vs2015
)

:: Work around Jenkins CI + msbuild problem: Jenkins sometimes creates very large environment
Expand Down Expand Up @@ -1056,6 +1056,6 @@ at the install location of previous Visual Studio version. The workaround is to
of the previous version to "%VSINSTALLDIR%" and then build.
REM DIA SDK not included in Express editions
echo Visual Studio Express does not include the DIA SDK. ^
You need Visual Studio 2015 or 2017 (Community is free).
You need Visual Studio 2017 or 2019 (Community is free).
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
exit /b 1
30 changes: 12 additions & 18 deletions src/coreclr/setup_vs_tools.cmd
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
@if not defined _echo @echo off

REM This script is responsible for setting up either the vs2015 or vs2017 env
REM This script is responsible for setting up the vs2017 or vs2019 env
REM All passed arguments are ignored
REM Script will return with 0 if pass, 1 if there is a failure to find either
REM vs2015 or vs2017
REM vs2017 or vs2019

:: Default to highest Visual Studio version available
::
:: For VS2015 (and prior), only a single instance is allowed to be installed on a box
:: and VS140COMNTOOLS is set as a global environment variable by the installer. This
:: allows users to locate where the instance of VS2015 is installed.
::
:: For VS2017, multiple instances can be installed on the same box SxS and VS150COMNTOOLS
:: For VS2017 and later, multiple instances can be installed on the same box SxS and VS1*0COMNTOOLS
:: is no longer set as a global environment variable and is instead only set if the user
:: has launched the VS2017 Developer Command Prompt.
:: has launched the Visual Studio Developer Command Prompt.
::
:: Following this logic, we will default to the VS2017 toolset if VS150COMNTOOLS tools is
:: set, as this indicates the user is running from the VS2017 Developer Command Prompt and
:: is already configured to use that toolset. Otherwise, we will fallback to using the VS2015
:: toolset if it is installed. Finally, we will fail the script if no supported VS instance
:: can be found.
:: Following this logic, we will default to the Visual Studio toolset assocated with the active
:: Developer Command Prompt. Otherwise, we will query VSWhere to locate the later version of
:: Visual Studio available on the machine. Finally, we will fail the script if not supported
:: instance can be found.

if defined VisualStudioVersion (
if not defined __VSVersion echo %__MsgPrefix%Detected Visual Studio %VisualStudioVersion% developer command ^prompt environment
goto skip_setup
)

echo %__MsgPrefix%Searching ^for Visual Studio 2017 or 2015 installation
echo %__MsgPrefix%Searching ^for Visual Studio 2017 or later installation
set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if exist %_VSWHERE% (
for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -prerelease -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools
goto call_vs
)
if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
echo VS2017 not found, using VS2015
echo Visual Studio 2017 or later not found
:call_vs
if not exist "%_VSCOMNTOOLS%" (
echo %__MsgPrefix%Error: Visual Studio 2015 or 2017 required.
echo %__MsgPrefix%Error: Visual Studio 2017 or 2019 required.
echo Please see https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md for build instructions.
exit /b 1
)
Expand All @@ -45,4 +39,4 @@ call "%_VSCOMNTOOLS%\VsDevCmd.bat"

:skip_setup

exit /b 0
exit /b 0
5 changes: 0 additions & 5 deletions src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ if(WIN32)
endif()

set(DACTABLEGEN_EXE ${CMAKE_BINARY_DIR}/src/ToolBox/SOS/DacTableGen/dactablegen.exe)
# The DactTableGen executable that we build needs an msdia140.dll supplied by Visual Studio.
# however VS2015 may not have this, so fall back to the DactTableGen in the tools package (which is old)
if($ENV{__VSVersion} STREQUAL "vs2015")
set(DACTABLEGEN_EXE ${BuildToolsDir}/dactablegen.exe)
endif()

add_custom_command(
DEPENDS coreclr mscordaccore mscordbi ${CLR_DIR}/src/debug/daccess/daccess.cpp
Expand Down
18 changes: 11 additions & 7 deletions src/coreclr/src/pal/tools/gen-buildsys-win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ set __SourceDir=%1
set __VSVersion=%2
set __Arch=%3
set __CmakeGenerator=Visual Studio
if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017)
if /i "%__VSVersion%" == "vs2015" (set __CmakeGenerator=%__CmakeGenerator% 14 2015)
if /i "%__Arch%" == "x64" (set __CmakeGenerator=%__CmakeGenerator% Win64)
if /i "%__Arch%" == "arm" (set __CmakeGenerator=%__CmakeGenerator% ARM)
if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)

if /i "%__NMakeMakefiles%" == "1" (set __CmakeGenerator=NMake Makefiles)
if /i "%__NMakeMakefiles%" == "1" (
set __CmakeGenerator=NMake Makefiles
) else (
if /i "%__VSVersion%" == "vs2019" (set __CmakeGenerator=%__CmakeGenerator% 16 2019)
if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017)

if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
)

:loop
if [%4] == [] goto end_loop
Expand All @@ -48,7 +52,7 @@ GOTO :DONE
echo "Usage..."
echo "gen-buildsys-win.bat <path to top level CMakeLists.txt> <VSVersion>"
echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
echo "Specify the VSVersion to be used - VS2015 or VS2017"
echo "Specify the VSVersion to be used - VS2017 or VS2019"
EXIT /B 1

:DONE
Expand Down
25 changes: 12 additions & 13 deletions src/coreclr/tests/runtest.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ if /I "%PROCESSOR_ARCHITEW6432%"=="arm64" goto :skip_vs_setup
call "%__ThisScriptDir%"\..\setup_vs_tools.cmd
if NOT '%ERRORLEVEL%' == '0' exit /b 1

if defined VS150COMNTOOLS (
if defined VS160COMNTOOLS (
set __VSVersion=vs2019
) else if defined VS150COMNTOOLS (
set __VSVersion=vs2017
) else (
set __VSVersion=vs2015
)
:skip_vs_setup

Expand Down Expand Up @@ -73,8 +73,8 @@ if /i "%1" == "debug" (set __BuildType=Debug&s
if /i "%1" == "release" (set __BuildType=Release&shift&goto Arg_Loop)
if /i "%1" == "checked" (set __BuildType=Checked&shift&goto Arg_Loop)

if /i "%1" == "vs2015" (set __VSVersion=%1&shift&goto Arg_Loop)
if /i "%1" == "vs2017" (set __VSVersion=%1&shift&goto Arg_Loop)
if /i "%1" == "vs2019" (set __VSVersion=%1&shift&goto Arg_Loop)

if /i "%1" == "TestEnv" (set __TestEnv=%2&shift&shift&goto Arg_Loop)
if /i "%1" == "AgainstPackages" (set __AgainstPackages=1&shift&goto Arg_Loop)
Expand Down Expand Up @@ -242,17 +242,16 @@ exit /b %ERRORLEVEL%
:: Set up msbuild and tools environment. Check if msbuild and VS exist.

set _msbuildexe=
if /i "%__VSVersion%" == "vs2017" (
if /i "%__VSVersion%" == "vs2019" (
set "__VSToolsRoot=%VS160COMNTOOLS%"
set "__VCToolsRoot=%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build"

set _msbuildexe="%VS160COMNTOOLS%\..\..\MSBuild\Current\Bin\MSBuild.exe"
) else if /i "%__VSVersion%" == "vs2017" (
set "__VSToolsRoot=%VS150COMNTOOLS%"
set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"

set _msbuildexe="%VS150COMNTOOLS%\..\..\MSBuild\15.0\Bin\MSBuild.exe"
) else if /i "%__VSVersion%" == "vs2015" (
set "__VSToolsRoot=%VS140COMNTOOLS%"
set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC"

set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
if not exist !_msbuildexe! set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
)

:: Does VS really exist?
Expand Down Expand Up @@ -723,7 +722,7 @@ echo.
echo./? -? /h -h /help -help - View this message.
echo ^<build_architecture^> - Specifies build architecture: x64, x86, arm, or arm64 ^(default: x64^).
echo ^<build_type^> - Specifies build type: Debug, Release, or Checked ^(default: Debug^).
echo VSVersion ^<vs_version^> - VS2015 or VS2017 ^(default: VS2017^).
echo VSVersion ^<vs_version^> - VS2017 or VS2019 ^(default: VS2019^).
echo TestEnv ^<test_env_script^> - Run a custom script before every test to set custom test environment settings.
echo AgainstPackages - This indicates that we are running tests that were built against packages.
echo GenerateLayoutOnly - If specified will not run the tests and will only create the Runtime Dependency Layout
Expand Down Expand Up @@ -769,6 +768,6 @@ echo %0 x64 release
exit /b 1

:NoVS
echo Visual Studio 2015 or 2017 ^(Community is free^) is a prerequisite to build this repository.
echo Visual Studio 2017 or 2019 ^(Community is free^) is a prerequisite to build this repository.
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
exit /b 1
Loading

0 comments on commit f28a4f0

Please sign in to comment.