Skip to content

Commit 026cd0f

Browse files
committed
More fixes and fixlets
1 parent d3e28de commit 026cd0f

File tree

7 files changed

+40
-5
lines changed

7 files changed

+40
-5
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
9999
});
100100
if (!runtimeIdentifiers.Contains (";")) {
101101
proj.SetProperty (KnownProperties.RuntimeIdentifier, runtimeIdentifiers);
102+
103+
// When targeting CoreCLR, XamarinAndroidApplicationProject sets `RuntimeIdentifiers` to make sure that only 64-bit
104+
// targets are built. It interferes with this test when `RuntimeIdentifier` is set.
105+
proj.RemoveProperty (KnownProperties.RuntimeIdentifiers);
102106
} else {
103107
proj.SetProperty (KnownProperties.RuntimeIdentifiers, runtimeIdentifiers);
104108
}
@@ -1701,7 +1705,7 @@ public void SimilarAndroidXAssemblyNames ([Values(true, false)] bool publishTrim
17011705
{
17021706
var proj = new XamarinAndroidApplicationProject {
17031707
IsRelease = true,
1704-
AotAssemblies = publishTrimmed,
1708+
AotAssemblies = publishTrimmed && !TargetRuntimeHelper.UseCoreCLR,
17051709
PackageReferences = {
17061710
new Package { Id = "Xamarin.AndroidX.CustomView", Version = "1.1.0.17" },
17071711
new Package { Id = "Xamarin.AndroidX.CustomView.PoolingContainer", Version = "1.0.0.4" },

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs

+2
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ static void Test ()
595595
[NonParallelizable] // parallel NuGet restore causes failures
596596
public void BuildBasicApplicationFSharp (bool isRelease, bool aot)
597597
{
598+
TargetRuntimeHelper.IgnoreIfIncompatibleWithMonoAOT (aot);
599+
598600
var proj = new XamarinAndroidApplicationProject {
599601
Language = XamarinAndroidProjectLanguage.FSharp,
600602
IsRelease = isRelease,

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public void BuildWithNativeLibraryUnknownAbi ()
456456
},
457457
}
458458
};
459-
proj.SetAndroidSupportedAbis ("arm64-v8a", "x64");
459+
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
460460

461461
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
462462
builder.ThrowOnBuildFailure = false;

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/InvalidConfigTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class InvalidConfigTests : BaseTest
4545
[TestCaseSource (nameof (SettingCombinationsSource))]
4646
public void SettingCombinations (bool isRelease, bool useInterpreter, bool publishTrimmed, bool aot, bool expected)
4747
{
48+
TargetRuntimeHelper.IgnoreIfIncompatibleWithMonoAOT (aot);
49+
4850
var proj = new XamarinAndroidApplicationProject {
4951
IsRelease = isRelease,
5052
EnableDefaultItems = true,

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public void CheckDebugModeWithTrimming ()
8585
[NonParallelizable] // Commonly fails NuGet restore
8686
public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblyStores)
8787
{
88+
if (!usesAssemblyStores && TargetRuntimeHelper.UseCoreCLR) {
89+
Assert.Ignore ("CoreCLR supports only assembly stores");
90+
}
91+
8892
var proj = new XamarinAndroidApplicationProject {
8993
IsRelease = true
9094
};

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Diagnostics;
34
using System.IO;
45
using System.Linq;
@@ -649,7 +650,18 @@ public abstract class MyRunner {
649650
}"
650651
});
651652
var proj = new XamarinAndroidApplicationProject { IsRelease = true, ProjectName = "App1" };
652-
proj.SetRuntimeIdentifiers(["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]);
653+
654+
bool thirtyTwoBitAbisSupported =
655+
!TargetRuntimeHelper.UseCoreCLR ||
656+
(TargetRuntimeHelper.CoreClrSupportsAbi ("armeabi-v7a") && TargetRuntimeHelper.CoreClrSupportsAbi ("x86"));
657+
658+
var rids = new List<string> { "arm64-v8a", "x86_64" };
659+
if (thirtyTwoBitAbisSupported) {
660+
rids.Add ("armeabi-v7a");
661+
rids.Add ("x86");
662+
}
663+
664+
proj.SetRuntimeIdentifiers (rids);
653665
proj.References.Add(new BuildItem.ProjectReference (Path.Combine ("..", "Lib1", "Lib1.csproj"), "Lib1"));
654666
proj.MainActivity = proj.DefaultMainActivity.Replace (
655667
"base.OnCreate (bundle);",
@@ -665,11 +677,15 @@ public abstract class MyRunner {
665677

666678
var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
667679
var dll = $"{lib.ProjectName}.dll";
668-
Assert64Bit ("android-arm", expected64: false);
680+
669681
Assert64Bit ("android-arm64", expected64: true);
670-
Assert64Bit ("android-x86", expected64: false);
671682
Assert64Bit ("android-x64", expected64: true);
672683

684+
if (thirtyTwoBitAbisSupported) {
685+
Assert64Bit ("android-arm", expected64: false);
686+
Assert64Bit ("android-x86", expected64: false);
687+
}
688+
673689
void Assert64Bit(string rid, bool expected64)
674690
{
675691
var assembly = AssemblyDefinition.ReadAssembly (Path.Combine (intermediate, rid, "linked", "shrunk", dll));

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Utilities/TargetRuntimeHelper.cs

+7
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,11 @@ public static void IgnoreOnIncompatibleRuntime (string runtime)
7878
Assert.Ignore ($"{runtime} tests not supported under MonoVM");
7979
}
8080
}
81+
82+
public static void IgnoreIfIncompatibleWithMonoAOT (bool aot)
83+
{
84+
if (aot && UseCoreCLR) {
85+
Assert.Ignore ("CoreCLR runtime doesn't support MonoVM-style AOT");
86+
}
87+
}
8188
}

0 commit comments

Comments
 (0)