[build] Create clr.host subset to remove patching step for mono runtime tests (#62500)
authorNathan Ricci <naricc@microsoft.com>
Thu, 9 Dec 2021 03:07:08 +0000 (22:07 -0500)
committerGitHub <noreply@github.com>
Thu, 9 Dec 2021 03:07:08 +0000 (22:07 -0500)
* [build] Define a component and subset for corerun and copy mono runtime files to coreroot.

eng/Subsets.props
src/coreclr/build-runtime.cmd
src/coreclr/build-runtime.sh
src/coreclr/components.cmake
src/coreclr/hosts/corerun/CMakeLists.txt
src/coreclr/hosts/coreshim/CMakeLists.txt
src/coreclr/runtime.proj
src/tests/Common/Directory.Build.targets

index 65da9d8..b76d849 100644 (file)
     <SubsetName Include="Clr.Native" Description="All CoreCLR native non-test components, including the runtime, jits, and other native tools." />
     <SubsetName Include="Clr.PalTests" OnDemand="true" Description="The CoreCLR PAL tests." />
     <SubsetName Include="Clr.PalTestList" OnDemand="true" Description="Generate the list of the CoreCLR PAL tests. When using the command line, use Clr.PalTests instead." />
+    <SubsetName Include="Clr.Hosts" Description="The CoreCLR corerun test host." />
     <SubsetName Include="Clr.Jit" Description="The JIT for the CoreCLR .NET runtime." />
     <SubsetName Include="Clr.AllJits" Description="All of the cross-targeting JIT compilers for the CoreCLR .NET runtime." />
     <SubsetName Include="Clr.CoreLib" Description="The managed System.Private.CoreLib library for CoreCLR." />
     <ProjectToBuild Include="$(CoreClrProjectRoot)System.Private.CoreLib\System.Private.CoreLib.csproj" Category="clr" />
   </ItemGroup>
 
+  <PropertyGroup Condition="$(_subset.Contains('+clr.hosts+'))">
+    <ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrHostsSubset=true</ClrRuntimeBuildSubsets>
+  </PropertyGroup>
+
   <PropertyGroup Condition="$(_subset.Contains('+clr.runtime+'))">
     <ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrRuntimeSubset=true</ClrRuntimeBuildSubsets>
   </PropertyGroup>
index dc17395..d14d061 100644 (file)
@@ -324,6 +324,9 @@ if NOT DEFINED PYTHON (
 set __CMakeTarget=
 for /f "delims=" %%a in ("-%__RequestedBuildComponents%-") do (
     set "string=%%a"
+    if not "!string:-hosts-=!"=="!string!" (
+        set __CMakeTarget=!__CMakeTarget! hosts
+    )
     if not "!string:-jit-=!"=="!string!" (
         set __CMakeTarget=!__CMakeTarget! jit
     )
@@ -739,7 +742,7 @@ echo -all: Builds all configurations and platforms.
 echo Build architecture: one of -x64, -x86, -arm, -arm64 ^(default: -x64^).
 echo Build type: one of -Debug, -Checked, -Release ^(default: -Debug^).
 echo -component ^<name^> : specify this option one or more times to limit components built to those specified.
-echo                     Allowed ^<name^>: jit alljits runtime paltests iltools
+echo                     Allowed ^<name^>: hosts jit alljits runtime paltests iltools
 echo -enforcepgo: verify after the build that PGO was used for key DLLs, and fail the build if not
 echo -pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.
 echo -cmakeargs: user-settable additional arguments passed to CMake.
index 7adfb63..cbf18f6 100755 (executable)
@@ -22,7 +22,7 @@ usage_list+=("-pgodatapath: path to profile guided optimization data.")
 usage_list+=("-pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.")
 usage_list+=("-skipcrossarchnative: Skip building cross-architecture native binaries.")
 usage_list+=("-staticanalyzer: use scan_build static analyzer.")
-usage_list+=("-component: Build individual components instead of the full project. Available options are 'jit', 'runtime', 'paltests', 'alljits', and 'iltools'. Can be specified multiple times.")
+usage_list+=("-component: Build individual components instead of the full project. Available options are 'hosts', 'jit', 'runtime', 'paltests', 'alljits', and 'iltools'. Can be specified multiple times.")
 
 setup_dirs_local()
 {
index 01d3db0..81ec07a 100644 (file)
@@ -1,6 +1,7 @@
 # Define all the individually buildable components of the CoreCLR build and their respective targets
 add_component(jit)
 add_component(alljits)
+add_component(hosts)
 add_component(runtime)
 add_component(paltests paltests_install)
 add_component(iltools)
@@ -16,5 +17,7 @@ add_dependencies(runtime coreclr_misc)
 # The runtime build requires the clrjit and iltools builds
 add_dependencies(runtime jit iltools)
 
+add_dependencies(runtime hosts)
+
 # The cross-components build is separate, so we don't need to add a dependency on coreclr_misc
 add_component(crosscomponents)
index ef20f57..b95f4c8 100644 (file)
@@ -32,4 +32,4 @@ else(CLR_CMAKE_HOST_WIN32)
     endif()
 endif(CLR_CMAKE_HOST_WIN32)
 
-install_clr(TARGETS corerun DESTINATIONS . COMPONENT runtime)
+install_clr(TARGETS corerun DESTINATIONS . COMPONENT hosts)
index 5c6a2fd..e25caf7 100644 (file)
@@ -22,4 +22,4 @@ target_link_libraries(CoreShim
     ${STATIC_MT_VCRT_LIB}
 )
 
-install_clr(TARGETS CoreShim DESTINATIONS . COMPONENT runtime)
+install_clr(TARGETS CoreShim DESTINATIONS . COMPONENT hosts)
index 39b2074..7c8a68a 100644 (file)
@@ -41,6 +41,7 @@
     </ItemGroup>
 
     <ItemGroup Condition="'$(ClrFullNativeBuild)' != 'true'">
+      <_CoreClrBuildArg Condition="'$(ClrHostsSubset)' == 'true'" Include="-component hosts" />
       <_CoreClrBuildArg Condition="'$(ClrRuntimeSubset)' == 'true'" Include="-component runtime" />
       <_CoreClrBuildArg Condition="'$(ClrJitSubset)' == 'true'" Include="-component jit" />
       <_CoreClrBuildArg Condition="'$(ClrPalTestsSubset)' == 'true'" Include="-component paltests" />
index e003e2d..cdf1321 100644 (file)
@@ -16,6 +16,8 @@
     <GCStressDependsOnCoreDisTools Condition="'$(TargetOS)' == 'Linux' And '$(TargetArchitecture)' == 'x64'">true</GCStressDependsOnCoreDisTools>
     <CopyCoreDisToolsToCoreRoot>false</CopyCoreDisToolsToCoreRoot>
     <CopyCoreDisToolsToCoreRoot Condition="$(GCStressDependsOnCoreDisTools) And '$(DotNetBuildFromSource)' != 'true'">true</CopyCoreDisToolsToCoreRoot>
+    <!-- Non-desktop OS's use a custom dotnet host, instead of corerun -->
+    <IsDesktopOS Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsAndroid)' != 'true' and '$(TargetstvOS)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetsMacCatalyst)' != 'true'">true</IsDesktopOS>
   </PropertyGroup>
 
   <Import Project="$(RepositoryEngineeringDir)coredistools.targets" Condition="$(CopyCoreDisToolsToCoreRoot)" />
           Include="$(CoreCLRArtifactsPath)%(RunTimeArtifactsIncludeFolders.Identity)**/*"
           Exclude="@(RunTimeArtifactsExcludeFiles -> '$(CoreCLRArtifactsPath)%(Identity)')"
           TargetDir="%(RunTimeArtifactsIncludeFolders.Identity)" />
+
+    
     </ItemGroup>
 
     <PropertyGroup>
       <RunTimeDependencyCopyLocal Include="$(CoreDisToolsLibrary)" Condition="$(CopyCoreDisToolsToCoreRoot)" />
     </ItemGroup>
 
+    <ItemGroup Condition="'$(RuntimeFlavor)' == 'mono' and '$(IsDesktopOS)' == 'true' " >
+      <RuntimeDependencyCopyLocal Include="$(MonoArtifactsPath)/libcoreclr$(LibSuffix)" TargetDir=""  />
+      <RuntimeDependencyCopyLocal Include="$(MonoArtifactsPath)/libmono-component-*" TargetDir=""  />
+       <RuntimeDependencyCopyLocal Include="$(MonoArtifactsPath)/*.dll" TargetDir="/"  />
+    </ItemGroup>
+
     <Copy
       SourceFiles="@(RunTimeDependencyCopyLocal)"
       DestinationFiles="@(RunTimeDependencyCopyLocal -> '$(CORE_ROOT)/%(TargetDir)%(RecursiveDir)%(Filename)%(Extension)')"