#!/bin/sh # Deterministic release build of the native helpers (src/gate/rust: frame-gate, source-bus). # # scripts/build-helpers.sh [OUT_DIR] (default: apps/media-worker/bin) # # std only, no crates: `--offline --locked` needs no network and fails if Cargo.lock would change. # Reproducible for a given rustc: the crate path is remapped out of the binary, symbols are # stripped, and the build uses its own target dir (the development target/ is left alone). # OUT_DIR gets the two binaries plus SHA256SUMS; the worker finds them via MEDIA_HELPER_DIR # (src/gate/binary.ts). The image builds this in a pinned rust stage (infra/media-worker.Dockerfile). set -eu here=$(cd "$(dirname "$0")/.." && pwd) crate="$here/src/gate/rust" out=${1:-"$here/bin"} target=${CARGO_TARGET_DIR:-"$crate/target/package"} export CARGO_TARGET_DIR="$target" export RUSTFLAGS="--remap-path-prefix=$crate=/frame-gate -C strip=symbols -C debuginfo=0" cargo build --release --offline --locked --manifest-path "$crate/Cargo.toml" mkdir -p "$out" for bin in frame-gate source-bus; do install -m 0755 "$target/release/$bin" "$out/$bin" done (cd "$out" && sha256sum frame-gate source-bus > SHA256SUMS && cat SHA256SUMS) rustc --version > "$out/RUSTC_VERSION"