Makefile RawHistoryFolder
1.PHONY: build test vet race mocks mocks-check spv-check fakes-check arch check bin tty logs pkg
2
3# 0 runs until quit; set e.g. TTY_TIMEOUT=60s for a safety net.
4TTY_TIMEOUT ?= 0
5RUNS := $(or $(XDG_STATE_HOME),$(HOME)/.local/state)/neferwl/runs
6
7# Build a fresh binary with the git revision embedded.
8bin:
9 CGO_ENABLED=0 go build -o bin/neferwl ./cmd/neferwl
10
11# Run on the current TTY. Quit: Ctrl+Alt+Backspace (or the quit bind).
12tty: bin
13 ./bin/neferwl --backend=drm --debug=all --timeout=$(TTY_TIMEOUT); \
14 echo "exit $$? - log: $(RUNS)/latest.log"
15
16# Summarise the last run: lifecycle, warnings and errors.
17logs:
18 @jq -r 'select(.level != "debug") | "\(.time) \(.level) [\(.component)] \(.message) \(del(.time,.level,.component,.message) | tostring)"' $(RUNS)/latest.log
19build:
20 CGO_ENABLED=0 go build ./...
21test:
22 CGO_ENABLED=0 go test ./...
23vet:
24 CGO_ENABLED=0 go vet ./...
25race:
26 # cgo is enabled only for the race test binary.
27 CGO_ENABLED=1 go test -race ./...
28MOCKS := internal/mocks ':(glob)internal/**/*_mock_test.go'
29# Regenerate from scratch so mocks of removed interfaces disappear too.
30mocks:
31 rm -rf internal/mocks
32 find internal -name '*_mock_test.go' -delete
33 $(HOME)/go/bin/mockery
34# Generated mocks must be committed and up to date.
35mocks-check: mocks
36 git diff --exit-code -- $(MOCKS)
37 @test -z "$$(git ls-files --others --exclude-standard -- $(MOCKS))"
38# Committed SPIR-V must match the GLSL shaders (needs glslc).
39spv-check:
40 go generate ./internal/adapters/vulkan
41 git diff --exit-code -- 'internal/adapters/vulkan/shaders/*.spv'
42# Test doubles come from Mockery only: no handwritten fake/stub/spy types.
43# Matches `type fakeX`, `\ttype RendererStub[T any]` and `spyX struct` in `type (` blocks.
44# grep exit 1 (no match) passes; 0 (match) and 2 (error) fail.
45FAKES := ^\s*type\s+\w*(fake|stub|spy|dummy|mock)\w*|^\s*\w*(fake|stub|spy|dummy|mock)\w*(\[[^]]*\])?\s+(struct|interface)\b
46fakes-check:
47 @rc=0; grep -rniE '$(FAKES)' --include='*_test.go' --exclude='*_mock_test.go' internal cmd || rc=$$?; \
48 [ $$rc -eq 1 ] || { [ $$rc -eq 0 ] && echo 'handwritten test double: add an interface and a Mockery entry (see AGENTS.md)' >&2; exit 1; }
49arch:
50 $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./...
51check: vet test arch fakes-check
52
53# Arch package of the committed HEAD (packaging/arch/PKGBUILD). Go modules
54# come from the module proxy in prepare(); the build itself runs offline.
55# pacman-ordered version: 0.0.0.r<commits>.g<hash>; a tag replaces 0.0.0.
56pkg: SHELL := bash
57pkg: .SHELLFLAGS := -eo pipefail -c
58pkg:
59 @test -z "$$(git status --porcelain)" || echo "warning: uncommitted changes are not packaged" >&2
60 v=$$(t=$$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//; s/-/_/g'); \
61 echo "$${t:-0.0.0}.r$$(git rev-list --count HEAD).g$$(git rev-parse --short HEAD)"); \
62 d=$$(mktemp -d /tmp/neferwl-pkg.XXXXXX); trap 'rm -rf "$$d"' EXIT; \
63 git archive --prefix=neferwl-$$v/ -o "$$d/neferwl-$$v.tar.gz" HEAD; \
64 cp packaging/arch/PKGBUILD "$$d/"; \
65 cd "$$d" && sed -i "s/^pkgver=.*/pkgver=$$v/; s/^sha256sums=.*/sha256sums=('$$(sha256sum *.tar.gz | cut -d' ' -f1)')/" PKGBUILD; \
66 makepkg -f --noconfirm; mkdir -p $(CURDIR)/dist; rm -f $(CURDIR)/dist/neferwl-*.pkg.tar.zst; mv *.pkg.tar.zst $(CURDIR)/dist/
67 @ls dist/*.pkg.tar.zst