From eeaef4f5debdc07f2556c23f7ea0235fdf2def0e Mon Sep 17 00:00:00 2001 From: Patrick Goldinger Date: Fri, 2 Jun 2023 00:30:18 +0200 Subject: [PATCH] Fix ICU build for Android unnecessarily building for host for every arch This should improve compile performance for workflow runners. --- app/.gitignore | 2 +- app/build.gradle.kts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/.gitignore b/app/.gitignore index b1fe6a0f..c0f65202 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,2 +1,2 @@ # Exclude auto-generated icu4c assets -src/main/assets/icu4c/ +.cxx_icu4c diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cf6f6ad6..76022985 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -79,7 +79,8 @@ android { cppFlags("-std=c++20", "-stdlib=libc++") arguments( "-DCMAKE_ANDROID_API=" + minSdk.toString(), - "-DICU_ASSET_EXPORT_DIR=" + project.file("src/main/assets/icu4c").absolutePath, + "-DICU_ASSET_EXPORT_DIR=" + project.file(".cxx_icu4c/android/assets/icu4c").absolutePath, + "-DICU_BUILD_DIR=" + project.file(".cxx_icu4c").absolutePath, "-DBUILD_SHARED_LIBS=false", "-DANDROID_STL=c++_static", ) @@ -93,7 +94,7 @@ android { sourceSets { maybeCreate("main").apply { assets { - srcDirs("src/main/assets") + srcDirs("src/main/assets", ".cxx_icu4c/android/assets") } java { srcDirs("src/main/kotlin") @@ -187,6 +188,9 @@ android { configPath = "app/src/main/config" } + // This specific block is crucial as it forces the assets packing to be done AFTER the native code has been + // compiled. This is important as CMake generates the ICU4C data file which needs to be placed inside the assets + // dir, especially though for clean builds on workflow runners and for F-Droid. applicationVariants.all { assembleProvider.configure { dependsOn(javaCompileProvider.get())