hop
Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key.
Brought by drakestapleton
| 1 | #!/bin/sh |
| 2 | # Regenerates Generated/hopcore from Omega/hopcore.om with Omega NG. Runs on Linux AArch64 (the seeded |
| 3 | # compiler and ng are Linux AArch64 executables); the output is a macOS arm64 program. |
| 4 | # Usage: NG=<ng built from omega-mv at the commit below> NGCHECK=<its ngcheck> sh Omega/gen-core.sh OUT |
| 5 | # omega-mv 3f71977099c5129aecf0feca88d4894dc3764b3e (rad main; the commit that adds `@ng a64 macho`) |
| 6 | # ng sha256 1b903ea3b5621025356ba3ed7bd17d33cccef31bcddbd89c24ab543cbd1d0d80, built by ngbuild from |
| 7 | # seed/ng/ng.units with seed/out/omc sha256 f4fa7951816bbd09c5eaaae6692852a70c3c305164b365027c5b683dec7d63e9 |
| 8 | # Writes OUT/hopcore (unsigned Mach-O; build.sh signs it on the Mac), OUT/hopcore.elf (the same unit as a |
| 9 | # Linux program, for checks on the build host), OUT/CORE-SHA256SUMS and OUT/mutant/ (thirteen cores built from a |
| 10 | # source with one changed rule each). Copy hopcore and the sums to Generated/, mutant/ to Omega/tests/mutant/. |
| 11 | set -eu |
| 12 | OUT=${1:?usage: gen-core.sh OUT} |
| 13 | NG=${NG:?set NG to the ng compiler} |
| 14 | NGCHECK=${NGCHECK:?set NGCHECK to ngcheck} |
| 15 | want=1b903ea3b5621025356ba3ed7bd17d33cccef31bcddbd89c24ab543cbd1d0d80 |
| 16 | [ "$(sha256sum "$NG" | cut -d' ' -f1)" = $want ] || { echo "ng is not $want" >&2; exit 1; } |
| 17 | ROOT=$(cd "$(dirname "$0")/.." && pwd) |
| 18 | mkdir -p "$OUT" |
| 19 | { printf '@ng front-ir\n'; cat "$ROOT/Omega/hopcore.om"; } | "$NG" > "$OUT/hopcore.ir" |
| 20 | "$NGCHECK" < "$OUT/hopcore.ir" > "$OUT/ngcheck.txt" # ACCEPT <sha256> fns= blocks= ops= |
| 21 | { printf '@ng opt\n'; cat "$OUT/hopcore.ir"; } | "$NG" > "$OUT/hopcore.opt.ir" |
| 22 | { printf '@ng a64 macho\n'; cat "$OUT/hopcore.opt.ir"; } | "$NG" > "$OUT/hopcore" |
| 23 | { printf '@ng a64\n'; cat "$OUT/hopcore.opt.ir"; } | "$NG" > "$OUT/hopcore.elf" |
| 24 | # Negative controls for Omega/tests/check-core.sh: one changed score in each part. |
| 25 | mkdir -p "$OUT/mutant" |
| 26 | mut() { # mut NAME SED-EXPRESSION |
| 27 | sed "$2" "$ROOT/Omega/hopcore.om" > "$OUT/mutant/$1.om" |
| 28 | ! cmp -s "$ROOT/Omega/hopcore.om" "$OUT/mutant/$1.om" || { echo "mutant $1 not applied" >&2; exit 1; } |
| 29 | { printf '@ng front-ir\n'; cat "$OUT/mutant/$1.om"; } | "$NG" > "$OUT/mutant/$1.ir" |
| 30 | { printf '@ng opt\n'; cat "$OUT/mutant/$1.ir"; } | "$NG" > "$OUT/mutant/$1.opt.ir" |
| 31 | { printf '@ng a64 macho\n'; cat "$OUT/mutant/$1.opt.ir"; } | "$NG" > "$OUT/mutant/$1" |
| 32 | rm -f "$OUT/mutant/$1.ir" "$OUT/mutant/$1.opt.ir" |
| 33 | } |
| 34 | mut hopcore-names 's/^ret sub 160 minu 30 sub nl ql$/ret sub 161 minu 30 sub nl ql/' |
| 35 | mut hopcore-paths 's/^s = add s 5$/s = add s 6/' |
| 36 | mut hopcore-text 's/^if lt w 3$/if lt w 2/' |
| 37 | mut hopcore-words 's/^if le rc 3$/if le rc 2/' |
| 38 | mut hopcore-board 's/^if lt ns 4$/if lt ns 3/' |
| 39 | mut hopcore-spans 's/^semit ob add cnt g sub i t0 4 2 0$/semit ob add cnt g sub i t0 4 3 0/' |
| 40 | mut hopcore-addr 's/^ret ne role 0$/ret eq role 0/' |
| 41 | mut hopcore-asm 's/^if eq matches 1$/if ge matches 1/' |
| 42 | mut hopcore-status 's/^if and eq state add k_b 1 gt idle add k_b 600$/if and eq state add k_b 1 gt idle add k_b 601/' |
| 43 | mut hopcore-rank 's/^n = rkadd n 3 k add k_b 230 0$/n = rkadd n 3 k add k_b 231 0/' |
| 44 | mut hopcore-suggest 's/^s = 130$/s = 131/' |
| 45 | mut hopcore-lifts 's/^f = div mul 60 get r_as i ft$/f = div mul 61 get r_as i ft/' |
| 46 | mut hopcore-gcm 's/^put c_l4 15 46560$/put c_l4 15 46561/' |
| 47 | { |
| 48 | echo "# hopcore, generated on $(uname -sm) by Omega NG (omega-mv 3f719770, ng $want)" |
| 49 | echo "# ngcheck: $(cat "$OUT/ngcheck.txt")" |
| 50 | (cd "$ROOT" && sha256sum Omega/hopcore.om) |
| 51 | (cd "$OUT" && sha256sum hopcore | sed 's# # Generated/#') |
| 52 | } > "$OUT/CORE-SHA256SUMS" |
| 53 | cat "$OUT/CORE-SHA256SUMS" |