.DEFAULT_GOAL := build

CARGO ?= cargo
PODMAN ?= podman
IMAGE ?= reminder-rs

.PHONY: build prepare test image

# Keep the stages ordered even when make is run with -j.
build: image
	$(PODMAN) run --rm -v "$(CURDIR):/mnt" -w /mnt \
		-e SQLX_OFFLINE=true "$(IMAGE)" cargo deb

image: test
	$(PODMAN) build -t "$(IMAGE)" .

test: prepare
	SQLX_OFFLINE=true $(CARGO) test --locked

# Include test-only queries in the metadata used by offline compilation.
prepare:
	SQLX_OFFLINE=false $(CARGO) sqlx prepare -- --all-targets --locked
