Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Android NDK to r27c and update to 16kb alignment #3096

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions native/android/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ DirectoryPath ANDROID_NDK_HOME = Argument("ndk", EnvironmentVariable("ANDROID_ND
string SUPPORT_VULKAN_VAR = Argument ("supportVulkan", EnvironmentVariable ("SUPPORT_VULKAN") ?? "true");
bool SUPPORT_VULKAN = SUPPORT_VULKAN_VAR == "1" || SUPPORT_VULKAN_VAR.ToLower () == "true";

Information("Android NDK Path: {0}", ANDROID_NDK_HOME);
Information("Building Vulkan: {0}", SUPPORT_VULKAN);

void CheckAlignment(FilePath so)
{
Information($"Making sure that everything is 16 KB aligned...");

var prebuilt = ANDROID_NDK_HOME.CombineWithFilePath("toolchains/llvm/prebuilt").FullPath;
var objdump = GetFiles($"{prebuilt}/*/bin/llvm-objdump*").FirstOrDefault() ?? throw new Exception("Could not find llvm-objdump");
RunProcess(objdump.FullPath, $"-p {so}", out var stdout);

var loads = stdout
.Where(l => l.Trim().StartsWith("LOAD"))
.ToList();

if (loads.Any(l => !l.Trim().EndsWith("align 2**14"))) {
Information(String.Join(Environment.NewLine + " ", stdout));
throw new Exception($"{so} contained a LOAD that was not 16 KB aligned.");
} else {
Information("Everything is 16 KB aligned:");
Information(String.Join(Environment.NewLine, loads));
}
}

Task("libSkiaSharp")
.IsDependentOn("git-sync-deps")
.WithCriteria(IsRunningOnMacOs() || IsRunningOnWindows())
Expand Down Expand Up @@ -38,12 +62,15 @@ Task("libSkiaSharp")
$"skia_use_vulkan={SUPPORT_VULKAN} ".ToLower () +
$"skia_enable_skottie=true " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_SYSCALL_GETRANDOM', '-DXML_DEV_URANDOM' ] " +
$"extra_ldflags=[ '-Wl,-z,max-page-size=16384' ] " +
$"ndk='{ANDROID_NDK_HOME}' " +
$"ndk_api=21");

var so = SKIA_PATH.CombineWithFilePath($"out/android/{arch}/libSkiaSharp.so");
var outDir = OUTPUT_PATH.Combine(arch);
EnsureDirectoryExists(outDir);
CopyFileToDirectory(SKIA_PATH.CombineWithFilePath($"out/android/{arch}/libSkiaSharp.so"), outDir);
CopyFileToDirectory(so, outDir);
CheckAlignment(so);
}
});

Expand All @@ -68,9 +95,11 @@ Task("libHarfBuzzSharp")
WorkingDirectory = "libHarfBuzzSharp",
});

var so = $"libHarfBuzzSharp/libs/{arch}/libHarfBuzzSharp.so";
var outDir = OUTPUT_PATH.Combine(arch);
EnsureDirectoryExists(outDir);
CopyFileToDirectory($"libHarfBuzzSharp/libs/{arch}/libHarfBuzzSharp.so", outDir);
CopyFileToDirectory(so, outDir);
CheckAlignment(so);
}
});

Expand Down
1 change: 1 addition & 0 deletions native/android/libHarfBuzzSharp/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ APP_PLATFORM := android-21
NDK_TOOLCHAIN_VERSION := clang
APP_STL := c++_static
APP_OPTIM := release
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
2 changes: 1 addition & 1 deletion native/android/libHarfBuzzSharp/jni/HarfBuzzSharp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LOCAL_MODULE := HarfBuzzSharp

LOCAL_C_INCLUDES := . $(src_root) $(ext_root)

LOCAL_LDFLAGS := -s -Wl,--gc-sections
LOCAL_LDFLAGS := -s -Wl,--gc-sections -Wl,-z,max-page-size=16384

LOCAL_CFLAGS := -DNDEBUG \
-DHAVE_CONFIG_OVERRIDE_H -DHAVE_OT -DHB_NO_FALLBACK_SHAPE \
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-android-ndk.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Param(
[string] $Version = "r25c",
[string] $Version = "r27c",
[string] $InstallDestination = $null
)

Expand Down
Loading