diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 12:47:38 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 12:47:38 -0300 |
| commit | 794f28199a4dde9d18ec711864336c96c58bb422 (patch) | |
| tree | 3985f1c033a9c62a264829cd354da9ce214e5db7 /Makefile | |
| download | d-0.1.0.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..091d007 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +# Development tasks. Everything runs through `dub`, so there is nothing to +# install first. +# +# make list the targets +# make test run the suite +# make lint dscanner + a dfmt check, no files touched +# make build release build of the library +# +# `lint` and `format` shell out to dscanner and dfmt, which dub fetches and +# builds on first use. + +DUB ?= dub +DFMT_FLAGS := --max_line_length=100 +SOURCES := $(wildcard source/cepis/*.d) $(wildcard test/*.d) + +.DEFAULT_GOAL := help +.PHONY: help test lint format build check clean + +help: + @echo 'Targets:' + @echo ' test run the test suite (unit and integration)' + @echo ' lint dub lint + a dfmt formatting check (read-only)' + @echo ' format apply dfmt (writes)' + @echo ' build release build of the library' + @echo ' check lint + test + build, in that order' + @echo ' clean remove build artefacts' + +test: + $(DUB) test + +# Read-only by design, so it is safe in CI and in a pre-commit hook: it reports +# what `make format` would change without changing anything. +lint: + $(DUB) lint + @status=0; for file in $(SOURCES); do \ + $(DUB) run --quiet --yes dfmt -- $(DFMT_FLAGS) "$$file" \ + | diff -u "$$file" - || status=1; \ + done; exit $$status + +format: + $(DUB) run --quiet --yes dfmt -- $(DFMT_FLAGS) --inplace $(SOURCES) + +build: + $(DUB) build --build=release + +# The order matters: lint is the fastest to fail, build the slowest, so a broken +# run reports the cheapest problem first. +check: lint test build + +clean: + $(DUB) clean + rm -f libcepis.a cepis cepis-test-library |