# php-qml — Todo example app — Make targets.

.DEFAULT_GOAL := help

SYMFONY_DIR  := symfony
QML_SRC_DIR  := qml
BUILD_DIR    := build/qml
QT_BIN       := $(BUILD_DIR)/todo

.PHONY: help
help: ## Show available targets
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  %-12s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.PHONY: install
install: ## Install Composer dependencies for the Symfony app
	cd $(SYMFONY_DIR) && composer install

.PHONY: build
build: ## Build the Qt host
	cmake -S $(QML_SRC_DIR) -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Debug
	cmake --build $(BUILD_DIR) --parallel

.PHONY: dev
dev: build ## Run the todo app in dev mode (FrankenPHP --watch + Qt host)
	./scripts/dev.sh

.PHONY: doctor
doctor: ## Run bridge:doctor inside the Symfony app
	cd $(SYMFONY_DIR) && bin/console bridge:doctor

.PHONY: doctor-connect
doctor-connect: ## Run bridge:doctor with backend connectivity probe
	cd $(SYMFONY_DIR) && bin/console bridge:doctor --connect

.PHONY: clean
clean: ## Remove build artefacts
	rm -rf $(BUILD_DIR)

.PHONY: quality
quality: build ## Run PHPStan, php-cs-fixer (check), PHPUnit, qmllint
	cd ../php && composer quality
	cmake --build $(BUILD_DIR) --target all_qmllint
