nandi/frqpublic Fork 0
962fcce83c1a65aae5463db87c71b13312b9101d
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.

lib.bb · 67 lines · 3.2 KBBlitzBasic Blame HistoryRaw
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago1#!/bin/sh
2#_(
3exec "$(dirname "$0")/bb" "$0" "$@"
4)
5
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago6;; Both native libraries, out of jolt-native's release rather than a checkout.
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago7;;
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago8;; libvidya is the tree ABI glimmer-vidya binds; libjoltmoq is the AV media
9;; plane. They come out of one archive because they are built together, and
Run this tree on a native half the builders made a32699e nandi 17d ago10;; they land in build/lib because a loader wants one directory. `just run` does
11;; not come through here — running a change to jolt-native means building it,
Build the APK as derivations only, and retire the buck2 graph 3bc3aaa nandi 16d ago12;; which is what the dev shell is for — so this is the released half: the same
13;; bytes the APK takes through nix/android.nix, and what a run of the last
14;; release takes.
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago15;;
16;; Nothing is compiled here. The pinned bytes are the bytes: this repo used to
17;; clone jolt-native and cargo-build it, which meant a Rust toolchain, a build
18;; whose output depended on the machine, and two places — the clone's sha and
19;; the release digest — that could disagree about which jolt-native frq was
20;; running against. Bump scripts/*.dotslash instead: see bump-jolt-native.bb.
21;;
22;; Linked rather than copied, so a bump reaches a running tree by relinking and
23;; nothing goes stale in build/ — except for the one object that has to be
24;; repaired on the way through. See below.
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago25(require '[babashka.classpath :as cp])
26(cp/add-classpath (str (babashka.fs/parent *file*)))
27(require '[frq.paths :as paths]
28 '[babashka.fs :as fs]
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago29 '[clojure.string :as str])
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago30
31(def root (str (fs/canonicalize (fs/path (fs/parent *file*) ".."))))
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago32(def lib (fs/path root "build" "lib"))
33
34;; v0.1.3's desktop libjoltmoq.so has 68 undefined `snd_*` symbols and no
35;; DT_NEEDED on libasound: cpal's ALSA host is compiled in, and the library it
36;; calls is not named. It is the defect that release fixed for Android, in the
37;; place the fix did not reach — buck2 keeps a build script's cfgs and drops
38;; its link directives, so `cargo:rustc-link-lib=asound` never became a link
39;; argument. Undefined symbols are legal in a cdylib, so nothing said so until
40;; something tried to load it.
41;;
42;; So the library is named here instead, on a copy: the DotSlash cache holds
43;; what the release published, and rewriting that in place would make a
44;; verified digest a lie about the bytes on disk.
45;;
46;; This goes away with the release that links it. `patchelf --print-needed`
47;; below is the test for that — a fixed object is linked, not copied.
48(def repairs {"libjoltmoq.so" "libasound.so.2"})
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago49
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago50(defn needed [file]
51 (set (str/split-lines (paths/out "patchelf" "--print-needed" file))))
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago52
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago53(fs/create-dirs lib)
54(doseq [name ["libvidya-linux" "libjoltmoq-linux"]]
55 (let [file (paths/dist root name)
56 base (fs/file-name file)
57 dest (fs/path lib base)
58 missing (get repairs base)]
59 (fs/delete-if-exists dest)
60 (if (and missing (not (contains? (needed file) missing)))
61 (do (fs/copy file dest)
62 ;; Out of the cache read-only, and patchelf writes.
63 (fs/set-posix-file-permissions dest "rw-r--r--")
64 (paths/out "patchelf" "--add-needed" missing (str dest))
65 (println (str (fs/relativize root dest) " <- " file " (+" missing ")")))
66 (do (fs/create-sym-link dest file)
67 (println (str (fs/relativize root dest) " -> " file))))))