#!/usr/bin/env bash
set -euo pipefail
show_help() {
cat <<'HELP'
Usage: bin/build
Build the two Go binaries: go-service/contentd and harness/harness.
Requires Go 1.26+. No database connection or Python is needed.
Overwrites the built binaries. TMPDIR defaults to ~/codex-tmp.
Example:
bin/build
go-service/contentd --help
Options:
-h, --help Show this help without performing work.
HELP
}
case "${1:-}" in
-h|--help|help) show_help; exit 0 ;;
"") ;;
*) printf 'Unexpected argument; use bin/build --help\n' >&2; exit 2 ;;
esac
project_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
export TMPDIR="${TMPDIR:-$HOME/codex-tmp}"
mkdir -p -- "$TMPDIR"
(cd "$project_root/harness" && go build -buildvcs=false -o harness .)
(cd "$project_root/go-service" && go build -buildvcs=false -o contentd .)