nandi/frqpublic Fork 0
ab83b42c62ecdf8ed290f736dac46a7945d8690f
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 · 64 lines · 2.9 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
10;; they land in build/lib because a loader wants one directory, which is where
11;; run.bb points LD_LIBRARY_PATH.
12;;
13;; Nothing is compiled here. The pinned bytes are the bytes: this repo used to
14;; clone jolt-native and cargo-build it, which meant a Rust toolchain, a build
15;; whose output depended on the machine, and two places — the clone's sha and
16;; the release digest — that could disagree about which jolt-native frq was
17;; running against. Bump scripts/*.dotslash instead: see bump-jolt-native.bb.
18;;
19;; Linked rather than copied, so a bump reaches a running tree by relinking and
20;; nothing goes stale in build/ — except for the one object that has to be
21;; repaired on the way through. See below.
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago22(require '[babashka.classpath :as cp])
23(cp/add-classpath (str (babashka.fs/parent *file*)))
24(require '[frq.paths :as paths]
25 '[babashka.fs :as fs]
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago26 '[clojure.string :as str])
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago27
28(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 ago29(def lib (fs/path root "build" "lib"))
30
31;; v0.1.3's desktop libjoltmoq.so has 68 undefined `snd_*` symbols and no
32;; DT_NEEDED on libasound: cpal's ALSA host is compiled in, and the library it
33;; calls is not named. It is the defect that release fixed for Android, in the
34;; place the fix did not reach — buck2 keeps a build script's cfgs and drops
35;; its link directives, so `cargo:rustc-link-lib=asound` never became a link
36;; argument. Undefined symbols are legal in a cdylib, so nothing said so until
37;; something tried to load it.
38;;
39;; So the library is named here instead, on a copy: the DotSlash cache holds
40;; what the release published, and rewriting that in place would make a
41;; verified digest a lie about the bytes on disk.
42;;
43;; This goes away with the release that links it. `patchelf --print-needed`
44;; below is the test for that — a fixed object is linked, not copied.
45(def repairs {"libjoltmoq.so" "libasound.so.2"})
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago46
Take every jolt-native half from the release, and only from there a008d3b nandi 18d ago47(defn needed [file]
48 (set (str/split-lines (paths/out "patchelf" "--print-needed" file))))
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(fs/create-dirs lib)
51(doseq [name ["libvidya-linux" "libjoltmoq-linux"]]
52 (let [file (paths/dist root name)
53 base (fs/file-name file)
54 dest (fs/path lib base)
55 missing (get repairs base)]
56 (fs/delete-if-exists dest)
57 (if (and missing (not (contains? (needed file) missing)))
58 (do (fs/copy file dest)
59 ;; Out of the cache read-only, and patchelf writes.
60 (fs/set-posix-file-permissions dest "rw-r--r--")
61 (paths/out "patchelf" "--add-needed" missing (str dest))
62 (println (str (fs/relativize root dest) " <- " file " (+" missing ")")))
63 (do (fs/create-sym-link dest file)
64 (println (str (fs/relativize root dest) " -> " file))))))