#!/usr/bin/env bash
#
# macOS entrypoint for the self-built FFmpeg binary.
# Builds the arm64 binary natively (VizLoom ships Apple Silicon only).
# The actual recipe lives in build-ffmpeg-core.sh.
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Toolchain hints (the core script re-checks, but fail early with install guidance).
if ! xcode-select -p >/dev/null 2>&1; then
  echo "ERROR: Xcode Command Line Tools required. Install with: xcode-select --install" >&2
  exit 1
fi
NEED=()
command -v nasm >/dev/null 2>&1 || NEED+=("nasm")
command -v pkg-config >/dev/null 2>&1 || NEED+=("pkg-config")
if ((${#NEED[@]})); then
  echo "ERROR: missing build tools: ${NEED[*]}" >&2
  echo "Install with: brew install ${NEED[*]}" >&2
  exit 1
fi

bash "$SCRIPT_DIR/build-ffmpeg-core.sh" mac arm64
