#!/bin/sh
# =============================================================================
# freebsd-setup.sh — runs INSIDE the FreeBSD VM (vmactions/freebsd-vm `prepare`).
# =============================================================================
# Role: install the Rust toolchain. audio-clock-bsd is pure Rust (thiserror +
# audio-core-bsd) — 0 system deps.
# Portability: /bin/sh on FreeBSD (no bashisms).
# =============================================================================
set -eu

if ! command -v cargo >/dev/null 2>&1; then
  echo "installing rustup + stable toolchain..."
  command -v curl >/dev/null 2>&1 || pkg install -y curl ca_root_nss
  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
    | sh -s -- -y --profile default
fi

if [ -f "$HOME/.cargo/env" ]; then
  # shellcheck disable=SC1091
  . "$HOME/.cargo/env"
fi

echo "rustc: $(rustc --version)"
echo "cargo: $(cargo --version)"

# audio-clock-bsd links no system library → nothing else to install.

echo "setup: ok"
