aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / om / allen-scene / check.sh
| 1 | #!/bin/sh |
| 2 | # Build the explicitly-authorized native C/WASM dependency and Omega controller. |
| 3 | # --generate: generate artifacts once, no test claims. Default: deterministic |
| 4 | # regeneration and exact committed-artifact checks. No package installation. |
| 5 | set -eu |
| 6 | cd "$(dirname "$0")" |
| 7 | omc=${OMEGA_OMC:-../hive-page/omc} |
| 8 | clang=${ALLEN_CLANG:-clang-18} |
| 9 | ld=${ALLEN_WASM_LD:-wasm-ld-18} |
| 10 | pin=$(tr -d ' \n' < ../hive-page/omc.sha256) |
| 11 | have=$(sha256sum "$omc" | cut -d' ' -f1) |
| 12 | [ "$pin" = "$have" ] || { printf 'Wrong Omega compiler pin\n' >&2; exit 3; } |
| 13 | "$clang" --version | grep -F 'clang version 18.1.3' >/dev/null || { printf 'Native dependency requires clang 18.1.3\n' >&2; exit 3; } |
| 14 | "$ld" --version | grep -F '18.1.3' >/dev/null || { printf 'Native dependency requires wasm-ld 18.1.3\n' >&2; exit 3; } |
| 15 | sha256sum -c native.sha256 |
| 16 | work=$(mktemp -d "${TMPDIR:-/tmp}/allen-scene.XXXXXX") |
| 17 | trap 'rm -rf "$work"' EXIT HUP INT TERM |
| 18 | build_wasm() { |
| 19 | "$clang" --target=wasm32 -O2 -nostdlib -ffreestanding -fno-builtin \ |
| 20 | -ffunction-sections -fdata-sections -fvisibility=hidden -fno-ident \ |
| 21 | -Wl,--no-entry -Wl,--strip-all -Wl,--export-memory -Wl,--stack-first \ |
| 22 | -Wl,-z,stack-size=1048576 -Wl,--max-memory=67108864 -Wl,--gc-sections \ |
| 23 | -Wl,--export=scene_init -Wl,--export=scene_pixels -Wl,--export=scene_enter \ |
| 24 | -Wl,--export=scene_key -Wl,--export=scene_word -Wl,--export=scene_step \ |
| 25 | -Wl,--export=scene_draw -Wl,--export=scene_view -Wl,--export=scene_glyph \ |
| 26 | -Wl,--export=scene_audio -Wl,--export=scene_voice -fuse-ld="$ld" \ |
| 27 | adapter.c native/mind.c native/night.c native/paint.c native/allen_font.c \ |
| 28 | native/flow.c native/sky_real.c native/sky_data.c native/chirp.c -o "$1" |
| 29 | } |
| 30 | "$omc" < scene.om > "$work/controller" |
| 31 | chmod +x "$work/controller" |
| 32 | "$work/controller" > "$work/scene.js" |
| 33 | build_wasm "$work/scene.wasm" |
| 34 | if [ "${1:-}" != --generate ]; then |
| 35 | "$work/controller" > "$work/again.js" |
| 36 | build_wasm "$work/again.wasm" |
| 37 | cmp "$work/scene.js" "$work/again.js" |
| 38 | cmp "$work/scene.wasm" "$work/again.wasm" |
| 39 | fi |
| 40 | [ -s "$work/scene.js" ] && [ -s "$work/scene.wasm" ] || exit 6 |
| 41 | if [ "${1:-}" = --generate ] || [ "${OMEGA_ACCEPT_CHANGE:-0}" = 1 ]; then |
| 42 | mkdir -p ../../public/allen |
| 43 | cp "$work/scene.js" ../../public/js/allen-scene.js |
| 44 | cp "$work/scene.wasm" ../../public/allen/scene.wasm |
| 45 | cp scene.om ../../public/allen/scene.om |
| 46 | sha256sum ../../public/js/allen-scene.js ../../public/allen/scene.wasm ../../public/allen/scene.om > artifacts.sha256 |
| 47 | else |
| 48 | cmp "$work/scene.js" ../../public/js/allen-scene.js |
| 49 | cmp "$work/scene.wasm" ../../public/allen/scene.wasm |
| 50 | cmp scene.om ../../public/allen/scene.om |
| 51 | sha256sum -c artifacts.sha256 |
| 52 | fi |
| 53 | printf 'Generated native scene and Omega controller (no browser claim)\n' |