#!/usr/bin/env bash
# Run a compiled part1 (C/C++) target on the HOST.
#   Usage: tools/run.sh <target>            # run ./build/path/<target>
#          tools/run.sh <target> [args...]  # pass args
# Looks up the target binary under build/ automatically.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
target="${1:?usage: tools/run.sh <target> [args...]}"
shift || true
bin=$(find "$REPO_ROOT/build" -type f -name "$target" -executable 2>/dev/null | head -1) || true
if [ -z "$bin" ]; then
    echo "target '$target' not found under $REPO_ROOT/build. Build first." >&2
    exit 1
fi
exec "$bin" "$@"
