.PHONY: runner run test lint apk ipa build-web

WEB_API_URL ?= https://jinzhi.api.yqzhice.top
WEB_BASE_HREF ?= /flutter/
GITVERSION := $(shell git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD)
COMMON_DART_DEFINES := --dart-define=GITVERSION=$(GITVERSION)

runner:
	dart run build_runner build --delete-conflicting-outputs

run:
	flutter run $(COMMON_DART_DEFINES) --dart-define=JINZHI_API_BASE_URL=http://localhost:8088

test:
	flutter test

lint:
	flutter analyze

apk:
	flutter build apk $(COMMON_DART_DEFINES) --release --target-platform android-arm64

ipa:
	flutter build ipa $(COMMON_DART_DEFINES) --release

build-web:
	API_BASE_URL=$(WEB_API_URL) BASE_HREF=$(WEB_BASE_HREF) bash scripts/build_web.sh
