SWIFT ?= swift CONFIGURATION ?= debug .DEFAULT_GOAL := help .PHONY: help test lint format build check clean help: @echo 'Targets:' @echo ' test run the test suite' @echo ' lint swift-format lint, read-only' @echo ' format apply swift-format in place (writes)' @echo ' build compile the library (CONFIGURATION=$(CONFIGURATION))' @echo ' check lint + test + build, in that order' @echo ' clean remove build artefacts' @echo @echo 'Override the toolchain with e.g. make test SWIFT=/path/to/swift' @echo 'Build a release with make build CONFIGURATION=release' test: $(SWIFT) test lint: @if $(SWIFT) format --version >/dev/null 2>&1; then \ $(SWIFT) format lint --strict --recursive Package.swift Sources Tests; \ else \ echo 'swift-format is not in this toolchain (needs Swift 6 or swift-format on PATH); skipping'; \ fi format: @if $(SWIFT) format --version >/dev/null 2>&1; then \ $(SWIFT) format --in-place --recursive Package.swift Sources Tests; \ else \ echo 'swift-format is not in this toolchain (needs Swift 6 or swift-format on PATH); skipping'; \ fi build: $(SWIFT) build -c $(CONFIGURATION) check: lint test build clean: $(SWIFT) package clean rm -rf .build