# {{SLUG}} mobile app (stapel-kmp). Run from mobile/.
.PHONY: check walk contracts generate desktop android ios stapel-local

# Every proof gate this machine can run (scripts/mobile-check.sh prints PASS / FAIL / NOT RUN).
check:
	scripts/mobile-check.sh

# The sign-in walk against a running backend: make walk WALK_BASE_URL=http://127.0.0.1:{{DEV_PORT}}/
walk:
	WALK_BASE_URL="$(WALK_BASE_URL)" scripts/mobile-check.sh

# The project's own backend modules -> contracts/<module>/ -> generated clients (commit both).
# Run after the backend gains endpoints.
contracts:
{{CONTRACT_RECIPES}}	./gradlew --console=plain :shared:stapelGenerate

generate:
	./gradlew --console=plain :shared:stapelGenerate

desktop:
	./gradlew --console=plain :desktopApp:run

android:
	./gradlew --console=plain :androidApp:assembleDebug

ios:
	scripts/ios-smoke.sh

# stapel-kmp is not on Maven Central yet. With `stapel.repo=local` (gradle.properties)
# the build resolves it from mavenLocal; this publishes the pinned train there from a
# fresh clone, so a clean checkout builds without anyone's ~/.m2. Needs JAVA_HOME (21)
# and ANDROID_HOME. MAVEN_REPO_LOCAL=<dir> publishes into another directory (pass the
# same -Dmaven.repo.local=<dir> to the build).
STAPEL_KMP_REPO ?= {{KMP_REPO}}
STAPEL_KMP_REF ?= {{KMP_COMMIT}}
stapel-local:
	rm -rf build/stapel-kmp
	git clone --quiet --filter=blob:none $(STAPEL_KMP_REPO) build/stapel-kmp
	git -C build/stapel-kmp checkout --quiet $(STAPEL_KMP_REF)
	cd build/stapel-kmp && ./gradlew --console=plain $(if $(MAVEN_REPO_LOCAL),-Dmaven.repo.local=$(MAVEN_REPO_LOCAL)) publishToMavenLocal
