OXYGENHUB

Android: Scaffold Rust core using uniffi f821ee741b9f

Author
Andy McCall @andymccall <[email protected]>
When
· 2026-09-30 11:43 UTC
Signature
✔ signed by Andy McCall
Hash
f821ee741b9f47cb96b8fb9adf99425bc003cf2505ff21dbf4aed50c48d88d7e
Depends on
nothing: a root change
Depended on by
23279b95b5b2 1dfa631436b6 bfa2eff05d35 8a657957d5a0 0a2858c0dad3 57c0824300db 5edf011e4d10
In bookmarks
main
In tags
v0.1.0 v0.1.1 v0.1.2 v0.1.3 v0.1.4 v0.1.5 v0.1.6 v0.1.7 v0.1.8 v0.1.9
Edits
1 atom, 2 tree operations, 1 file

Browse the tree at this change

added scripts/build_rust.sh +37 −0
1 +
#!/usr/bin/env bash
2 +
set -e
3 +
4 +
echo "=== 🦀 Building Oxygen Rust Core for Android ==="
5 +
6 +
# Check if cargo-ndk is installed
7 +
if ! command -v cargo-ndk &> /dev/null; then
8 +
    echo "Installing cargo-ndk (Android build helper)..."
9 +
    cargo install cargo-ndk
10 +
fi
11 +
12 +
# Ensure Android targets are installed
13 +
echo "Adding Rust Android targets..."
14 +
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android
15 +
16 +
# Ensure NDK is set
17 +
if [ -z "$ANDROID_NDK_HOME" ]; then
18 +
    echo "⚠️ ANDROID_NDK_HOME is not set!"
19 +
    echo "Please set it to your NDK path, e.g.:"
20 +
    echo "export ANDROID_NDK_HOME=\$HOME/Android/Sdk/ndk/27.x.x.x"
21 +
    exit 1
22 +
fi
23 +
24 +
cd rust-core
25 +
26 +
echo "Building shared libraries using cargo-ndk..."
27 +
# Build for all common Android architectures and output to the JNI libs folder
28 +
cargo ndk -t armeabi-v7a -t arm64-v8a -t x86_64 -o ../app/src/main/jniLibs build --release
29 +
30 +
echo "Generating Kotlin bindings using uniffi-bindgen..."
31 +
# Use uniffi-bindgen to generate Kotlin files
32 +
cargo run --features=uniffi/cli --bin uniffi-bindgen generate \
33 +
    --library ../app/src/main/jniLibs/arm64-v8a/librust_core.so \
34 +
    --language kotlin \
35 +
    --out-dir ../app/src/main/java/uniffi/rust_core
36 +
37 +
echo "✅ Rust build complete! The JNI libraries and Kotlin bindings are ready."