# Befund-Schani build helpers.
#
# `make msi` reproduces the CI's Windows pipeline locally, entirely via
# public Docker images (no local wine/mingw/wixl needed) — see
# docs/releasing.md. Step 1 caches its work under build/olm-win, so
# re-runs are cheap.

DOCKER = docker run --rm --network=host -v $(CURDIR):/src -w /src

.PHONY: msi dmg test

## Build the Windows installer: olm wheel -> PyInstaller bundle -> MSI.
msi:
	$(DOCKER) debian:bookworm bash -c "\
	    apt-get update -qq && apt-get install -yqq --no-install-recommends \
	        gcc mingw-w64 cmake make curl ca-certificates unzip \
	        python3 python3-cffi python3-setuptools && \
	    bash scripts/build_olm_windows_wheel.sh"
	$(DOCKER) tobix/pywine:3.13 sh -c "bash scripts/build_windows_dist.sh"
	$(DOCKER) debian:bookworm bash -c "\
	    apt-get update -qq && apt-get install -yqq --no-install-recommends \
	        msitools wixl python3 && \
	    bash scripts/build_windows_msi.sh"

## Build the macOS .app + DMG. Must run ON a Mac — PyInstaller cannot
## cross-compile, and there is no Wine equivalent for macOS.
dmg:
	@[ "$$(uname -s)" = "Darwin" ] || { \
	    echo "make dmg must run on macOS (see docs/releasing.md)"; exit 1; }
	bash scripts/build_macos_dmg.sh

test:
	uv run pytest tests/
