Skip to content

Commit 182f2c2

Browse files
committed
[build] Use API-21 for all native builds
Up until this commit, we have been building the 64-bit targets (`x86-64` and `armv8-a` against NDK API 21 while the 32-bit targets (`x86` and `armv7-a`) against NDK API 16. This commit changes it so that all targets build against API 21. This gives us the ability to speed up Debug builds on 32-bit platforms via use of POSIX APIs for directory traversal that are available starting from API 21 onwards (`openat` and `fstatat`). The switch to API 21 was initially planned for .NET5 but there's no harm in making the change now.
1 parent ee3a0c5 commit 182f2c2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class BuildAndroidPlatforms
4242
};
4343

4444
public static readonly Dictionary<string, uint> NdkMinimumAPI = new Dictionary<string, uint> {
45-
{ AbiNames.TargetJit.AndroidArmV7a, 16 },
45+
{ AbiNames.TargetJit.AndroidArmV7a, 21 },
4646
{ AbiNames.TargetJit.AndroidArmV8a, 21 },
47-
{ AbiNames.TargetJit.AndroidX86, 16 },
47+
{ AbiNames.TargetJit.AndroidX86, 21 },
4848
{ AbiNames.TargetJit.AndroidX86_64, 21 },
4949
};
5050
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void TestNdkUtil ()
4141
Assert.IsTrue (NdkUtil.ValidateNdkPlatform (log, ndkDir, arch, enableLLVM: false));
4242
Assert.AreEqual (0, errors.Count, "NdkUtil.ValidateNdkPlatform should not have returned false.");
4343
int level = NdkUtil.GetMinimumApiLevelFor (arch, ndkDir);
44-
int expected = 16;
44+
int expected = 21;
4545
Assert.AreEqual (expected, level, $"Min Api Level for {arch} should be {expected}.");
4646
var compilerNoQuotes = NdkUtil.GetNdkTool (ndkDir, arch, "gcc", level);
4747
Assert.AreEqual (0, errors.Count, "NdkUtil.GetNdkTool should not have errored.");

src/monodroid/jni/embedded-assemblies.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ EmbeddedAssemblies::typemap_read_header ([[maybe_unused]] int dir_fd, const char
583583
struct stat sbuf;
584584
int res;
585585

586-
#if __ANDROID_API__ < 21
586+
#if defined (WINDOWS)
587587
simple_pointer_guard<char[]> full_file_path = utils.path_combine (dir_path, file_path);
588588
res = stat (full_file_path, &sbuf);
589589
#else
@@ -600,7 +600,7 @@ EmbeddedAssemblies::typemap_read_header ([[maybe_unused]] int dir_fd, const char
600600
return false;
601601
}
602602

603-
#if __ANDROID_API__ < 21
603+
#if defined (WINDOWS)
604604
fd = open (full_file_path, O_RDONLY);
605605
#else
606606
fd = openat (dir_fd, file_path, O_RDONLY);
@@ -800,7 +800,7 @@ EmbeddedAssemblies::try_load_typemaps_from_directory (const char *path)
800800
}
801801

802802
int dir_fd;
803-
#if __ANDROID_API__ < 21
803+
#if WINDOWS
804804
dir_fd = -1;
805805
#else
806806
dir_fd = dirfd (dir);

0 commit comments

Comments
 (0)