nandi/frqpublic Fork 0
3343b8e782134f74f387c73fad766afd69cde853
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 · 90 lines · 3.2 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}"
12JOLT="${JOLT:-$(command -v jolt)}"
13MODULE="${MODULE:-frq.app}"
14CHEZ_ANDROID="${CHEZ_ANDROID:-$HOME/.cache/vidya-chez-android}"
15HOST_SCHEME="$CHEZ_ANDROID/ta6le/bin/ta6le/scheme"
16TARGET_BOOT="$CHEZ_ANDROID/boot/tarm64le"
17XPATCH="$CHEZ_ANDROID/xc-tarm64le/s/xpatch"
18
19for path in "$HOST_SCHEME" "$TARGET_BOOT/petite.boot" \
20 "$TARGET_BOOT/scheme.boot" "$TARGET_BOOT/scheme.h" "$XPATCH"; do
21 [[ -e "$path" ]] || {
22 echo "missing Android Chez artifact: $path" >&2
23 echo "Build Chez's tarm64le cross target first; see ../vidya/android." >&2
24 exit 1
25 }
26done
27command -v "$JOLT" >/dev/null || {
28 echo "Jolt executable not found: $JOLT" >&2
29 exit 1
30}
31
32# The boot image is a pure function of the Scheme sources, the module name, the
33# flat-split flag and Chez's own boot files — all static. Hash them, and skip
34# the whole thing when the stamp still matches: a Rust-only APK rebuild has no
35# reason to spend fifteen single-threaded seconds recompiling Scheme.
36#
37# The flag is part of the stamp on purpose. JOLT_NO_FLAT_SPLIT changes the shape
38# of what `jolt build` emits, so an app.build/ left by an ordinary build is not
39# reusable here; a stamp miss wipes the tree below, which is what the
40# unconditional `rm -rf` used to be defending against.
41STAMP="$OUT/jolt.boot.stamp"
42stamp_now() {
43 {
44 printf '%s\n' "$MODULE" "JOLT_NO_FLAT_SPLIT=1"
45 "$JOLT" --version 2>/dev/null || true
46 find "$ROOT/src" "$VIDYA/glimmer/src" "$GLIMMER" -type f \
47 \( -name '*.jolt' -o -name '*.edn' \) -print0 | sort -z | xargs -0 sha256sum
48 sha256sum "$TARGET_BOOT/petite.boot" "$TARGET_BOOT/scheme.boot" "$XPATCH"
49 } | sha256sum | cut -d' ' -f1
50}
51
52WANT="$(stamp_now)"
53if [[ -f "$OUT/jolt.boot" && -f "$OUT/scheme.h" && -f "$STAMP" ]] &&
54 [[ "$(<"$STAMP")" == "$WANT" ]]; then
55 echo "jolt boot image up to date" >&2
56 exit 0
57fi
58
59rm -f "$STAMP"
60rm -rf "$OUT/project" "$OUT/cross"
61mkdir -p "$OUT/project" "$OUT/cross"
62cat > "$OUT/project/deps.edn" <<EOF
63{:paths ["$ROOT/src" "$VIDYA/glimmer/src" "$GLIMMER"]}
64EOF
65
66(
67 cd "$OUT/project"
68 JOLT_NO_FLAT_SPLIT=1 "$JOLT" build \
69 -m "$MODULE" -o app
70)
71
72cat > "$OUT/cross/compile.ss" <<EOF
73(import (chezscheme))
74(load "$XPATCH")
75(optimize-level 2)
76(generate-inspector-information #f)
77(compile-file "$OUT/project/app.build/flat.ss" "$OUT/cross/flat.so")
78(make-boot-file "$OUT/jolt.boot" '()
79 "$TARGET_BOOT/petite.boot"
80 "$TARGET_BOOT/scheme.boot"
81 "$OUT/cross/flat.so")
82EOF
83
84SCHEMEHEAPDIRS="$CHEZ_ANDROID/ta6le/boot/ta6le" \
85 "$HOST_SCHEME" --script "$OUT/cross/compile.ss"
86
87cp "$TARGET_BOOT/scheme.h" "$OUT/scheme.h"
88
89# Last, so an interrupted build leaves no stamp and the next run redoes it.
90printf '%s\n' "$WANT" > "$STAMP"