omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tools / source-aware / build-v2
| 1 | #!/bin/bash |
| 2 | # Host build orchestration only for the source-aware v2 codec (spec/universal/source-aware-v2.md). |
| 3 | # Same pinned source-born seed chain as tools/source-aware/build; the v1 core and build/L574 are untouched. |
| 4 | set -euo pipefail |
| 5 | cd "$(dirname "$0")/../.." |
| 6 | build=${SA_BUILD:-build/L832} |
| 7 | case "$build" in build/L832|build/L832/*) ;; *) echo 'unsafe source-aware build path' >&2; exit 73;; esac |
| 8 | case "/$build/" in */../*|*/./*|*//*) echo 'unsafe source-aware build path' >&2; exit 73;; esac |
| 9 | [ ! -L build ] && [ ! -L build/L832 ] || exit 73 |
| 10 | if [ -d build/L832 ]; then |
| 11 | unsafe=$(find build/L832 \( -type l -o -type f -links +1 -o ! -type d ! -type f \) -print) |
| 12 | [ -z "$unsafe" ] || { echo 'unsafe source-aware build tree' >&2; exit 73; } |
| 13 | fi |
| 14 | mkdir -p "$build" |
| 15 | # No stale success after any failed build. Test receipts are caller-owned scratch. |
| 16 | rm -f "$build/PASS.json" "$build/sa" "$build/sa.tmp" |
| 17 | trap 'rm -f "$build/sa.tmp"' EXIT |
| 18 | seed_repo=${SA_SEED_REPO:-/home/drakestapleton/workspace/omega-bridge-native-development} |
| 19 | pin=0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9 |
| 20 | expected=191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9 |
| 21 | sourcehash=8608fa11f6a2cf1c50db22d871eef16b00d5bc719bc1a222cc3e456984ac5ebf |
| 22 | # A different committed repository may be used, never an untracked binary overlay. |
| 23 | git -C "$seed_repo" cat-file -e "$pin^{commit}" |
| 24 | [ "$(git -C "$seed_repo" show "$pin:seed/omc/omc.om" | sha256sum | cut -d' ' -f1)" = "$sourcehash" ] |
| 25 | if [ ! -d "$build/toolchain" ]; then |
| 26 | mkdir "$build/toolchain" |
| 27 | git -C "$seed_repo" archive "$pin" | tar -x -C "$build/toolchain" |
| 28 | fi |
| 29 | # Verify the original lock and all imported seed source before every compile. |
| 30 | (cd "$build/toolchain" && tools/verify-sources.sh) |
| 31 | if [ ! -f "$build/toolchain/build/bootstrap/omc" ]; then |
| 32 | (cd "$build/toolchain" && tools/bootstrap.sh --offline) > "$build/bootstrap.log" 2>&1 |
| 33 | fi |
| 34 | compiler="$build/toolchain/build/bootstrap/omc" |
| 35 | [ "$(sha256sum "$compiler" | cut -d' ' -f1)" = "$expected" ] |
| 36 | [ "$(sha256sum "$build/toolchain/seed/omc/omc.om" | cut -d' ' -f1)" = "$sourcehash" ] |
| 37 | sh "$build/toolchain/tools/verify-elf.sh" "$compiler" |
| 38 | sha256sum -c tools/source-aware/imports.sha256 > "$build/imports.log" |
| 39 | cat src/source-aware/vendor/sha256.om src/source-aware/core-v2.om src/source-aware/main.om > "$build/sa.om" |
| 40 | "$compiler" < "$build/sa.om" > "$build/sa.tmp" |
| 41 | sh "$build/toolchain/tools/verify-elf.sh" "$build/sa.tmp" |
| 42 | chmod +x "$build/sa.tmp" |
| 43 | mv "$build/sa.tmp" "$build/sa" |
| 44 | sha256sum "$compiler" "$build/sa.om" "$build/sa" > "$build/toolchain.sha256" |