56 lines
1.8 KiB
Bash
56 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
# One-time developer setup (Linux / macOS):
|
|
# - verifies required tools
|
|
# - installs vcpkg if VCPKG_ROOT is not set
|
|
# - pins the vcpkg dependency baseline in vcpkg.json
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "${REPO_ROOT}"
|
|
|
|
echo ">> Checking required tools"
|
|
missing=0
|
|
for tool in git cmake ninja; do
|
|
if ! command -v "${tool}" >/dev/null 2>&1; then
|
|
echo " MISSING: ${tool}" >&2
|
|
missing=1
|
|
fi
|
|
done
|
|
if [[ "${missing}" -ne 0 ]]; then
|
|
echo "ERROR: install the missing tools and re-run." >&2
|
|
exit 1
|
|
fi
|
|
if ! command -v c++ >/dev/null 2>&1 && ! command -v clang++ >/dev/null 2>&1; then
|
|
echo "WARNING: no C++ compiler found on PATH (need GCC 13+ or Clang 16+ for C++23)." >&2
|
|
fi
|
|
|
|
echo ">> Setting up vcpkg"
|
|
if [[ -z "${VCPKG_ROOT:-}" ]]; then
|
|
if [[ ! -d "${REPO_ROOT}/vcpkg" ]]; then
|
|
echo " Cloning vcpkg into ./vcpkg"
|
|
git clone https://github.com/microsoft/vcpkg.git "${REPO_ROOT}/vcpkg"
|
|
fi
|
|
"${REPO_ROOT}/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
|
|
export VCPKG_ROOT="${REPO_ROOT}/vcpkg"
|
|
echo " VCPKG_ROOT is not set in your environment."
|
|
echo " Add this to your shell profile (~/.bashrc, ~/.zshrc):"
|
|
echo " export VCPKG_ROOT=\"${REPO_ROOT}/vcpkg\""
|
|
else
|
|
echo " Using VCPKG_ROOT=${VCPKG_ROOT}"
|
|
fi
|
|
VCPKG_EXE="${VCPKG_ROOT}/vcpkg"
|
|
|
|
echo ">> Pinning the vcpkg dependency baseline"
|
|
if grep -q '"builtin-baseline"' vcpkg.json; then
|
|
echo " builtin-baseline already present — leaving it pinned."
|
|
else
|
|
"${VCPKG_EXE}" x-update-baseline --add-initial-baseline
|
|
echo " Added builtin-baseline to vcpkg.json. Commit this change."
|
|
fi
|
|
|
|
echo ""
|
|
echo ">> Bootstrap complete. Next steps:"
|
|
echo " cmake --preset linux-debug # or macos-debug"
|
|
echo " cmake --build --preset linux-debug"
|
|
echo " ctest --preset linux-debug"
|