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

justfile · 231 lines · 8.8 KBMakefile Blame HistoryRaw
Six verbs, and the last of the nix 2e24e64 nandi yesterday1# Six verbs over one tree.
Inline the babashka scripts into the justfile 76dcc6c nandi 12d ago2#
Six verbs, and the last of the nix 2e24e64 nandi yesterday3# There is no nix here any more. `tools/toolchain.sh` fetches Flutter (which
4# carries Dart), a JDK, the Clojure CLI and Nim as sha256-pinned tarballs into
5# `.toolchain/`, and every recipe below runs inside the environment that
6# script prints. One mechanism, and the same one the containers in `.modal/`
7# use — which is what lets a plain Debian image build this.
8#
9# What the host still brings: a C compiler (Nim shells out to one), OpenSSL
10# (nim.cfg is `-d:ssl`), git, curl, unzip, python3. For `run desktop` and the
11# other Linux builds, GTK and the usual CMake/Ninja/pkg-config.
12#
13# just build TARGET apk desktop web lib ui app
14# just run TARGET apk desktop web ui app
15# just test SUITE all nim dart common live
The last of the Clojure 284b59c nandi 22h ago16# just modal CONTAINER dev
Six verbs, and the last of the nix 2e24e64 nandi yesterday17# just serve [PORT] the Modal-built web bundle, on localhost
18# just tools ... the toolchain itself
Take glimmer-vidya from gitlab, so a stranger can build this 5c40e75 nandi 20d ago19
Write the build in babashka, and pin the babashka 34832a8 nandi 19d ago20set shell := ["bash", "-euo", "pipefail", "-c"]
A freeq client in jolt, as glimmer components on Vidya 4719d6f nandi 21d ago21
Six verbs, and the last of the nix 2e24e64 nandi yesterday22# Every recipe is a `#!` script. Without this, "$@" is empty in one of them —
23# just interpolates into a shebang recipe rather than handing it argv.
Give the terminal's classpath an nREPL, and hand recipes their arguments 664397d nandi 11d ago24set positional-arguments
25
Six verbs, and the last of the nix 2e24e64 nandi yesterday26root := justfile_directory()
27tc := justfile_directory() / "tools/toolchain.sh"
Inline the babashka scripts into the justfile 76dcc6c nandi 12d ago28
A freeq client in jolt, as glimmer components on Vidya 4719d6f nandi 21d ago29default:
30 @just --list
31
The last of the Clojure 284b59c nandi 22h ago32# The toolchain, directly: `just tools versions`,
Six verbs, and the last of the nix 2e24e64 nandi yesterday33# `just tools exec -- flutter doctor`.
The last of the Clojure 284b59c nandi 22h ago34[doc('the toolchain itself: versions, exec -- CMD')]
Six verbs, and the last of the nix 2e24e64 nandi yesterday35tools *args:
36 #!/usr/bin/env bash
37 cd "{{root}}"
38 exec "{{tc}}" "$@"
39
40# Build a target.
41#
The last of the Clojure 284b59c nandi 22h ago42# desktop the app: Nim owns the state and the screens, Flutter paints
A web version, from the same core 23846db nandi 7h ago43# web the same, in a browser: the core compiled by `nim js`, the
44# socket a WebSocket to freeq's own bridge, Flutter painting
The last of the Clojure 284b59c nandi 22h ago45# lib the Nim core alone, as build/nim/libfrqcore.so
A web version, from the same core 23846db nandi 7h ago46# core-js the core alone, as build/web/frq_core.js
The last of the Clojure 284b59c nandi 22h ago47#
48# There were four more. `apk` and `web` compiled ClojureDart and went with it:
49# the web target cannot come back without a wasm build of the core, since a
50# browser has no dart:ffi, and the APK wants libfrqcore.so cross-compiled for
51# Android's ABIs. `ui` and `app` were the two halves of the migration, and
52# there is one app now.
A web version, from the same core 23846db nandi 7h ago53[doc('build a target: desktop web lib core-js')]
Six verbs, and the last of the nix 2e24e64 nandi yesterday54build target="desktop":
Build the APK, out of ClojureDart and Flutter e2b0e6b nandi 8d ago55 #!/usr/bin/env bash
56 set -euo pipefail
Six verbs, and the last of the nix 2e24e64 nandi yesterday57 cd "{{root}}"
58 case "{{target}}" in
59 desktop) just _flutter desktop build ;;
A web version, from the same core 23846db nandi 7h ago60 web) just _web-bundle ;;
Six verbs, and the last of the nix 2e24e64 nandi yesterday61 lib) just _nim-lib ;;
The core, compiled to JavaScript 5ac0521 nandi 7h ago62 core-js) just _nim-js ;;
A web version, from the same core 23846db nandi 7h ago63 *) echo "usage: just build [desktop|web|lib|core-js]" >&2; exit 1 ;;
Build the APK, out of ClojureDart and Flutter e2b0e6b nandi 8d ago64 esac
65
Six verbs, and the last of the nix 2e24e64 nandi yesterday66# Build a target and start it.
Paint the desktop with Flutter too, beside libcosmic fc5f63c nandi 8d ago67#
The last of the Clojure 284b59c nandi 22h ago68# FRQ_TRACE=1 every line in and out, both languages in one log
69# FRQ_AUTOCONNECT=1 press Connect at startup, for a window a script cannot
70# click; FRQ_NICK overrides the nickname
A web version, from the same core 23846db nandi 7h ago71[doc('build the app and start it: desktop web')]
The last of the Clojure 284b59c nandi 22h ago72run target="desktop":
Paint the desktop with Flutter too, beside libcosmic fc5f63c nandi 8d ago73 #!/usr/bin/env bash
74 set -euo pipefail
Six verbs, and the last of the nix 2e24e64 nandi yesterday75 cd "{{root}}"
76 case "{{target}}" in
77 desktop) just _flutter desktop run ;;
A web version, from the same core 23846db nandi 7h ago78 web) just _web-bundle
79 echo "serving build/web on http://localhost:8000"
80 exec python3 -m http.server 8000 --directory build/web ;;
81 *) echo "usage: just run [desktop|web]" >&2; exit 1 ;;
Paint the desktop with Flutter too, beside libcosmic fc5f63c nandi 8d ago82 esac
A shell that is already the devShell, and two recipes to reach it e853593 nandi 6d ago83
Six verbs, and the last of the nix 2e24e64 nandi yesterday84# Test a suite.
85#
86# nim the Nim core. No Flutter, no Dart, no SDK — a rule about the IRC
87# wire format is checkable in a second.
88# dart the Dart side of the FFI boundary, on the plain Dart VM. Passing
89# `nim` and failing this one is a marshalling bug, which is why the
90# two are separate suites.
The core, compiled to JavaScript 5ac0521 nandi 7h ago91# web the JavaScript build of the same core, driven as a browser
92# drives it. Needs node and nothing else.
Six verbs, and the last of the nix 2e24e64 nandi yesterday93# live the whole stack against a real freeq. Not in `all`: it wants a
94# network and a running server.
95#
96# just test all of them
97# just test nim tircparse one Nim file
The core, compiled to JavaScript 5ac0521 nandi 7h ago98[doc('run a suite: all nim dart layout web live')]
Six verbs, and the last of the nix 2e24e64 nandi yesterday99test suite="all" *args:
A third target, and the seam that was already waiting for it f54ca45 nandi 3d ago100 #!/usr/bin/env bash
101 set -euo pipefail
Six verbs, and the last of the nix 2e24e64 nandi yesterday102 cd "{{root}}"
103 shift
104 case "{{suite}}" in
The core, compiled to JavaScript 5ac0521 nandi 7h ago105 all) just test nim && just test dart && just test layout \
106 && just test web ;;
Lay every screen out in a test, and fix what that found 36bdfc5 nandi yesterday107 layout) just _nim-lib
108 just _flutter layout test ;;
Six verbs, and the last of the nix 2e24e64 nandi yesterday109 nim) just _nim-test "$@" ;;
The core, compiled to JavaScript 5ac0521 nandi 7h ago110 web) just _nim-js
111 exec node nim/web/test/smoke.js build/web/frq_core.js ;;
Six verbs, and the last of the nix 2e24e64 nandi yesterday112 dart) just _nim-lib
113 exec "{{tc}}" exec -- bash -c \
114 'cd dart/frq_core && dart pub get && dart test -r expanded' ;;
115 live) just _nim-lib
116 exec "{{tc}}" exec -- bash -c \
117 'cd dart/frq_core && dart pub get >/dev/null && dart run tool/live_ui.dart "$@"' _ "$@" ;;
The core, compiled to JavaScript 5ac0521 nandi 7h ago118 *) echo "usage: just test [all|nim|dart|layout|web|live]" >&2; exit 1 ;;
Six verbs, and the last of the nix 2e24e64 nandi yesterday119 esac
A third target, and the seam that was already waiting for it f54ca45 nandi 3d ago120
Six verbs, and the last of the nix 2e24e64 nandi yesterday121# The containers in `.modal/`, run on Modal rather than here: this machine
122# evaluates and Modal builds. See CLAUDE.md, which says so rather more firmly.
A shell that is already the devShell, and two recipes to reach it e853593 nandi 6d ago123#
Six verbs, and the last of the nix 2e24e64 nandi yesterday124# `--shell` leaves a sandbox running with the container's own image, volumes
125# and environment, and prints the command to attach to it. It blocks — an
126# ephemeral app takes its sandbox down when the entrypoint returns — so attach
127# from a second terminal and Ctrl-C here when done. The sandbox bills until
128# you do.
A shell that is already the devShell, and two recipes to reach it e853593 nandi 6d ago129#
Six verbs, and the last of the nix 2e24e64 nandi yesterday130# just modal dev
The last of the Clojure 284b59c nandi 22h ago131# just modal dev --shell
Six verbs, and the last of the nix 2e24e64 nandi yesterday132[doc('run a .modal/ container on Modal')]
133modal container="dev" *args:
A shell that is already the devShell, and two recipes to reach it e853593 nandi 6d ago134 #!/usr/bin/env bash
135 set -euo pipefail
Six verbs, and the last of the nix 2e24e64 nandi yesterday136 cd "{{root}}"
137 shift || true
A shell that is already the devShell, and two recipes to reach it e853593 nandi 6d ago138 exec modal run ".modal/{{container}}/container.py" "$@"
139
The core, compiled to JavaScript 5ac0521 nandi 7h ago140# The same core, compiled to JavaScript.
141#
142# `--path:src --path:web`, in that order, because the later path wins: every
143# module under `nim/web/frq` shadows the one beside it in `nim/src/frq`, so
144# `frq/conn` is a queue the host fills rather than two socket threads, and the
145# shared code above them never learns which host it is on.
A web version, from the same core 23846db nandi 7h ago146# The web bundle: the core as JavaScript, and Flutter around it.
147#
148# The core goes into `flutter/web/` rather than being copied afterwards,
149# because `flutter build web` copies that directory into the bundle — so the
150# page's `<script src="frq_core.js">` resolves the same in a dev server as it
151# does in the built output.
152[private]
153_web-bundle:
154 #!/usr/bin/env bash
155 set -euo pipefail
156 cd "{{root}}"
157 just _nim-js
158 cp build/web/frq_core.js flutter/web/frq_core.js
159 exec "{{tc}}" exec -- bash -euo pipefail -c '
160 cd flutter
161 flutter pub get
162 flutter build web
163 rm -rf ../build/web
164 cp -r build/web ../build/web
165 echo "built build/web"'
166
The core, compiled to JavaScript 5ac0521 nandi 7h ago167[private]
168_nim-js:
169 #!/usr/bin/env bash
170 set -euo pipefail
171 cd "{{root}}"
172 out="{{root}}/build/web"
173 mkdir -p "$out"
174 exec "{{tc}}" exec -- bash -euo pipefail -c '
175 cd nim
176 nim js -d:release --hints:off \
177 --path:src --path:web --out:"'"$out"'/frq_core.js" web/frq_web.nim
178 printf "built %s (%s)\n" "'"$out"'/frq_core.js" \
179 "$(gzip -9c "'"$out"'/frq_core.js" | wc -c | awk "{printf \"%d KB gzipped\", \$1/1024}")"'
180
Six verbs, and the last of the nix 2e24e64 nandi yesterday181[private]
182_nim-lib:
One frontend where there were three, and a core that is not Clojure 438b247 nandi yesterday183 #!/usr/bin/env bash
184 set -euo pipefail
Six verbs, and the last of the nix 2e24e64 nandi yesterday185 cd "{{root}}"
186 out="{{root}}/build/nim"
One frontend where there were three, and a core that is not Clojure 438b247 nandi yesterday187 mkdir -p "$out"
Six verbs, and the last of the nix 2e24e64 nandi yesterday188 exec "{{tc}}" exec -- bash -euo pipefail -c '
189 cd nim
190 nim c --app:lib --mm:orc -d:release --hints:off \
191 --path:src --out:"'"$out"'/libfrqcore.so" src/frq_core.nim
192 echo "built '"$out"'/libfrqcore.so"
193 nm -D --defined-only "'"$out"'/libfrqcore.so" | grep " T frq_" || true'
194
195[private]
196_nim-test *args:
The binding is Dart, and it works f7aea3b nandi yesterday197 #!/usr/bin/env bash
198 set -euo pipefail
Six verbs, and the last of the nix 2e24e64 nandi yesterday199 cd "{{root}}"
200 exec "{{tc}}" exec -- bash -euo pipefail -c '
201 cd nim
202 if [ -n "${1:-}" ]; then
203 exec nim c -r --hints:off --path:src "tests/$1.nim"
204 fi
205 for t in tests/t*.nim; do
206 echo "== $t"
207 nim c -r --hints:off --path:src "$t"
208 done' _ "$@"
209
210[private]
211_flutter target action:
Nim under the existing UI, not instead of it 56551a8 nandi yesterday212 #!/usr/bin/env bash
213 set -euo pipefail
Six verbs, and the last of the nix 2e24e64 nandi yesterday214 cd "{{root}}"
The last of the Clojure 284b59c nandi 22h ago215 just _nim-lib
Six verbs, and the last of the nix 2e24e64 nandi yesterday216 exec "{{tc}}" exec -- bash -euo pipefail -c '
217 cd flutter
218 # Nim resolves OpenSSL through dynlib at run time; without the host
219 # library on the loader path `newContext` dies in a SIGSEGV that says
220 # nothing about SSL.
221 export LD_LIBRARY_PATH="${FRQ_OPENSSL_LIB:-}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
The last of the Clojure 284b59c nandi 22h ago222 flutter pub get
Six verbs, and the last of the nix 2e24e64 nandi yesterday223 case "$1:$2" in
The last of the Clojure 284b59c nandi 22h ago224 desktop:build) exec flutter build linux --debug ;;
225 desktop:run) exec flutter run -d linux ;;
Lay every screen out in a test, and fix what that found 36bdfc5 nandi yesterday226 # Widget tests, which lay every screen out for real. Headless: no
The last of the Clojure 284b59c nandi 22h ago227 # GL and no window, which is what makes them the check a Wayland
Lay every screen out in a test, and fix what that found 36bdfc5 nandi yesterday228 # window cannot be.
The last of the Clojure 284b59c nandi 22h ago229 layout:test) exec flutter test test/nim_layout_test.dart ;;
230 *) echo "unknown target/action: $1 $2" >&2; exit 1 ;;
Six verbs, and the last of the nix 2e24e64 nandi yesterday231 esac' _ "{{target}}" "{{action}}"