# moon-plasma tasks. `just` lists them.
set shell := ["bash", "-euo", "pipefail", "-c"]

export PATH := env_var('HOME') + "/.moon/bin:" + env_var('PATH')

socket := env_var_or_default('XDG_RUNTIME_DIR', '/tmp') + "/wayland-moon-0"
theme := "config/themes/moon-night.json"
exe := "_build/native/debug/build/compositor/bin/bin.exe"

default:
    @just --list

# Build the native compositor.
build:
    moon build --target native --warn-list -a compositor/bin

# Run the compositor (Ctrl-C to stop). Connect clients via `just client`.
run: build
    rm -f {{socket}}
    {{exe}} --socket {{socket}} --theme {{theme}}

# Start a Wayland client inside the running compositor (default: foot).
client *cmd="foot":
    WAYLAND_DISPLAY={{socket}} {{cmd}}

# Compositor + wasm component + lib tests.
test:
    moon test --target native --warn-list -a compositor/renderer compositor/host
    moon test --target wasm --warn-list -a lib/shell lib/panel lib/clock lib/launcher lib/wm

# Render one composed frame to _build/e2e_frame.png (via the e2e test).
frame:
    moon test --target native --warn-list -a compositor/host
    @echo "wrote _build/e2e_frame.png"

# Everything CI runs.
ci:
    scripts/test.sh
