interplane.Get Omega
Read in your language

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

branch main Branches Tags History

interplane.io / scripts / build-native.sh

50 lines · 1961 bytes Raw Blame History
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
6set -eu
7
8if [ "$#" -ne 1 ]; then
9 echo 'usage: build-native.sh OUTPUT' >&2
10 exit 2
11fi
12OUTPUT=$1
13OMC=${OMC:-"${OMEGA_SRC:-$HOME/workspace/omega-mv}/seed/out/omc"}
14if [ ! -x "$OMC" ]; then
15 echo "pinned compiler missing or not executable: $OMC; set OMC explicitly" >&2
16 exit 2
17fi
18ROOT=$(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.
20read -r PIN_HASH _ < "$ROOT/native/omc.sha256"
21COMPILER_HASH=$(sha256sum "$OMC")
22COMPILER_HASH=${COMPILER_HASH%% *}
23if [ "$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
26fi
27
28LIB_HASH=$(sha256sum "$ROOT/native/lib/sha2.om")
29LIB_HASH=${LIB_HASH%% *}
30if [ "$LIB_HASH" != 5cf0f98116def6917d3a373f2bd4c3932d46e3ff84d9567bbae9e720366fdb33 ]; then
31 echo "refuse: native/lib/sha2.om is not the pinned SHA-2 unit: $LIB_HASH" >&2
32 exit 3
33fi
34mkdir -p "$(dirname -- "$OUTPUT")"
35WORK=$(mktemp -d "$(dirname -- "$OUTPUT")/.native-build.XXXXXXXX")
36trap 'rm -rf "$WORK"' 0
37trap '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"
40if "$OMC" < "$WORK/unit.om" > "$WORK/site" 2> "$WORK/err"; then
41 :
42else
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
47fi
48test -s "$WORK/site"
49chmod +x "$WORK/site"
50mv "$WORK/site" "$OUTPUT"