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