Makefile RawHistoryFolder
1.PHONY: build test vet race mocks mocks-check spv-check fakes-check log-check arch check perf-check color-check bin tty logs pkg install
2
3# 0 runs until quit; set e.g. TTY_TIMEOUT=60s for a safety net.
4TTY_TIMEOUT ?= 0
5comma := ,
6# Go runtime profiles for tty runs; set PPROF= to disable.
7PPROF ?= localhost:6060
8RUNS := $(or $(XDG_STATE_HOME),$(HOME)/.local/state)/neferwl/runs/drm
9
10# Build a fresh binary with the git revision embedded.
11bin:
12 CGO_ENABLED=0 go build -o bin/neferwl ./cmd/neferwl
13
14# Run on the current TTY. Quit: Ctrl+Alt+Backspace (or the quit bind).
15# TTY_DEBUG adds narrow categories, e.g. TTY_DEBUG=drm-flip.
16tty: bin
17 ./bin/neferwl --backend=drm --debug=all$(if $(TTY_DEBUG),$(comma)$(TTY_DEBUG)) --timeout=$(TTY_TIMEOUT) $(if $(PPROF),--pprof=$(PPROF)); \
18 echo "exit $$? - log: $(RUNS)/latest.log"
19
20# Summarise the last run: lifecycle, warnings and errors.
21logs:
22 @jq -r 'select(.level != "debug") | "\(.time) \(.level) [\(.component)] \(.message) \(del(.time,.level,.component,.message) | tostring)"' $(RUNS)/latest.log
23build:
24 CGO_ENABLED=0 go build ./...
25test:
26 CGO_ENABLED=0 go test ./...
27vet:
28 CGO_ENABLED=0 go vet ./...
29race:
30 # cgo is enabled only for the race test binary.
31 CGO_ENABLED=1 go test -race ./...
32MOCKS := internal/mocks ':(glob)internal/**/*_mock_test.go'
33# Regenerate from scratch so mocks of removed interfaces disappear too.
34mocks:
35 rm -rf internal/mocks
36 find internal -name '*_mock_test.go' -delete
37 $(HOME)/go/bin/mockery
38# Generated mocks must be committed and up to date.
39mocks-check: mocks
40 git diff --exit-code -- $(MOCKS)
41 @test -z "$$(git ls-files --others --exclude-standard -- $(MOCKS))"
42# Committed SPIR-V must match the GLSL shaders (needs glslc).
43spv-check:
44 go generate ./internal/adapters/vulkan
45 git diff --exit-code -- 'internal/adapters/vulkan/shaders/*.spv'
46# Test doubles come from Mockery only: no handwritten fake/stub/spy types.
47# Matches `type fakeX`, `\ttype RendererStub[T any]` and `spyX struct` in `type (` blocks.
48# grep exit 1 (no match) passes; 0 (match) and 2 (error) fail.
49FAKES := ^\s*type\s+\w*(fake|stub|spy|dummy|mock)\w*|^\s*\w*(fake|stub|spy|dummy|mock)\w*(\[[^]]*\])?\s+(struct|interface)\b
50fakes-check:
51 @rc=0; grep -rniE '$(FAKES)' --include='*_test.go' --exclude='*_mock_test.go' internal cmd || rc=$$?; \
52 [ $$rc -eq 1 ] || { [ $$rc -eq 0 ] && echo 'handwritten test double: add an interface and a Mockery entry (see AGENTS.md)' >&2; exit 1; }
53# The component field comes from logging.For: a second one on a scoped logger
54# duplicates the JSON key. grep exit 1 (no match) passes; 0 and 2 fail.
55LOGCOMPONENT := "component"|FieldComponent
56log-check:
57 @rc=0; grep -rnE '$(LOGCOMPONENT)' --include='*.go' --exclude='*_test.go' --exclude-dir=logging internal cmd || rc=$$?; \
58 [ $$rc -eq 1 ] || { [ $$rc -eq 0 ] && echo 'component log field: derive a logger with logging.For instead (see AGENTS.md)' >&2; exit 1; }
59arch:
60 $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./...
61# Fast, mandatory guards for tiled content publications and SHM copies.
62perf-check:
63 CGO_ENABLED=0 go test ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1
64check: vet test arch fakes-check log-check perf-check
65
66# On-demand SDR/HDR colour check with examples/testpattern on a headless
67# NeferWL. Needs a GPU and /dev/udmabuf; not part of check.
68color-check:
69 CGO_ENABLED=0 go test -tags colorcheck ./internal/app -run '^TestColorCheck' -count=1 -v
70
71# Arch package of the committed HEAD (packaging/arch/PKGBUILD). Go modules
72# come from the module proxy in prepare(); the build itself runs offline.
73# pacman-ordered version: 0.0.0.r<commits>.g<hash>; a tag replaces 0.0.0.
74pkg: SHELL := bash
75pkg: .SHELLFLAGS := -eo pipefail -c
76pkg:
77 @test -z "$$(git status --porcelain)" || echo "warning: uncommitted changes are not packaged" >&2
78 v=$$(t=$$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//; s/-/_/g'); \
79 echo "$${t:-0.0.0}.r$$(git rev-list --count HEAD).g$$(git rev-parse --short HEAD)"); \
80 d=$$(mktemp -d /tmp/neferwl-pkg.XXXXXX); trap 'rm -rf "$$d"' EXIT; \
81 git archive --prefix=neferwl-$$v/ -o "$$d/neferwl-$$v.tar.gz" HEAD; \
82 cp packaging/arch/PKGBUILD packaging/neferwl.install "$$d/"; \
83 cd "$$d" && sed -i "s/^pkgver=.*/pkgver=$$v/; s/^sha256sums=.*/sha256sums=('$$(sha256sum *.tar.gz | cut -d' ' -f1)')/" PKGBUILD; \
84 makepkg -f --noconfirm; mkdir -p $(CURDIR)/dist; rm -f $(CURDIR)/dist/neferwl-*.pkg.tar.zst; mv *.pkg.tar.zst $(CURDIR)/dist/
85 @ls dist/*.pkg.tar.zst
86
87# Build the package, then install it with pacman (asks for sudo).
88install: pkg
89 sudo pacman -U dist/neferwl-*.pkg.tar.zst