whiskers.git / tools / build-core.sh
1#!/usr/bin/env bash

Build the Rust core for the tablet and generate the Kotlin bindings.

mise run core

Gradle runs this before every build, so a clean checkout builds with one command. Outputs (all gitignored): android/app/src/main/jniLibs/<abi>/libwhiskers_ffi.so, android/app/src/main/kotlin/uniffi/whiskers_ffi/whiskers_ffi.kt and the grey cat's drawing, android/app/src/main/kotlin/app/whiskers/art/GreyScenes.kt (written from crates/whiskers-art) and PixelIconSet.kt (the admitted pixel icons, from crates/whiskers-icons).

11set -euo pipefail
12cd "$(dirname "$0")/.."

Her tablet runs 32- and 64-bit code (Amazon's Fire HD 10 specifications), so both. x86_64 is only for the emulator; it costs a second to build.

16cargo ndk -t arm64-v8a -t armeabi-v7a -t x86_64 -o android/app/src/main/jniLibs build -p whiskers-ffi --release

The bindings are read from the built library itself, so they cannot drift from it.

19cargo run -q -p whiskers-ffi --bin uniffi-bindgen -- generate \
20    --library target/aarch64-linux-android/release/libwhiskers_ffi.so \
21    --language kotlin --no-format --out-dir android/app/src/main/kotlin

The grey cat is drawn from the same data the website draws: written out as Kotlin so the app needs no native call per frame (and Robolectric can photograph it).

25cargo run -q -p whiskers-art --bin gen-kotlin -- android/app/src/main/kotlin/app/whiskers/art/GreyScenes.kt

The admitted pixel icons, as data the app draws in their own colours.

28cargo run -q -p whiskers-icons --bin gen-kotlin -- android/app/src/main/kotlin/app/whiskers/art/PixelIconSet.kt