interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tools / bridge

17 lines · 892 bytes Raw Blame History
1#!/bin/sh
2# The pinned Omega frontend checks the complete unit before either backend runs.
3set -eu
4case ${1-} in c) mode=C;; python) mode=P;; *) echo 'usage: tools/bridge c|python source.om' >&2; exit 64;; esac
5[ "$#" = 2 ] || exit 64
6input=$(realpath -- "$2")
7cd "$(dirname "$0")/.."
8sha256sum --status -c build/compiler.sha256 || { echo "rebuild required: tools/build.sh" >&2; exit 65; }
9seed=${OMEGA_SEED:-build/bootstrap/omc}
10[ "$(sha256sum "$seed" | cut -d' ' -f1)" = 191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9 ] || exit 65
11# Snapshot once: validation and generation must read identical bytes.
12tmp=$(mktemp -d build/request.XXXXXX)
13trap 'find "$tmp" -type f -delete; rmdir "$tmp"' EXIT HUP INT TERM
14cat "$input" > "$tmp/input.om"
15"$seed" < "$tmp/input.om" > "$tmp/native"
16[ -s "$tmp/native" ] || exit 65
17{ printf '%s' "$mode"; cat "$tmp/input.om"; } | build/bridge