# https://just.systems/man/en/
#
# Take a look at ./doc/manual/src/contributing/hacking.md for a detailed
# explanation on how to use this file!

outdir := x"${out:-$PWD/outputs/out}"
builddir := "build"

# List all available targets
list:
    just --list

# Clean build artifacts
clean:
    rm -rf {{ builddir }}

# Prepare meson for building.
setup *OPTIONS:
    meson setup {{ builddir }} --reconfigure --prefix="{{outdir}}" $mesonFlags {{ OPTIONS }}

# Build lix with extra options
build *OPTIONS:
    meson compile -C {{ builddir }} {{ OPTIONS }}

alias compile := build

# `meson install` will automatically build anything that needs to be built to install it.
[doc("Install Lix for local development")]
install *OPTIONS:
    meson install --quiet -C {{ builddir }} {{ OPTIONS }}

# Run all tests tests (installs first).
test *OPTIONS: (install)
    meson test -C {{ builddir }} --print-errorlogs --max-lines 10000 {{ OPTIONS }}

# Run unit tests only
test-unit *OPTIONS: (test "--suite" "check")

# Run integration tests only
test-integration *OPTIONS: (test "--suite" "installcheck" OPTIONS)

# Run functional2 tests using pytest directly, allowing for additional arguments to be passed to pytest e.g. for more granular test selection
test-functional2 *OPTIONS:
    cd tests/functional2 && python -m pytest -v {{ OPTIONS }}

alias clang-tidy := lint

# Lint with `clang-tidy`
lint:
    ninja -C build clang-tidy

alias clang-tidy-fix := lint-fix

# Fix lints with `clang-tidy-fix`
lint-fix:
    ninja -C build clang-tidy-fix
