rtl8127-omega
aien-dev/rtl8127-omega
Brought by drakestapleton
rtl8127-omega / tools / omc.sh
| 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 |
| 5 | set -eu |
| 6 | root=$(cd "$(dirname "$0")/.." && pwd) |
| 7 | pin_commit=$(awk '$1 == "omega-mv" { print $2 }' "$root/omega.pin") |
| 8 | pin_sha=$(awk '$1 == "omc-sha256" { print $2 }' "$root/omega.pin") |
| 9 | check() { [ -x "$1" ] && [ "$(sha256sum "$1" | cut -d' ' -f1)" = "$pin_sha" ]; } |
| 10 | if [ -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 |
| 13 | fi |
| 14 | if check "$root/build/omc"; then echo "$root/build/omc"; exit 0; fi |
| 15 | src="$root/build/omega-mv" |
| 16 | if [ ! -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 |
| 19 | fi |
| 20 | git -C "$src" fetch -q origin "$pin_commit" >&2 || true |
| 21 | git -C "$src" checkout -q --detach "$pin_commit" >&2 |
| 22 | (cd "$src" && sh seed/omega-from-seed.sh) >&2 |
| 23 | check "$src/seed/out/omc" || { echo "omc.sh: built omc does not match pin $pin_sha" >&2; exit 1; } |
| 24 | echo "$src/seed/out/omc" |