include help-system.mk

FEATURES?=default

run: $(call print-help, run, Runs the binary in develop mode)
	cargo run --features $(FEATURES) --no-default-features

run-debug: $(call print-help, run-debug, Runs the binary with the 'debug' feature, which shows map generation, and other debug functionality)
	cargo run --features debug

run-pi: $(call print-help, run-pi, Sets appropriate flags so that the game runs on a Raspberry Pi)
	MESA_GL_VERSION_OVERRIDE=3.0 MESA_GLSL_VERSION_OVERRIDE=330 cargo run --features $(FEATURES)

run-curses: $(call print-help, run-curses, Run the game in a console window via the curses library)
	cargo run --features curses --no-default-features

build:
	cargo build

build-wasm: $(call print-help, build-wasm, Build the webassembly version of the game)
	cargo build --release --target wasm32-unknown-unknown --features wasm
	wasm-bindgen target/wasm32-unknown-unknown/release/roguelike_tutorial.wasm --out-dir wasm --no-modules --no-typescript

build-wasm-dev: $(call print-help, build-wasm-dev, Build the webassembly version of the game (dev version))
	cargo build --target wasm32-unknown-unknown --features wasm,debug
	wasm-bindgen target/wasm32-unknown-unknown/debug/roguelike_tutorial.wasm --out-dir wasm --no-modules --no-typescript

clean: $(call print-help, clean, Removes save file and compilation artifacts)
	rm -f savegame.json
	cargo clean

check: $(call print-help, check, Check code syntax)
	cargo check --features $(FEATURES)

check-wasm: $(call print-help, check-wasm, Check code syntax for webassembly build)
	cargo check --target wasm32-unknown-unknown --features wasm

lint: $(call print-help, lint, Check code syntax and style)
	cargo clippy --features $(FEATURES)

fmt: $(call print-help, fmt, Runs formatter on code)
	cargo +nightly fmt

fix: $(call print-help, fix, Fixes some warnings, then runs the formatter)
	cargo fix --allow-dirty --allow-staged
	make fmt

docs: $(call print-help, docs, Generates code docs)
	cargo doc --features $(FEATURES) --document-private-items

.phony: run-pi clean check run fmt fix lint docs build build-wasm check-wasm build-wasm-dev