summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 23f9fa3e08690b8f1c53b7e4e84e9301d71da192 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Development tasks. Everything runs through `zig`, so there is nothing to
# install first.
#
#   make            list the targets
#   make test       run the suite
#   make lint       formatting check + full type check, no files touched
#   make build      release build of the library and the CLI

ZIG ?= zig

# Passed to `zig build` for the targets that produce binaries.
OPTIMIZE ?= ReleaseSafe

.DEFAULT_GOAL := help
.PHONY: help test lint format build check clean docs run

help:
	@echo 'Targets:'
	@echo '  test       run the unit and integration tests'
	@echo '  lint       zig fmt --check + zig build check (read-only)'
	@echo '  format     apply zig fmt (writes)'
	@echo '  build      build the library and the cepis CLI (OPTIMIZE=$(OPTIMIZE))'
	@echo '  check      lint + test + build, in that order'
	@echo '  docs       generate the API documentation into zig-out/docs'
	@echo '  run        build and run the CLI: make run ARGS="01001000"'
	@echo '  clean      remove build artefacts and the local cache'

test:
	$(ZIG) build test --summary all

# 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, and type-checks
# every module including the tests.
lint:
	$(ZIG) fmt --check build.zig src test
	$(ZIG) build check

format:
	$(ZIG) fmt build.zig src test

build:
	$(ZIG) build -Doptimize=$(OPTIMIZE)

docs:
	$(ZIG) build-lib src/root.zig -femit-docs=zig-out/docs -fno-emit-bin

run:
	$(ZIG) build run -- $(ARGS)

# 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:
	rm -rf zig-out .zig-cache