interplane.Get Omega
Read in your language

rtl8127-omega

aien-dev/rtl8127-omega

Brought by drakestapleton

branch main Branches Tags History

rtl8127-omega / tools / omc.sh

24 lines · 1195 bytes Raw Blame History
1#!/bin/sh
2# Print the path of a verified Omega compiler (omc).
3# OMC=/path/to/omc picks one (it is checked against the pin). Otherwise: ./build/omc if it matches, else the omnet-style
4# birth from the pinned omega-mv commit (needs git and network). Usage: tools/omc.sh
5set -eu
6root=$(cd "$(dirname "$0")/.." && pwd)
7pin_commit=$(awk '$1 == "omega-mv" { print $2 }' "$root/omega.pin")
8pin_sha=$(awk '$1 == "omc-sha256" { print $2 }' "$root/omega.pin")
9check() { [ -x "$1" ] && [ "$(sha256sum "$1" | cut -d' ' -f1)" = "$pin_sha" ]; }
10if [ -n "${OMC:-}" ]; then
11 check "$OMC" || { echo "omc.sh: $OMC does not match the pinned sha256 $pin_sha" >&2; exit 1; }
12 echo "$OMC"; exit 0
13fi
14if check "$root/build/omc"; then echo "$root/build/omc"; exit 0; fi
15src="$root/build/omega-mv"
16if [ ! -d "$src/.git" ]; then
17 mkdir -p "$root/build"
18 git clone -q --filter=blob:none https://github.com/aien-dev/omega-mv.git "$src" >&2
19fi
20git -C "$src" fetch -q origin "$pin_commit" >&2 || true
21git -C "$src" checkout -q --detach "$pin_commit" >&2
22(cd "$src" && sh seed/omega-from-seed.sh) >&2
23check "$src/seed/out/omc" || { echo "omc.sh: built omc does not match pin $pin_sha" >&2; exit 1; }
24echo "$src/seed/out/omc"