nandi/frqpublic Fork 0
5c40e758d011ed38612fa0d8335a591dc3dd18b3
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

build-jolt-boot.sh · 95 lines · 3.5 KBBash Blame HistoryRaw
A freeq client in jolt, as glimmer components on Vidya 4719d6f nandi 20d ago1#!/usr/bin/env bash
2set -euo pipefail
3
4ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5VIDYA="${VIDYA:-$(cd "$ROOT/../vidya" && pwd)}"
6# glimmer itself is a git dependency, so its sources live in the jolt cache
7# rather than in either checkout. The boot image is built from :paths alone —
8# there is no dependency resolution inside a cross compile — so the cache path
9# has to be named here.
10GLIMMER="${GLIMMER:-$HOME/.jolt/gitlibs/https___github.com_jolt-lang_glimmer/5581c331c51aff989259b9e8e92ec920fe5e6741/src}"
11OUT="${1:?usage: build-jolt-boot.sh OUTPUT_DIRECTORY}"
Pin the jolt the APK needs 2308a7e nandi 19d ago12# The DotSlash-pinned jolt beside this script, not whatever is on PATH: an
13# upstream jolt cannot open a TLS connection on Android — it reads the socket
14# address out of `struct addrinfo` at glibc's offset, which is Bionic's
15# `ai_canonname` — so a build made with one produces an APK that cannot sign in
16# or send a picture. Override with JOLT= to use another.
17JOLT="${JOLT:-$ROOT/scripts/jolt}"
A freeq client in jolt, as glimmer components on Vidya 4719d6f nandi 20d ago18MODULE="${MODULE:-frq.app}"
19CHEZ_ANDROID="${CHEZ_ANDROID:-$HOME/.cache/vidya-chez-android}"
20HOST_SCHEME="$CHEZ_ANDROID/ta6le/bin/ta6le/scheme"
21TARGET_BOOT="$CHEZ_ANDROID/boot/tarm64le"
22XPATCH="$CHEZ_ANDROID/xc-tarm64le/s/xpatch"
23
24for path in "$HOST_SCHEME" "$TARGET_BOOT/petite.boot" \
25 "$TARGET_BOOT/scheme.boot" "$TARGET_BOOT/scheme.h" "$XPATCH"; do
26 [[ -e "$path" ]] || {
27 echo "missing Android Chez artifact: $path" >&2
28 echo "Build Chez's tarm64le cross target first; see ../vidya/android." >&2
29 exit 1
30 }
31done
32command -v "$JOLT" >/dev/null || {
33 echo "Jolt executable not found: $JOLT" >&2
34 exit 1
35}
36
37# The boot image is a pure function of the Scheme sources, the module name, the
38# flat-split flag and Chez's own boot files — all static. Hash them, and skip
39# the whole thing when the stamp still matches: a Rust-only APK rebuild has no
40# reason to spend fifteen single-threaded seconds recompiling Scheme.
41#
42# The flag is part of the stamp on purpose. JOLT_NO_FLAT_SPLIT changes the shape
43# of what `jolt build` emits, so an app.build/ left by an ordinary build is not
44# reusable here; a stamp miss wipes the tree below, which is what the
45# unconditional `rm -rf` used to be defending against.
46STAMP="$OUT/jolt.boot.stamp"
47stamp_now() {
48 {
49 printf '%s\n' "$MODULE" "JOLT_NO_FLAT_SPLIT=1"
50 "$JOLT" --version 2>/dev/null || true
51 find "$ROOT/src" "$VIDYA/glimmer/src" "$GLIMMER" -type f \
52 \( -name '*.jolt' -o -name '*.edn' \) -print0 | sort -z | xargs -0 sha256sum
53 sha256sum "$TARGET_BOOT/petite.boot" "$TARGET_BOOT/scheme.boot" "$XPATCH"
54 } | sha256sum | cut -d' ' -f1
55}
56
57WANT="$(stamp_now)"
58if [[ -f "$OUT/jolt.boot" && -f "$OUT/scheme.h" && -f "$STAMP" ]] &&
59 [[ "$(<"$STAMP")" == "$WANT" ]]; then
60 echo "jolt boot image up to date" >&2
61 exit 0
62fi
63
64rm -f "$STAMP"
65rm -rf "$OUT/project" "$OUT/cross"
66mkdir -p "$OUT/project" "$OUT/cross"
67cat > "$OUT/project/deps.edn" <<EOF
68{:paths ["$ROOT/src" "$VIDYA/glimmer/src" "$GLIMMER"]}
69EOF
70
71(
72 cd "$OUT/project"
73 JOLT_NO_FLAT_SPLIT=1 "$JOLT" build \
74 -m "$MODULE" -o app
75)
76
77cat > "$OUT/cross/compile.ss" <<EOF
78(import (chezscheme))
79(load "$XPATCH")
80(optimize-level 2)
81(generate-inspector-information #f)
82(compile-file "$OUT/project/app.build/flat.ss" "$OUT/cross/flat.so")
83(make-boot-file "$OUT/jolt.boot" '()
84 "$TARGET_BOOT/petite.boot"
85 "$TARGET_BOOT/scheme.boot"
86 "$OUT/cross/flat.so")
87EOF
88
89SCHEMEHEAPDIRS="$CHEZ_ANDROID/ta6le/boot/ta6le" \
90 "$HOST_SCHEME" --script "$OUT/cross/compile.ss"
91
92cp "$TARGET_BOOT/scheme.h" "$OUT/scheme.h"
93
94# Last, so an interrupted build leaves no stamp and the next run redoes it.
95printf '%s\n' "$WANT" > "$STAMP"