name := "HanjaKanaMun"
build_dir := "build"

# List available recipes
default:
    @just --list

# Debug build
build:
    odin build . -vet -debug -out:{{name}}

# Build and run (debug)
run:
    odin run . -vet -debug -out:{{name}}

# Type-check with vet, no binary
check:
    odin check . -vet

# Run the test suite (single-threaded: the tests share the memory game's global state)
test:
    mkdir -p {{build_dir}}
    odin test tests -vet -define:ODIN_TEST_THREADS=1 -out:{{build_dir}}/tests

# Optimized build into build/, with the assets it needs at runtime
release:
    mkdir -p {{build_dir}}/{{name}}
    odin build . -vet -o:speed -out:{{build_dir}}/{{name}}/{{name}}
    cp -R assets {{build_dir}}/{{name}}/

# Release build packed as build/<name>_<version>_<os>_<arch>.tar.gz
package version="dev": release
    tar -czf {{build_dir}}/{{name}}_{{version}}_{{os()}}_{{arch()}}.tar.gz -C {{build_dir}} {{name}}
    @echo "{{build_dir}}/{{name}}_{{version}}_{{os()}}_{{arch()}}.tar.gz"

# Format all Odin files with odinfmt (settings in odinfmt.json)
fmt:
    odinfmt -w .

# Remove build output
clean:
    if [ -d {{build_dir}} ]; then rm -r -- {{build_dir}}; fi
    rm -f -- {{name}}
