omega-dnn
aien-dev/omega-dnn
Brought by drakestapleton
| 1 | #!/bin/sh |
| 2 | # Build build/libomega_native.so + bindings from om/dnn.om with the pinned compilers and omega-bridge. |
| 3 | # Usage: tools/build.sh (fetches the pins into .deps/ when OMEGA_MV / OMEGA_BRIDGE are unset) |
| 4 | # OMEGA_MV=<omega-mv clone> OMEGA_BRIDGE=<omega-bridge clone> tools/build.sh |
| 5 | # The pins (parent omega-mv, bridge ABI v2) are in PINS; a compiler whose sha256 differs is refused. |
| 6 | set -eu |
| 7 | ROOT=$(cd "$(dirname "$0")/.." && pwd) |
| 8 | . "$ROOT/PINS" |
| 9 | DEPS=$ROOT/.deps |
| 10 | fetch() { # repo sha dir |
| 11 | [ -d "$3/.git" ] || git clone -q --filter=blob:none --no-checkout "https://github.com/aien-dev/$1" "$3" |
| 12 | git -C "$3" fetch -q origin "$2" 2>/dev/null || git -C "$3" fetch -q origin |
| 13 | git -C "$3" checkout -q "$2" |
| 14 | } |
| 15 | if [ -z "${OMEGA_MV:-}" ]; then OMEGA_MV=$DEPS/omega-mv; fetch omega-mv "$OMEGA_MV_SHA" "$OMEGA_MV"; fi |
| 16 | if [ -z "${OMEGA_BRIDGE:-}" ]; then OMEGA_BRIDGE=$DEPS/omega-bridge; fetch omega-bridge "$OMEGA_BRIDGE_SHA" "$OMEGA_BRIDGE"; fi |
| 17 | OMC1=$OMEGA_MV/evidence/SEED-0/omc/omc.elf |
| 18 | OMC2=$OMEGA_MV/seed/out/omc |
| 19 | chmod +x "$OMC1" "$OMC2" |
| 20 | check() { got=$(sha256sum < "$1" | cut -d' ' -f1); [ "$got" = "$2" ] || { echo "build.sh: $1 sha256 $got, pinned $2" >&2; exit 1; }; } |
| 21 | check "$OMC1" "$OMC1_SHA256" |
| 22 | check "$OMC2" "$OMC2_SHA256" |
| 23 | SRC=${OMEGA_DNN_SRC:-$ROOT/om/dnn.om} |
| 24 | OUT=${OMEGA_DNN_OUT:-$ROOT/build} |
| 25 | "$OMC2" < "$SRC" > /dev/null |
| 26 | OMEGA_NATIVE_OMC=$OMC1 OMEGA_NATIVE_OMC2=$OMC2 "$OMEGA_BRIDGE/tools/native" "$OUT" "$SRC" |