# T-Deck workspace — one common build command per app that builds BOTH
# targets (SDL2 emulator + ESP32-S3 firmware), so a change can never leave
# one of them silently broken.
#
#   make netdeck            build the NetDeck emulator AND the T-Deck firmware
#   make netdeck-test       run the full headless test suite:
#                             unit + integration (fast, deterministic)
#                           + E2E journeys (separate build, real loop(),
#                             ~1-2 min wall time)
#   make netdeck-test-unit  fast layer only
#   make netdeck-test-e2e   E2E layer only
#
# Firmware builds need platformio: either `pio` on PATH or the default
# ~/.platformio/penv/bin/pio install.

PIO := $(shell command -v pio 2>/dev/null || echo $(HOME)/.platformio/penv/bin/pio)

ifeq ($(wildcard $(PIO)),)
$(error pio not found — put it on PATH or install to ~/.platformio)
endif

netdeck:
	@echo "=== [1/2] NetDeck firmware (ESP32-S3, pio) ==="
	$(PIO) run -d examples/NetDeck
	@echo "=== [2/2] NetDeck emulator (SDL2) ==="
	$(MAKE) --no-print-directory -C emulator APP=NetDeck
	@echo "=== both NetDeck targets built OK ==="

netdeck-test:
	@echo "=== NetDeck tests: unit + integration + E2E ==="
	$(MAKE) --no-print-directory -C emulator APP=NetDeck test
	$(MAKE) --no-print-directory -C emulator APP=NetDeck test-e2e

netdeck-test-unit:
	$(MAKE) --no-print-directory -C emulator APP=NetDeck test

netdeck-test-e2e:
	$(MAKE) --no-print-directory -C emulator APP=NetDeck test-e2e

.PHONY: netdeck netdeck-test netdeck-test-unit netdeck-test-e2e
