External 3rd party NDK dependency for app

Hello there!

Since the last F-Droid release of my app FlorisBoard I’ve added an external dependency to my app, namely ICU (or ICU4C to be more precise). As there’s not really a standard way to include ICU for native C++ on Android, I’ve set up a custom build script to cross-compile ICU for all targeted ABIs. The cross-compile process is time consuming though, so I’ve then added the prebuilt output from my local machine to the build repository and re-use the library files. This works perfectly fine for releases on GitHub or on Google Play, but for F-Droid I cannot use these prebuilt files, as they would count as binary blobs. The ICU source code + build script and the prebuilt ICU library files are stored in this repository: GitHub - florisboard/icu4c: Build repository for FlorisBoard external dependency ICU4C and are included as a git submodule in the main app repository.

The question now is, is there a way for F-Droid to build the ICU library once from source and then re-use it? The compiled ICU files will rarely change, only when I either have to change the data configuration or if I upgrade the ICU version, so it would make sense to use the library files for multiple app builds. I’ve done some research before asking and the only thing I found was the srclibs field in the recipe, but I couldn’t really find more info how these work and if they also work for NDK-related libraries.

Thanks in advance for the help!

1 Like

I cannot use these prebuilt files, as they would count as binary blobs

Yep.

The question now is, is there a way for F-Droid to build the ICU library once from source and then re-use it?

No.

The compiled ICU files will rarely change, only when I either have to change the data configuration or if I upgrade the ICU version, so it would make sense to use the library files for multiple app builds.

Is ICU compilation too time-consuming? If it takes less than several hours to build, I see no problem compiling it from source every time.

Is ICU compilation too time-consuming? If it takes less than several hours to build, I see no problem compiling it from source every time.

For me the ICU build process takes about 10 min from scratch, so definitely below several hours. I will probably add an fdroid flavor or similar in the app’s build.gradle which compiles ICU every time it is invoked, and edit the build recipe to build with that flavor. Thanks for your help, will mark your reply as the solution.

As far as I can see there is a script to build ICU libraries. It will be easier just to call it from fdroiddata recipe and we’re done.

You are right, this would be the easier solution.

I had a look at the metadata reference and based on that this is the build recipe I’ve come up with:

  - versionName: 0.3.12
    versionCode: 43
    commit: v0.3.12
    subdir: app
    submodules: true
    scandelete:
      - app/src/main/icu4c/prebuilt
    build: NDK=$$NDK$$ SDK=$$SDK$$ ./app/src/main/icu4c/floris-cc-icu4c.sh
    gradle:
      - yes

The scandelete would remove the prebuilt binaries cloned from the git remote if I understood correctly, the build command afterwards would completely re-compile and re-build the prebuilt directory again.

Obviously this wasn’t needed for v0.3.12 but will be needed for the upcoming v0.3.13 release, so how do I include these new attributes in the metadata file correctly? Wait for the v0.3.13 release and add it then, or add it to the v0.3.12 block so the attributes get copied to the next release?

Open a merge request to fdroiddata with v0.3.13 right before you’re going to tag v0.3.13 and ping me.

Hope it is not too off-topic but as a Florisboard user I just want to thank you for putting in the effort to make sure your awesome project stays within F-Droid’s guidelines :heart:

3 Likes

Open a merge request to fdroiddata with v0.3.13 right before you’re going to tag v0.3.13 and ping me.

Will do, thanks. Note that the 0.3.13 release is still 1 week away if everything goes according to plan, so I’ll do the MR next Wednesday-Friday.

Hope it is not too off-topic but as a Florisboard user I just want to thank you for putting in the effort to make sure your awesome project stays within F-Droid’s guidelines :heart:

Yes it is a bit of effort but worth it imo. I use F-Droid also as a user and value the strict guidelines for apps, so as a developer I also have to make sure to stay within them. Also a big thanks to all F-Droid contributors who help maintain this awesome open app store! :heart:

3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.