# Justfile for Simian project
# Usage: just <recipe>

# Default configuration
set shell := ["powershell", "-Command"]

# Variables
BUILD_DIR := "build"
CMAKE_CONFIG := "Release"
CMAKE_GENERATOR := "Visual Studio 17 2022"
CMAKE_ARCH := "x64"

# Initialize and update submodules
submodules:
    @echo "Updating submodules..."
    git submodule update --init --recursive

# Configure the project (out-of-source)
configure:
    @echo "Configuring CMake (generator: {{CMAKE_GENERATOR}}, arch: {{CMAKE_ARCH}})"
    cmake -G "{{CMAKE_GENERATOR}}" -A {{CMAKE_ARCH}} -S . -B {{BUILD_DIR}}

# Configure for Debug
configure-debug:
    @echo "Configuring Debug"
    cmake -G "{{CMAKE_GENERATOR}}" -A {{CMAKE_ARCH}} -S . -B {{BUILD_DIR}} -DCMAKE_BUILD_TYPE=Debug

# Build (Release by default)
build:
    @echo "Building (config: {{CMAKE_CONFIG}})"
    cmake --build {{BUILD_DIR}} --config {{CMAKE_CONFIG}}

# Build Debug
build-debug:
    @echo "Building Debug"
    cmake --build {{BUILD_DIR}} --config Debug

# Run the built executable (defaults to Debug for development)
run:
    @echo "Running simian (Release)..."
    {{BUILD_DIR}}\Release\simian.exe

run-editor:
    @echo "Running simian (Release) with Editor..."
    {{BUILD_DIR}}\Release\simian.exe --editor

# Run Debug build
run-debug:
    @echo "Running simian (Debug)..."
    {{BUILD_DIR}}\Debug\simian.exe

# Run Release build
run-release:
    @echo "Running simian (Release)..."
    {{BUILD_DIR}}\Release\simian.exe

# Clean build folder
clean:
    @echo "Removing {{BUILD_DIR}} folder"
    Remove-Item -Recurse -Force {{BUILD_DIR}} -ErrorAction SilentlyContinue

# Reconfigure, build and run (convenience)
rebuild-run: submodules configure build run

# Lint / formatting (placeholder)
format:
    @echo "No formatter configured. Add commands here."

# Tests (placeholder - uses CTest if configured)
test:
    @echo "Running tests (if configured)"
    cmake --build {{BUILD_DIR}} --config {{CMAKE_CONFIG}} --target RUN_TESTS

# Provide a help recipe
help:
    @echo "Available recipes: submodules, configure, configure-debug, build, build-debug, run, clean, rebuild-run, format, test"

# Notes for non-Windows shells
# If you're running on Git Bash or WSL, set shell and generator accordingly, e.g.:
# just -s --shell "bash -lc" configure
