#!/usr/bin/env bash
# run_host.sh — compile and run the Java AER-1 conformance port.
# Self-locating: works from any checkout layout; no hardcoded paths.
# macOS bash 3.x compatible (no GNU-only flags, no readlink -f).
set -euo pipefail

DIR="$(cd "$(dirname "$0")" && pwd)"
KIT="${1:-$DIR/../kit-snapshot}"   # arg1 may override the kit root
OUT="$DIR/out"

mkdir -p "$OUT"
echo ">> javac -encoding UTF-8 -d $OUT $DIR/*.java"
javac -encoding UTF-8 -d "$OUT" "$DIR"/*.java

echo ">> java -Dfile.encoding=UTF-8 -cp $OUT RunKit $KIT"
java -Dfile.encoding=UTF-8 -cp "$OUT" RunKit "$KIT"
