From 32e4d05195abe86c5a02ed38a0abd232cd5f47aa Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 16 Mar 2021 18:32:04 +0100 Subject: [PATCH] [dotnet] Add support for specifying the VM with the _XamarinRuntime property. (#10881) Use a private property (prefixed with underscore) for now, until we can decide on a better/general name. Also add a variation to xharness to build monotouch-test with CoreCLR (building works fine, but it crashes at startup, which is expected at this point). --- dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets | 2 +- dotnet/targets/Xamarin.Shared.Sdk.targets | 9 ++++++--- tests/xharness/Harness.cs | 1 + tests/xharness/Jenkins/TestData.cs | 1 + tests/xharness/Jenkins/TestVariationsFactory.cs | 7 +++++++ tools/common/Application.cs | 1 + tools/common/Target.cs | 3 ++- tools/common/XamarinRuntime.cs | 6 ++++++ tools/dotnet-linker/LinkerConfiguration.cs | 6 ++++++ tools/dotnet-linker/dotnet-linker.csproj | 3 +++ tools/mmp/mmp.csproj | 3 +++ tools/mtouch/mtouch.csproj | 3 +++ 12 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 tools/common/XamarinRuntime.cs diff --git a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets index c616714bb530..62b3f7fffff4 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets @@ -89,7 +89,7 @@ The problem is that by default we get the 'Microsoft.NETCore.App.Runtime.osx-x64' runtime pack (the core clr version), when we want the 'Microsoft.NETCore.App.Mono.Runtime.osx-x64' runtime pack. This works around that by declaring a new known framework for mono's runtime pack, removing the default 'Microsoft.NETCore.App' framework reference, and adding the mono one. --> - + <_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --custom-data "LinkerOptionsFile=$(_CustomLinkerOptionsFile)" @@ -379,8 +380,9 @@ - <_MonoNugetPackageId Condition="'$(_PlatformName)' != 'macOS'">Microsoft.NETCore.App.Runtime.$(RuntimeIdentifier) - <_MonoNugetPackageId Condition="'$(_PlatformName)' == 'macOS'">Microsoft.NETCore.App.Runtime.Mono.$(RuntimeIdentifier) + <_PackageIdInfix Condition="'$(_XamarinRuntime)' != 'CoreCLR' And '$(_PlatformName)' == 'macOS'">Mono. + + <_MonoNugetPackageId>Microsoft.NETCore.App.Runtime.$(_PackageIdInfix)$(RuntimeIdentifier) @@ -428,8 +430,9 @@ <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == ''">static <_LibXamarinExtension Condition="'$(_LibXamarinLinkMode)' == 'dylib'">dylib <_LibXamarinExtension Condition="'$(_LibXamarinLinkMode)' == 'static'">a + <_LibXamarinRuntime Condition="'$(_XamarinRuntime)' == 'CoreCLR'">-coreclr <_LibXamarinDebug Condition="'$(_BundlerDebug)' == 'true'">-debug - <_LibXamarinName Condition="'$(_LibXamarinName)' == ''">libxamarin-dotnet$(_LibXamarinDebug).$(_LibXamarinExtension) + <_LibXamarinName Condition="'$(_LibXamarinName)' == ''">libxamarin-dotnet$(_LibXamarinRuntime)$(_LibXamarinDebug).$(_LibXamarinExtension) diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 43ed1f3bd2f9..1417daa408b8 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -293,6 +293,7 @@ int AutoConfigureMac (bool generate_projects) Name = "monotouch-test", IsDotNetProject = true, TargetFrameworkFlavors = MacFlavors.DotNet, + Platform = "AnyCPU", }); foreach (var flavor in new MonoNativeFlavor [] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified }) { diff --git a/tests/xharness/Jenkins/TestData.cs b/tests/xharness/Jenkins/TestData.cs index e5966a0b5c91..5bdeefe7f49f 100644 --- a/tests/xharness/Jenkins/TestData.cs +++ b/tests/xharness/Jenkins/TestData.cs @@ -18,6 +18,7 @@ class TestData public bool? Ignored; public bool EnableSGenConc; public bool UseThumb; + public string XamarinRuntime; public MonoNativeLinkMode MonoNativeLinkMode; public IEnumerable Candidates; } diff --git a/tests/xharness/Jenkins/TestVariationsFactory.cs b/tests/xharness/Jenkins/TestVariationsFactory.cs index b966568ffb54..df9b1a3f02f1 100644 --- a/tests/xharness/Jenkins/TestVariationsFactory.cs +++ b/tests/xharness/Jenkins/TestVariationsFactory.cs @@ -115,6 +115,10 @@ IEnumerable GetTestData (RunTestTask test) case "AnyCPU": case "x86": switch (test.TestName) { + case "monotouch-test": + if (test.TestProject.IsDotNetProject) + yield return new TestData { Variation = "Debug (CoreCLR)", Debug = true, XamarinRuntime = "CoreCLR", Ignored = true, }; + break; case "xammac tests": switch (test.ProjectConfiguration) { case "Release": @@ -157,6 +161,7 @@ public IEnumerable CreateTestVariations (IEnumerable tests, Func CreateTestVariations (IEnumerable tests, Func (value, out var rv)) + throw new InvalidOperationException ($"Invalid XamarinRuntime '{value}' in {linker_file}"); + Application.XamarinRuntime = rv; + break; default: throw new InvalidOperationException ($"Unknown key '{key}' in {linker_file}"); } @@ -291,6 +296,7 @@ public void Write () Console.WriteLine ($" SdkVersion: {SdkVersion}"); Console.WriteLine ($" UseInterpreter: {Application.UseInterpreter}"); Console.WriteLine ($" Verbosity: {Verbosity}"); + Console.WriteLine ($" XamarinRuntime: {Application.XamarinRuntime}"); } } diff --git a/tools/dotnet-linker/dotnet-linker.csproj b/tools/dotnet-linker/dotnet-linker.csproj index 71afb5b5dc91..5dcbeed3d808 100644 --- a/tools/dotnet-linker/dotnet-linker.csproj +++ b/tools/dotnet-linker/dotnet-linker.csproj @@ -191,6 +191,9 @@ external\tools\common\DlsymOptions.cs + + tools\common\XamarinRuntime.cs + diff --git a/tools/mmp/mmp.csproj b/tools/mmp/mmp.csproj index e6b821302444..a8a4867caa84 100644 --- a/tools/mmp/mmp.csproj +++ b/tools/mmp/mmp.csproj @@ -467,6 +467,9 @@ tools\common\DlsymOptions.cs + + tools\common\XamarinRuntime.cs + diff --git a/tools/mtouch/mtouch.csproj b/tools/mtouch/mtouch.csproj index 494e77df995d..e8c2e55ec97d 100644 --- a/tools/mtouch/mtouch.csproj +++ b/tools/mtouch/mtouch.csproj @@ -481,6 +481,9 @@ tools\common\DlsymOptions.cs + + tools\common\XamarinRuntime.cs +