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

repl.bb · 60 lines · 2.7 KBBlitzBasic Blame HistoryRaw
Build the desktop libraries rather than fetching a release of them 0b81161 nandi 15d ago1#!/bin/sh
2#_(
3exec "$(dirname "$0")/bb" "$0" "$@"
4)
5
6;; A jolt against this tree, with the native libraries under it.
7;;
8;; repl.bb a REPL
9;; repl.bb nrepl-server the same thing for an editor to connect to
10;; repl.bb -e '(+ 1 1)' or any other jolt command line
11;;
12;; This exists because `jolt` in the repo root does not work on its own.
13;; deps.edn carries :jolt/native, so every jolt invocation here — a REPL, an
14;; nREPL server, `jolt -M:frq` — loads libvidya and libjoltmoq before it reads
15;; a line, and dies naming the library if the loader cannot find them. The
16;; libraries are the flake's, which means an LD_LIBRARY_PATH nobody should have
17;; to remember.
18;;
19;; So it is run.bb without the app: the same re-exec into `nix develop`, the
20;; same deps overrides for the Jolt halves that bind those objects, and then
21;; whatever jolt command line the caller asked for. run.bb is `repl.bb -M:frq`
22;; with a window's worth of extra care about the GL driver; this is the rest of
23;; the time.
24(require '[babashka.classpath :as cp])
25(cp/add-classpath (str (babashka.fs/parent *file*)))
26(require '[frq.paths :as paths]
27 '[babashka.fs :as fs]
28 '[babashka.process :as p]
29 '[clojure.string :as str])
30
31(def root (str (fs/canonicalize (fs/path (fs/parent *file*) ".."))))
32(def self (str (fs/path root "scripts" "repl.bb")))
33
34;; Outside the shell, get inside it and come back — the test, the flag and the
35;; reasoning are run.bb's.
36(when-not (System/getenv "JOLT_NATIVE_LIB")
37 (let [cmd (paths/nix root
38 ["nix" "develop" root
39 "--max-jobs" (paths/env "FRQ_MAX_JOBS" "0")
40 "--command" self]
41 *command-line-args*)]
42 (System/exit (:exit @(apply p/process {:inherit true :dir root} cmd)))))
43
44;; The Jolt halves that have to match those objects, for run.bb's reason: the
45;; pin in deps.edn is a release, and what the shell built is the flake input.
46(def overrides
47 (str "{:deps {jolt-lang/glimmer {:local/root \"" (System/getenv "GLIMMER_SRC") "\"}"
48 " nandi/glimmer-vidya {:local/root \"" (System/getenv "GLIMMER_VIDYA_SRC") "\"}}}"))
49
50(System/exit
51 (:exit @(apply p/process
52 {:inherit true
53 :dir root
54 :extra-env {"LD_LIBRARY_PATH"
55 (->> [(System/getenv "JOLT_NATIVE_LIB")
56 (System/getenv "FRQ_LIB_PATH")
57 (System/getenv "LD_LIBRARY_PATH")]
58 (remove str/blank?)
59 (str/join ":"))}}
60 (concat ["jolt" "-Sdeps" overrides] *command-line-args*))))