whiskers.git / tools / build-core.sh
1#!/usr/bin/env bash
2# Build the Rust core for the tablet and generate the Kotlin bindings.
3#
4#     mise run core
5#
6# Gradle runs this before every build, so a clean checkout builds with one command.
7# Outputs (all gitignored): android/app/src/main/jniLibs/<abi>/libwhiskers_ffi.so,
8# android/app/src/main/kotlin/uniffi/whiskers_ffi/whiskers_ffi.kt and the grey cat's drawing,
9# android/app/src/main/kotlin/app/whiskers/art/GreyScenes.kt (written from crates/whiskers-art) and
10# PixelIconSet.kt (the admitted pixel icons, from crates/whiskers-icons).
11set -euo pipefail
12cd "$(dirname "$0")/.."
13
14# Her tablet runs 32- and 64-bit code (Amazon's Fire HD 10 specifications), so both.
15# 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
17
18# 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
22
23# The grey cat is drawn from the same data the website draws: written out as Kotlin so the app
24# 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
26
27# 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