#!/bin/sh # build.sh - pack dev/ into the one bench.sh at the repo root, which is all # people download. It unpacks the helpers to a temp dir and runs dev's # bench.sh from there, with results and bench.local.env next to itself. # # usage: dev/build.sh (then commit the root bench.sh with dev/) # dev/build.sh --check (exit 1 if the root bench.sh is out of date) set -eu dev=$(cd "$(dirname "$0")" && pwd) out="$dev/../bench.sh" files="bench.sh collect-env.sh gpu-power.sh mem-bw.py config.json standard.env" eof=__BENCH_STANDARD_EOF__ . "$dev/standard.env" for f in $files; do if grep -q "$eof" "$dev/$f"; then echo "build.sh: $f contains $eof" >&2; exit 1; fi done tmp=$(mktemp) trap 'rm -f "$tmp"' EXIT { cat < \"\$d/%s\" <<'%s'\n" "$f" "$eof" cat "$dev/$f" printf '%s\n' "$eof" done printf 'sh "$d/bench.sh" "$@"\n' } > "$tmp" if [ "${1:-}" = --check ]; then cmp -s "$tmp" "$out" || { echo "build.sh: bench.sh is out of date, run dev/build.sh" >&2; exit 1; } echo "bench.sh is up to date" else cp "$tmp" "$out" && chmod +x "$out" echo "built $(cd "$dev/.." && pwd)/bench.sh ($(wc -c < "$out") bytes)" fi