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/omega-mcp/blob/main/build.sh # omega-mcp aien-dev/omega-mcp Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mcp / build.sh` 108 lines ยท 5541 bytes Raw Blame History 1 #!/bin/sh 2 # Build omega-mcp with the pinned Omega compiler. 3 # OMEGA_SRC=/path/to/omega-mv ./build.sh (a git clone of omega-mv that contains the PIN revision; default ../omega-mv) 4 # OMC=/path/to/omc OMEGA_SRC=... ./build.sh (use this omc binary instead of the one at the PIN revision) 5 # PIN is the only file that names the pin: `omega-mv REV` and `omc-sha256 SHA`. Everything else is derived: 6 # build/omc REV:seed/out/omc from OMEGA_SRC (or $OMC); refused (exit 2) unless its sha256 is SHA 7 # build/omega-mv/ the units src/UNITS names as `omega-mv:PATH`, read from REV in OMEGA_SRC at every build 8 # (no copy of them is tracked here; exit 2 names a PATH that REV does not hold) 9 # data/ rewritten by tools/gen-reference.py from the source at REV (citation lines, keyword ids, 10 # the keyword total); it stops the build (exit 1) when a cited quote is missing or repeated 11 # at REV. data/ is committed, so after a repin `git diff data/` is the reviewable change 12 # build/pin.om the texts kpin (SHA) and kmv (REV, 8 characters) the server units use: the start-up check 13 # compares the compiler beside the server with kpin; initialize and compile report them 14 # build/pincheck gates/pincheck.om, run over `git ls-files`: a tracked file that restates the pin or names 15 # another hash fails the build (exit 1), so no copy of the pin can drift from PIN 16 # build/agent-maintenance-mcp the separate agent-file maintenance server, built from maintenance/UNITS the 17 # same way as the compiler server (same pinned omc, same omega-mv units); gates/maintenance-cases.sh 18 # build/agent-qa-mcp the agent Q&A server, built from qa/UNITS the same way; gates/qa-cases.sh 19 # Output: build/omega-mcp, build/agent-maintenance-mcp, build/agent-qa-mcp, build/omc, build/data/, 20 # build/pincheck; data/ regenerated. 21 # The server unit is the concatenation listed in src/UNITS: the sha256 unit first (its `layout` must precede 22 # every fn; `export fn` becomes `fn` because a program unit has a `fn main`), then the JSON units, the 23 # generated pin unit and the server units. The leading `om2` line opts the whole unit into profile OM-2. 24 set -eu 25 cd "$(dirname "$0")" 26 die() { echo "build.sh: $2" >&2; exit "$1"; } 27 [ -f PIN ] || die 2 "PIN is missing" 28 set -- $(cat PIN) 29 [ $# -eq 4 ] && [ "$1" = omega-mv ] && [ "$3" = omc-sha256 ] || die 2 "PIN must be two lines: omega-mv REV, omc-sha256 SHA" 30 rev=$2 sha=$4 31 case $rev$sha in *[!0-9a-f]*) die 2 "PIN: REV and SHA must be lowercase hex" ;; esac 32 [ ${#rev} -eq 40 ] && [ ${#sha} -eq 64 ] || die 2 "PIN: REV must have 40 hex digits and SHA 64" 33 src=${OMEGA_SRC:-../omega-mv} 34 git -C "$src" cat-file -e "$rev^{commit}" 2>/dev/null || die 2 "$src is not a git clone of omega-mv containing $rev (set OMEGA_SRC)" 35 git rev-parse --is-inside-work-tree >/dev/null 2>&1 || die 2 "the pin check needs a git checkout of omega-mcp (git ls-files)" 36 mkdir -p build 37 rm -f build/omc.new build/omega-mcp.new build/agent-maintenance-mcp.new build/agent-qa-mcp.new build/pincheck.new 38 if [ -n "${OMC:-}" ]; then 39 cp "$OMC" build/omc.new 40 else 41 git -C "$src" cat-file blob "$rev:seed/out/omc" > build/omc.new || die 2 "omega-mv $rev has no seed/out/omc" 42 fi 43 chmod 755 build/omc.new 44 got=$(sha256sum build/omc.new | cut -d' ' -f1) 45 if [ "$got" != "$sha" ]; then 46 rm -f build/omc.new 47 die 2 "${OMC:-omega-mv $rev:seed/out/omc} has sha256 $got, not the PIN omc-sha256 $sha" 48 fi 49 rm -rf build/omega-mv 50 for u in src/UNITS maintenance/UNITS qa/UNITS; do 51 for f in $(sed -n 's/^omega-mv://p' "$u"); do 52 mkdir -p "build/omega-mv/$(dirname "$f")" 53 git -C "$src" cat-file blob "$rev:$f" > "build/omega-mv/$f" 2>/dev/null || 54 die 2 "omega-mv $rev has no $f ($u names it as omega-mv:$f)" 55 done 56 done 57 python3 tools/gen-reference.py --omega-src "$src" > build/gen.out 2>&1 || { 58 cat build/gen.out >&2; die 1 "tools/gen-reference.py could not write data/ from omega-mv $rev"; } 59 { 60 echo "note generated by build.sh from PIN; edit PIN, never this file" 61 echo "text kpin \"$sha\"" 62 echo "text kmv \"$(echo "$rev" | cut -c1-8)\"" 63 } > build/pin.om 64 concat() { 65 { 66 printf 'om2\n' 67 first=1 68 while read -r f; do 69 case "$f" in ''|'#'*) continue ;; omega-mv:*) f=build/omega-mv/${f#omega-mv:} ;; esac 70 if [ $first = 1 ]; then 71 sed 's/^export fn /fn /' "$f" | grep -v '^om2$' 72 first=0 73 else 74 cat "$f" 75 fi 76 done < "$1" 77 } > "$2" 78 } 79 unit=build/omega-mcp.om 80 concat src/UNITS "$unit" 81 munit=build/agent-maintenance-mcp.om 82 concat maintenance/UNITS "$munit" 83 qunit=build/agent-qa-mcp.om 84 concat qa/UNITS "$qunit" 85 compile() { 86 rc=0 87 build/omc.new < "$1" > "$2" 2> build/omc.err || rc=$? 88 if [ $rc -ne 0 ]; then 89 cat build/omc.err >&2 90 rm -f "$2" 91 die 1 "omc refused $1 (exit $rc); line numbers refer to $1" 92 fi 93 chmod 755 "$2" 94 } 95 compile "$unit" build/omega-mcp.new 96 compile "$munit" build/agent-maintenance-mcp.new 97 compile "$qunit" build/agent-qa-mcp.new 98 compile gates/pincheck.om build/pincheck.new 99 rc=0 100 git ls-files | build/pincheck.new >&2 || rc=$? 101 [ $rc -eq 0 ] || die 1 "pin check failed (exit $rc): see the findings above" 102 mv build/pincheck.new build/pincheck 103 mv build/omega-mcp.new build/omega-mcp 104 mv build/agent-maintenance-mcp.new build/agent-maintenance-mcp 105 mv build/agent-qa-mcp.new build/agent-qa-mcp 106 mv build/omc.new build/omc 107 rm -rf build/data && cp -R data build/data 108 sha256sum build/omega-mcp build/agent-maintenance-mcp build/agent-qa-mcp build/omc