interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / source-aware / build

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