Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hop/blob/main/Omega/gen-ui.sh # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Omega / gen-ui.sh` 48 lines ยท 3506 bytes Raw Blame History 1 #!/bin/sh 2 # Builds Generated/hoppanel, Hop's launcher panel as one Omega program (Omega/ui/hoppanel.om), with Omega NG. 3 # Runs on Linux AArch64 (the seeded compiler and ng are Linux AArch64 executables); the output is a macOS arm64 4 # program that opens a window through AppKit: no Swift, no C. 5 # Usage: NG= NGCHECK= sh Omega/gen-ui.sh OUT 6 # omega-mv `b2ad967e57146172c1bedf1eac98babb75baef65` (rad main; callbacks from library code, libback, and names 7 # over 8 bytes in front-ir) 8 # ng sha256 `5ed20188ba8582f27105393d7578cbbe13a420630bd9dc50bedbf06a1443170c`, built by ngbuild from seed/ng/ng.units with 9 # seed/out/omc sha256 `f4fa7951816bbd09c5eaaae6692852a70c3c305164b365027c5b683dec7d63e9` 10 # The panel uses Hop's own rules: the matcher, the text decisions and the order of the rows. They are not copied 11 # by hand: this script takes every function of Omega/hopcore.om but its main (from `fn isword` to the line 12 # before `fn main to int`) and puts them where Omega/ui/hoppanel.om says `note @hopcore`. 13 # Writes OUT/hoppanel (unsigned Mach-O; build.sh signs it on the Mac), OUT/UI-SHA256SUMS, and OUT/mutant/hoppanel-deaf 14 # (a panel that throws the matcher's answer away, for Omega/tests/check-ui.sh). Copy hoppanel and the sums to 15 # Generated/, mutant/hoppanel-deaf to Omega/tests/mutant/. 16 set -eu 17 OUT=${1:?usage: gen-ui.sh OUT} 18 NG=${NG:?set NG to the ng compiler} 19 NGCHECK=${NGCHECK:?set NGCHECK to ngcheck} 20 want=`5ed20188ba8582f27105393d7578cbbe13a420630bd9dc50bedbf06a1443170c` 21 [ "$(sha256sum "$NG" | cut -d' ' -f1)" = $want ] || { echo "ng is not $want" >&2; exit 1; } 22 ROOT=$(cd "$(dirname "$0")/.." && pwd) 23 mkdir -p "$OUT/mutant" 24 sed -n '/^fn isword /,/^fn main to int$/p' "$ROOT/Omega/hopcore.om" | sed '$d' > "$OUT/hopfuzz.om" 25 grep -q '^fn swrank ' "$OUT/hopfuzz.om" || { echo "the core's functions were not found in Omega/hopcore.om" >&2; exit 1; } 26 ! grep -q '^fn main ' "$OUT/hopfuzz.om" || { echo "the core's main must stay out of the panel" >&2; exit 1; } 27 awk -v f="$OUT/hopfuzz.om" '$0 == "note @hopcore" { print "note ---- the core of Hop, from Omega/hopcore.om ----"; while ((getline l < f) > 0) print l 28 print "note ---- end of the core of Hop ----"; n++; next } { print } END { exit n == 1 ? 0 : 1 }' "$ROOT/Omega/ui/hoppanel.om" > "$OUT/hoppanel.om" \ 29 || { echo "Omega/ui/hoppanel.om must have exactly one line: note @hopcore" >&2; exit 1; } 30 build() { # build SOURCE PROGRAM 31 { printf '@ng front-ir\n'; cat "$1"; } | "$NG" > "$2.ir" 32 "$NGCHECK" < "$2.ir" > "$2.ngcheck.txt" # ACCEPT fns= blocks= ops= 33 { printf '@ng opt\n'; cat "$2.ir"; } | "$NG" > "$2.opt.ir" 34 { printf '@ng a64 macho\n'; cat "$2.opt.ir"; } | "$NG" > "$2" 35 } 36 build "$OUT/hoppanel.om" "$OUT/hoppanel" 37 sed 's/^ret add get res 3 1$/ret 0/' "$OUT/hoppanel.om" > "$OUT/mutant/hoppanel-deaf.om" 38 ! cmp -s "$OUT/hoppanel.om" "$OUT/mutant/hoppanel-deaf.om" || { echo "mutant not applied" >&2; exit 1; } 39 build "$OUT/mutant/hoppanel-deaf.om" "$OUT/mutant/hoppanel-deaf" 40 rm -f "$OUT/mutant/"*.ir "$OUT/mutant/"*.txt 41 { 42 echo "# hoppanel, generated on $(uname -sm) by Omega NG (omega-mv `b2ad967e`, ng $want)" 43 echo "# $(cat "$OUT/hoppanel.ngcheck.txt")" 44 echo "# hopcore-block $(sha256sum "$OUT/hopfuzz.om" | cut -d' ' -f1)" 45 (cd "$ROOT" && sha256sum Omega/ui/hoppanel.om) 46 echo "$(sha256sum "$OUT/hoppanel" | cut -d' ' -f1) Generated/hoppanel" 47 } > "$OUT/UI-SHA256SUMS" 48 cat "$OUT/UI-SHA256SUMS"