mirror of https://github.com/dotnet/runtime
[mono] Improve mono.proj, auto-detect build configurations (#31739)
* Auto-detect build configuration in Makefile * Improve RunCoreClrTests target * Clone .dotnet to .dotnet-mono * Implement Console
This commit is contained in:
parent
e8dc3a1d34
commit
134b198b96
|
@ -4,6 +4,7 @@ syntax: glob
|
|||
|
||||
# Tool Runtime Dir
|
||||
.dotnet/
|
||||
.dotnet-mono/
|
||||
.packages/
|
||||
.tools/
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<DotNetExec Condition="'$(DotNetExec)' == ''">dotnet</DotNetExec>
|
||||
<LocalDotnetDir>..\..\.dotnet</LocalDotnetDir>
|
||||
<LocalDotnet>$(LocalDotnetDir)\$(DotNetExec)</LocalDotnet>
|
||||
<LocalMonoDotnetDir>..\..\.dotnet-mono</LocalMonoDotnetDir>
|
||||
<LocalMonoDotnet>$(LocalMonoDotnetDir)\$(DotNetExec)</LocalMonoDotnet>
|
||||
<ScriptExt Condition="'$(OS)' == 'Windows_NT'">.cmd</ScriptExt>
|
||||
<ScriptExt Condition="'$(OS)' != 'Windows_NT'">.sh</ScriptExt>
|
||||
<_CoreClrFileName Condition="'$(TargetsWindows)' == 'true'">coreclr.dll</_CoreClrFileName>
|
||||
|
@ -56,6 +58,12 @@
|
|||
<Exec Command="msvc\run-msbuild.bat build $(_MonoBuildPlatform) $(Configuration) sgen "$(_MonoBuildParams)" msvc\mono-netcore.sln" IgnoreStandardErrorWarningFormat="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildCoreLib">
|
||||
<MSBuild Projects="$(MonoProjectRoot)netcore\System.Private.CoreLib\System.Private.CoreLib.csproj"
|
||||
Properties="Configuration=$(Configuration)"
|
||||
Targets="Build" />
|
||||
</Target>
|
||||
|
||||
<!-- General targets -->
|
||||
<Target Name="Build" DependsOnTargets="BuildMonoRuntimeUnix;BuildMonoRuntimeWindows">
|
||||
<PropertyGroup>
|
||||
|
@ -88,25 +96,19 @@
|
|||
|
||||
<Target Name="Test" />
|
||||
|
||||
<!-- Copy Mono runtime bits to the local .dotnet dir for local experiments (temp solution) -->
|
||||
<Target Name="PatchLocalDotnet" DependsOnTargets="ValidateLocalDotnet">
|
||||
<PropertyGroup>
|
||||
<LocalDotnetRuntimeDir>$([System.IO.Directory]::GetDirectories("$(LocalDotnetDir)\shared\Microsoft.NETCore.App")[0])</LocalDotnetRuntimeDir>
|
||||
</PropertyGroup>
|
||||
<!-- Copy Mono runtime bits to the local .dotnet-mono (clone of .dotnet) dir for local experiments (temp solution) -->
|
||||
<Target Name="PatchLocalMonoDotnet" DependsOnTargets="ValidateLocalDotnet">
|
||||
<ItemGroup>
|
||||
<_LocalDotnetFiles Include="$(LocalDotnetDir)\**\*.*" />
|
||||
<_MonoRuntimeArtifacts Include="$(BinDir)\*.*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="$(_MonoRuntimeArtifacts)"
|
||||
DestinationFolder="$(LocalDotnetRuntimeDir)"
|
||||
<Error Condition="@(_MonoRuntimeArtifacts->Count()) < 2" Text="Mono artifacts were not found at $(BinDir)" />
|
||||
<!-- copy .dotnet to .dotnet-mono if it doesn't exist -->
|
||||
<Copy SourceFiles="@(_LocalDotnetFiles)"
|
||||
DestinationFolder="$(LocalMonoDotnetDir)\%(RecursiveDir)"
|
||||
SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
<!-- Copy Coreclr runtime bits to the local .dotnet dir -->
|
||||
<Target Name="RestoreLocalDotnet" DependsOnTargets="ValidateLocalDotnet">
|
||||
<Copy SourceFiles="$(CoreCLRArtifactsPath)\System.Private.CoreLib.dll"
|
||||
DestinationFiles="$(LocalDotnetRuntimeDir)\System.Private.CoreLib.dll" />
|
||||
<Copy SourceFiles="$(CoreCLRArtifactsPath)\$(_CoreClrFileName)"
|
||||
DestinationFiles="$(LocalDotnetRuntimeDir)\$(_CoreClrFileName)" />
|
||||
<Copy SourceFiles="@(_MonoRuntimeArtifacts)"
|
||||
DestinationFolder="$([System.IO.Directory]::GetDirectories('$(LocalMonoDotnetDir)\shared\Microsoft.NETCore.App')[0])" />
|
||||
</Target>
|
||||
|
||||
<!-- Copy Mono runtime bits to the coreclr's Core_Root in order to run runtime tests -->
|
||||
|
@ -115,9 +117,9 @@
|
|||
<ItemGroup>
|
||||
<_MonoRuntimeArtifacts Include="$(BinDir)\*.*" />
|
||||
</ItemGroup>
|
||||
<Error Condition="@(_MonoRuntimeArtifacts->Count()) < 2" Text="Mono artifacts were not found at $(BinDir)" />
|
||||
<Copy SourceFiles="@(_MonoRuntimeArtifacts)"
|
||||
DestinationFolder="$(CoreClrTestCoreRoot)"
|
||||
SkipUnchangedFiles="true"/>
|
||||
DestinationFolder="$(CoreClrTestCoreRoot)" />
|
||||
</Target>
|
||||
|
||||
<!-- Copy Coreclr runtime bits back to Core_Root -->
|
||||
|
@ -129,8 +131,16 @@
|
|||
</Target>
|
||||
|
||||
<!-- Run netcore\sample\HelloWorld sample using Mono Runtime -->
|
||||
<Target Name="RunSample" DependsOnTargets="PatchLocalDotnet">
|
||||
<Exec Command="$(LocalDotnet) run -c Release -f $(NetCoreAppCurrent) -p $(MonoProjectRoot)netcore\sample\HelloWorld" />
|
||||
<Target Name="RunSample" DependsOnTargets="PatchLocalMonoDotnet">
|
||||
<PropertyGroup>
|
||||
<EnvVars Condition="'$(OS)' != 'Windows_NT'"><![CDATA[
|
||||
COMPlus_DebugWriteToStdErr=1 \
|
||||
MONO_ENV_OPTIONS="" \
|
||||
]]>
|
||||
</EnvVars>
|
||||
</PropertyGroup>
|
||||
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="$(EnvVars) $(LocalMonoDotnet) run -c $(Configuration) -p $(MonoProjectRoot)netcore/sample/HelloWorld" />
|
||||
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="$(EnvVars) $(LocalMonoDotnet) run -c $(Configuration) -p $(MonoProjectRoot)netcore\sample\HelloWorld" />
|
||||
</Target>
|
||||
|
||||
<!-- Run CoreCLR runtime test using testhost -->
|
||||
|
@ -139,25 +149,15 @@
|
|||
<Exec Command="$(CoreClrTest) -coreroot="$(CoreClrTestCoreRoot)""/>
|
||||
</Target>
|
||||
|
||||
<!-- Make sure coreclr tests are built (in $(CoreClrTestConfig) configuration), e.g.
|
||||
*nix: `cd ../coreclr && ./build.sh -release && ./build-testh.sh -release`
|
||||
Windows: `cd ../coreclr && build.cmd -release` -->
|
||||
<!-- Run coreclr tests using runtest.py -->
|
||||
<Target Name="RunCoreClrTests" DependsOnTargets="ValidateLocalDotnet;PatchCoreClrCoreRoot">
|
||||
<ItemGroup>
|
||||
<CoreClrTests Include="$(ArtifactsDir)tests\coreclr\$(OSGroup).$(Platform).$(CoreClrTestConfig)\**\*$(ScriptExt)" />
|
||||
</ItemGroup>
|
||||
<Exec Condition="'$(OS)' == 'Windows_NT'" Command=""%(CoreClrTests.Identity)" -coreroot "$(CoreClrTestCoreRoot)"" ContinueOnError="WarnAndContinue" />
|
||||
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="bash "%(CoreClrTests.Identity)" -coreroot="$(CoreClrTestCoreRoot)"" ContinueOnError="WarnAndContinue" />
|
||||
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="$(MonoProjectRoot)..\coreclr\tests\runtest.cmd $(CoreClrTestConfig)" ContinueOnError="ErrorAndContinue" />
|
||||
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="$(MonoProjectRoot)../coreclr/tests/./runtest.sh $(CoreClrTestConfig)" ContinueOnError="ErrorAndContinue" />
|
||||
</Target>
|
||||
|
||||
<!-- Show summary for coreclr tests -->
|
||||
<Target Name="CoreClrTestsSummary">
|
||||
<Exec Command="python $(MonoProjectRoot)..\coreclr\tests\runtest.py --analyze_results_only -test_location $(ArtifactsDir)tests\coreclr\$(OSGroup).$(Platform).$(CoreClrTestConfig) -build_type $(CoreClrTestConfig)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RunBenchmarks">
|
||||
<Target Name="RunBenchmarks" DependsOnTargets="PatchLocalMonoDotnet">
|
||||
<Error Condition="$(BenchmarksRepo) == ''" Text="BenchmarksRepo variable is not set" />
|
||||
<Exec WorkingDirectory="$(BenchmarksRepo)\src\benchmarks\micro" Command="$(LocalDotnet) run -c Release -f $(NetCoreAppCurrent) --cli $(LocalDotnet)" />
|
||||
<Exec WorkingDirectory="$(BenchmarksRepo)\src\benchmarks\micro" Command="$(LocalDotnet) run -c Release -f $(NetCoreAppCurrent) --cli $(LocalMonoDotnet)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="ValidateLocalDotnet">
|
||||
|
|
|
@ -1,35 +1,46 @@
|
|||
DOTNET=../../../.dotnet/dotnet
|
||||
DOTNET := $(shell bash init-tools.sh | tail -1)
|
||||
# DOTNET_MONO is a copy of DOTNET (local .dotnet) with Mono Runtime bits (see patch-mono-dotnet rule)
|
||||
DOTNET_MONO = ../../../.dotnet-mono/dotnet
|
||||
|
||||
# run sample using local .dotnet (will be patched with Mono Runtime)
|
||||
run-sample:
|
||||
$(DOTNET) msbuild /t:RunSample ../mono.proj
|
||||
CORECLR_TESTS_CONFIG=Release
|
||||
MONO_RUNTIME_CONFIG=Release
|
||||
|
||||
# auto detect configurations for mono runtime and coreclr tests
|
||||
ifeq ($(words $(wildcard ../../../artifacts/bin/mono/*.*.*)), 1)
|
||||
MONO_RUNTIME_CONFIG := $(word 3,$(subst ., ,$(notdir $(wildcard ../../../artifacts/bin/mono/*.*.*))))
|
||||
endif
|
||||
|
||||
ifeq ($(words $(wildcard ../../../artifacts/tests/coreclr/*.*.*)), 1)
|
||||
CORECLR_TESTS_CONFIG := $(word 3,$(subst ., ,$(notdir $(wildcard ../../../artifacts/tests/coreclr/*.*.*))))
|
||||
endif
|
||||
|
||||
MONO_PROJ=/p:CoreClrTestConfig=$(CORECLR_TESTS_CONFIG) /p:Configuration=$(MONO_RUNTIME_CONFIG) ../mono.proj
|
||||
|
||||
# run sample using local .dotnet-mono
|
||||
run-sample: patch-mono-dotnet
|
||||
COMPlus_DebugWriteToStdErr=1 $(DOTNET_MONO) run -c Debug -p sample/HelloWorld
|
||||
|
||||
# run sample using dotnet from PATH
|
||||
run-sample-coreclr:
|
||||
dotnet run -c Release -p sample/HelloWorld -f netcoreapp3.1
|
||||
$(DOTNET) run -c Debug -p sample/HelloWorld
|
||||
|
||||
bcl corelib:
|
||||
$(DOTNET) msbuild /t:BuildCoreLib $(MONO_PROJ)
|
||||
|
||||
runtime:
|
||||
$(DOTNET) msbuild /t:Build ../mono.proj
|
||||
$(DOTNET) msbuild /t:Build $(MONO_PROJ)
|
||||
|
||||
# temp: makes $(DOTNET) to use mono runtime (to run real-world apps using '$(DOTNET) run')
|
||||
patch-local-dotnet:
|
||||
$(DOTNET) msbuild /t:PatchLocalDotnet ../mono.proj
|
||||
|
||||
restore-local-dotnet:
|
||||
$(DOTNET) msbuild /t:RestoreLocalDotnet ../mono.proj
|
||||
# call it if you want to use $(DOTNET_MONO) in this Makefile
|
||||
patch-mono-dotnet:
|
||||
$(DOTNET) msbuild /t:PatchLocalMonoDotnet $(MONO_PROJ)
|
||||
|
||||
# run specific coreclr test, e.g.:
|
||||
# make run-tests-coreclr CoreClrTest="bash ../../artifacts/tests/coreclr/OSX.x64.Checked/JIT/opt/InstructionCombining/DivToMul/DivToMul.sh"
|
||||
# make run-tests-coreclr CoreClrTest="bash ../../artifacts/tests/coreclr/OSX.x64.Release/JIT/opt/InstructionCombining/DivToMul/DivToMul.sh"
|
||||
run-tests-coreclr:
|
||||
$(DOTNET) msbuild /t:RunCoreClrTest /p:CoreClrTest="$(CoreClrTest)" ../mono.proj
|
||||
$(DOTNET) msbuild /t:RunCoreClrTest /p:CoreClrTest="$(CoreClrTest)" $(MONO_PROJ)
|
||||
|
||||
# run all coreclr tests
|
||||
run-tests-coreclr-all:
|
||||
$(DOTNET) msbuild /t:RunCoreClrTests ../mono.proj
|
||||
|
||||
# show summary for coreclr tests
|
||||
tests-coreclr-summary:
|
||||
$(DOTNET) msbuild /t:CoreClrTestsSummary ../mono.proj
|
||||
$(DOTNET) msbuild /t:RunCoreClrTests $(MONO_PROJ)
|
||||
|
||||
# run 'dotnet/performance' benchmarks
|
||||
# e.g. 'make run-benchmarks BenchmarksRepo=/prj/performance'
|
||||
|
|
|
@ -143,6 +143,7 @@
|
|||
|
||||
<!-- Sources -->
|
||||
<ItemGroup>
|
||||
<Compile Include="$(BclSourcesRoot)\Mono\Console.Mono.cs" />
|
||||
<Compile Include="$(BclSourcesRoot)\Mono\MonoListItem.cs" />
|
||||
<Compile Include="$(BclSourcesRoot)\Mono\MonoDomain.cs" />
|
||||
<Compile Include="$(BclSourcesRoot)\Mono\MonoDomainSetup.cs" />
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
// Some CoreCLR tests use it for internal printf-style debugging in System.Private.CoreLib
|
||||
public static class Console
|
||||
{
|
||||
public static void Write(string? s) => DebugProvider.WriteCore(s);
|
||||
|
||||
public static void WriteLine(string? s) => Write(s + Environment.NewLineConst);
|
||||
|
||||
public static void WriteLine() => Write(Environment.NewLineConst);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# always ignore system dotnet
|
||||
export use_installed_dotnet_cli=false
|
||||
. "../../../eng/common/tools.sh"
|
||||
InitializeDotNetCli true
|
||||
which dotnet
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputPath>bin</OutputPath>
|
||||
<TargetFrameworks>$(NetCoreAppCurrent);netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
Loading…
Reference in New Issue