# https://just.systems
# Variables

BUILD_DIR := "build"
VCPKG_TOOLCHAIN := env("VCPKG_ROOT", home_directory() / ".vcpkg") / "scripts/buildsystems/vcpkg.cmake"

# Set this to the path where H5Py installs HDF5 binary. On macOS its .dylib, Linux .so, Windows .dll

HDF5_DIR := `../.venv/bin/python -c "import h5py,os;d=os.path.dirname(h5py.__file__);print(os.path.join(d,'.dylibs') if os.path.exists(os.path.join(d,'.dylibs')) else os.path.join(os.path.dirname(d),'h5py.libs'))"`

# Settings
set dotenv-load := true
set export := true

# Default recipe: list available commands
default:
    @just --list

# Setup the CMake build environment
setup:
    export HDF5_DIR={{ HDF5_DIR }}; \
    cmake -B {{ BUILD_DIR }} -S . \
        -DCMAKE_TOOLCHAIN_FILE={{ VCPKG_TOOLCHAIN }} \
        -DCMAKE_BUILD_TYPE=Release \
        -G Ninja

build:
    cmake --build {{ BUILD_DIR }}

# Full build from scratch
full-build: setup build

# Clean all build and dependency artifacts
clean:
    rm -rf {{ BUILD_DIR }} vcpkg_installed

full-clean-build: clean full-build
