Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Dec 3, 2024
1 parent e069e56 commit 842419f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
32 changes: 30 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 @@ -42,9 +66,11 @@ Task("libSkiaSharp")
$"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 @@ -69,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
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

0 comments on commit 842419f

Please sign in to comment.