interplane.io
Source of interplane.io: a Rust generator that renders the page from the protocol repository's public record, deployed hourly from the Spark.
Brought by drakestapleton
interplane.io / scripts / build-native.sh
| 1 | #!/bin/sh |
| 2 | # Host orchestration only. Site assembly and every check live in native/site.om. |
| 3 | # OMC pinned Omega compiler for AArch64 Linux (default: $OMEGA_SRC/seed/out/omc) |
| 4 | # OMEGA_SRC local Omega checkout, used only when OMC is unset (default: $HOME/workspace/omega-mv) |
| 5 | # Usage: sh scripts/build-native.sh OUTPUT |
| 6 | set -eu |
| 7 | |
| 8 | if [ "$#" -ne 1 ]; then |
| 9 | echo 'usage: build-native.sh OUTPUT' >&2 |
| 10 | exit 2 |
| 11 | fi |
| 12 | OUTPUT=$1 |
| 13 | OMC=${OMC:-"${OMEGA_SRC:-$HOME/workspace/omega-mv}/seed/out/omc"} |
| 14 | if [ ! -x "$OMC" ]; then |
| 15 | echo "pinned compiler missing or not executable: $OMC; set OMC explicitly" >&2 |
| 16 | exit 2 |
| 17 | fi |
| 18 | ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) |
| 19 | # native/omc.sha256 is the one copy of the pin, written by scripts/pin-omc.sh from omega-mv main. |
| 20 | read -r PIN_HASH _ < "$ROOT/native/omc.sha256" |
| 21 | COMPILER_HASH=$(sha256sum "$OMC") |
| 22 | COMPILER_HASH=${COMPILER_HASH%% *} |
| 23 | if [ "$COMPILER_HASH" != "$PIN_HASH" ]; then |
| 24 | echo "refuse: compiler SHA-256 is not the pinned Omega compiler ($PIN_HASH, native/omc.sha256): $COMPILER_HASH" >&2 |
| 25 | exit 3 |
| 26 | fi |
| 27 | |
| 28 | LIB_HASH=$(sha256sum "$ROOT/native/lib/sha2.om") |
| 29 | LIB_HASH=${LIB_HASH%% *} |
| 30 | if [ "$LIB_HASH" != 5cf0f98116def6917d3a373f2bd4c3932d46e3ff84d9567bbae9e720366fdb33 ]; then |
| 31 | echo "refuse: native/lib/sha2.om is not the pinned SHA-2 unit: $LIB_HASH" >&2 |
| 32 | exit 3 |
| 33 | fi |
| 34 | mkdir -p "$(dirname -- "$OUTPUT")" |
| 35 | WORK=$(mktemp -d "$(dirname -- "$OUTPUT")/.native-build.XXXXXXXX") |
| 36 | trap 'rm -rf "$WORK"' 0 |
| 37 | trap 'exit 1' 1 2 15 |
| 38 | # Units concatenate: the om2 line, the SHA-2 unit, then the builder. |
| 39 | { printf 'om2\n'; cat "$ROOT/native/lib/sha2.om" "$ROOT/native/site.om" "$ROOT/native/translate.om"; } > "$WORK/unit.om" |
| 40 | if "$OMC" < "$WORK/unit.om" > "$WORK/site" 2> "$WORK/err"; then |
| 41 | : |
| 42 | else |
| 43 | rc=$? |
| 44 | cat "$WORK/err" >&2 |
| 45 | echo "refuse: compile failed with status $rc (unit line = native/site.om line + $(($(wc -l < "$ROOT/native/lib/sha2.om") + 1)))" >&2 |
| 46 | exit 4 |
| 47 | fi |
| 48 | test -s "$WORK/site" |
| 49 | chmod +x "$WORK/site" |
| 50 | mv "$WORK/site" "$OUTPUT" |