From 33881ed9d89b5bb9f6b228e22298d7df5034f4ba Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Sat, 26 Nov 2022 23:59:08 +0800 Subject: [PATCH] Android building instructions --- cozo-lib-java/README.md | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/cozo-lib-java/README.md b/cozo-lib-java/README.md index 281a864b..ecf0ab22 100644 --- a/cozo-lib-java/README.md +++ b/cozo-lib-java/README.md @@ -4,13 +4,40 @@ This crate provides the JNI bindings for using Cozo in Java/JVM languages/Androi You do not use this crate directly. Instead, use: -* ... for Android * ... for Java or other JVM languages * ... for Clojure on JVM (you can also use the Java library, but this one is nicer) +* ... for Android + +Keep reading only if the prebuilt binaries provided by these libraries do not suit your needs. -## Building +## Building for JDK With the Rust toolchain installed, ```bash -cargo build --release -p cozo_java -F compact -F storage-rocksdb -``` \ No newline at end of file +cargo build --release -p cozo_java -F storage-rocksdb +``` + +## Building for Android + +Building for Android is not easy, and we will be very sketchy. + +The first thing to note is that you should omit `-F storage-rocksdb` from the build command above, +unless you are prepared to manually change lots of `build.rs` flags in +[cozorocks](../cozorocks) to build the RocksDB dependency. + +Then, in addition to adding Android targets to the Rust toolchain, +you also need to set up the Android NDK +cross-compilation and libraries paths, etc. +This is notoriously hard to get right, but fortunately +you can just use the Docker image [here](https://github.com/cross-rs/cross) +which has everything set up for you. + +When everything is set up correctly, the following command show complete without errors: + +```bash +for TARGET in aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android; do + cross build -p cozo_java --release --target=$TARGET +done +``` + +For running on modern Android phones, the single target `aarch64-linux-android` is probably enough. \ No newline at end of file