interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / allen-page / speed-check.sh

51 lines · 2016 bytes Raw Blame History
1#!/bin/sh
2# Regenerate public/js/aien-speed.js (the AienSpeed component) from speed-js.om
3# with the pinned arm64 omc vendored for the Hive page; its pin is recorded once,
4# in ../hive-page/omc.sha256. CI on x86_64 checks the committed script against
5# aien-speed.js.sha256. OMEGA_OMC overrides the compiler path, never its pin.
6# OMEGA_ACCEPT_CHANGE=1 accepts a rewritten script; otherwise stale output exits 4.
7# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten;
8# 5: nondeterministic output; 6: empty output. Compile/run failures propagate.
9set -eu
10cd "$(dirname "$0")"
11omc=${OMEGA_OMC:-$PWD/../hive-page/omc}
12pin=$(tr -d ' \n' < ../hive-page/omc.sha256)
13if [ ! -f "$omc" ]; then
14 printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2
15 exit 2
16fi
17have=$(sha256sum "$omc" | cut -d' ' -f1)
18if [ "$have" != "$pin" ]; then
19 printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2
20 exit 3
21fi
22work=$(mktemp -d "${TMPDIR:-/tmp}/aien-speed.XXXXXX")
23trap 'rm -rf "$work"' EXIT HUP INT TERM
24"$omc" < speed-js.om > "$work/speed"
25chmod +x "$work/speed"
26"$work/speed" > "$work/first.js"
27"$work/speed" > "$work/second.js"
28artifact=../../public/js/aien-speed.js
29if ! cmp -s "$work/first.js" "$work/second.js"; then
30 printf '%s: generator output differs between runs\n' "$artifact" >&2
31 exit 5
32fi
33if [ ! -s "$work/first.js" ]; then
34 printf '%s: generator wrote nothing\n' "$artifact" >&2
35 exit 6
36fi
37stale=0
38if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$work/first.js"; then
39 stale=1
40fi
41cp "$work/first.js" "$artifact"
42hash=$(sha256sum "$artifact" | cut -d' ' -f1)
43printf '%s %s\n' "$hash" "$artifact" > aien-speed.js.sha256
44printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash"
45printf 'omc sha256 %s\n' "$have"
46if [ "$stale" = 1 ]; then
47 printf 'Generated script was rewritten; commit it with speed-js.om\n' >&2
48 if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then
49 exit 4
50 fi
51fi