Makefile RawHistoryFolder

1# Makefile for dumber (Clean Architecture - puregotk)
2
3.PHONY: build build-systemviews generate-systemviews build-quick install-local test lint staticcheck clean install-tools install-golangci-lint install-staticcheck dev generate help init man flatpak-deps flatpak-build flatpak-install flatpak-run flatpak-clean stress-omnibox-callbacks verify-purego verify-generated verify-systemviews-assets check
4
5# Load local overrides from .env.local if present (Makefile syntax)
6ifneq (,$(wildcard .env.local))
7include .env.local
8export
9endif
10
11# Variables
12BINARY_NAME=dumber
13MAIN_PATH=./cmd/dumber
14DIST_DIR=dist
15LOCAL_BIN_DIR?=$(HOME)/.local/bin
16TOOL_BIN_DIR?=$(shell go env GOPATH)/bin
17GOLANGCI_LINT_VERSION?=v2.14.0
18STATICCHECK_VERSION?=2026.2.2
19
20# Detect number of CPU cores for parallel compilation
21NPROCS?=$(shell nproc 2>/dev/null || echo 1)
22
23# Version information from git
24VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.0.0-dev")
25COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
26BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
27
28# Go flags. NATIVE_GOFLAGS can add native-only hardening such as
29# -buildmode=pie without breaking js/wasm systemviews builds.
30GOFLAGS?=-mod=mod
31NATIVE_GOFLAGS?=$(GOFLAGS)
32WASM_GOFLAGS?=$(GOFLAGS)
33
34# Linker flags
35LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
36
37# Systemview artifacts are built with the toolchain that satisfies go.mod's
38# go directive: setup-go's toolchain in CI, the local Go elsewhere. GOENV=off
39# keeps the developer's go env file out of the build (e.g. a local GOEXPERIMENT
40# changes runtime codegen), so one toolchain always yields the same WASM bytes.
41
42# Disable optimizations and inlining for ALL packages. purego callbacks
43# create mixed Go/C stack frames; the Go runtime (stack growth, GC,
44# scheduler) cannot reliably traverse optimised frames across these
45# boundaries. -N prevents register-only variables and stack slot reuse
46# that corrupt the runtime's stack walker. -l prevents inlining across
47# package boundaries. Both are required — -l alone is insufficient.
48GCFLAGS=-gcflags 'all=-N -l'
49
50# VCS stamping for measured binaries. build-quick stays unstamped for fast
51# iteration; build-manifest forces stamping so the manifest binds the exact
52# built tree instead of the ambient checkout HEAD.
53BUILDVCS?=false
54
55# Default target
56help: ## Show this help message
57	@echo "Available targets:"
58	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
59
60# Build targets
61build: build-systemviews verify-systemviews-assets ## Build the application (pure Go, no CGO)
62	@echo "Building $(BINARY_NAME) $(VERSION) using $(NPROCS) cores..."
63	@mkdir -p $(DIST_DIR)
64	GOFLAGS="$(NATIVE_GOFLAGS)" CGO_ENABLED=0 go build -buildvcs=false -p $(NPROCS) $(GCFLAGS) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_PATH)
65	@rm -f $(DIST_DIR)/cef-helper
66	@echo "Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)"
67
68generate-systemviews: ## Generate Go code from systemviews templ components
69	@echo "Generating systemviews templ components..."
70	GOENV=off go tool templ generate -path internal/ui/systemviews -include-version=false
71	@echo "Systemviews templ generation complete"
72
73build-systemviews: generate-systemviews ## Build the WASM systemviews runtime
74	@echo "Building systemviews wasm assets..."
75	@command -v brotli >/dev/null 2>&1 || { echo "Error: brotli is required to build compressed systemviews assets. Install brotli and retry."; exit 1; }
76	@mkdir -p assets/systemviews
77	@cp -f "$$(go env GOROOT)/lib/wasm/wasm_exec.js" assets/systemviews/wasm_exec.js
78	GOFLAGS="$(WASM_GOFLAGS)" GOENV=off GOOS=js GOARCH=wasm go build -trimpath -buildvcs=false -ldflags="-s -w" -o assets/systemviews/systemviews.wasm ./cmd/systemviews
79	brotli -f -o assets/systemviews/systemviews.wasm.br assets/systemviews/systemviews.wasm
80	go run ./cmd/systemviews-assets -dir assets/systemviews
81	@echo "Systemviews build complete"
82
83build-quick: ## Build quickly for backend development
84	@echo "Building $(BINARY_NAME) $(VERSION) (quick)..."
85	@mkdir -p $(DIST_DIR)
86	go run ./cmd/systemviews-assets -check-if-present -dir assets/systemviews
87	GOFLAGS="$(NATIVE_GOFLAGS)" CGO_ENABLED=0 go build -buildvcs=$(BUILDVCS) -p $(NPROCS) $(GCFLAGS) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_PATH)
88	@rm -f $(DIST_DIR)/cef-helper
89	@echo "Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)"
90
91build-manifest: ## Generate the collector build manifest for dist/dumber (VCS-stamped build)
92	@$(MAKE) build-quick BUILDVCS=true
93	@echo "Generating build manifest..."
94	python3 scripts/generate_build_manifest.py --binary $(DIST_DIR)/$(BINARY_NAME)
95	@echo "Manifest: $(DIST_DIR)/$(BINARY_NAME).manifest.json"
96
97install-local: build-quick ## Install dumber to ~/.local/bin atomically
98	@echo "Installing $(BINARY_NAME) to $(LOCAL_BIN_DIR)..."
99	@mkdir -p $(LOCAL_BIN_DIR)
100	@tmp_dumber="$$(mktemp '$(LOCAL_BIN_DIR)/.dumber.tmp.XXXXXX')"; \
101	trap 'rm -f "$$tmp_dumber"' EXIT INT TERM; \
102	install -m 0755 $(DIST_DIR)/$(BINARY_NAME) "$$tmp_dumber"; \
103	mv -f "$$tmp_dumber" $(LOCAL_BIN_DIR)/$(BINARY_NAME); \
104	removed_stale=0; \
105	if [ -e $(LOCAL_BIN_DIR)/cef-helper ]; then rm -f $(LOCAL_BIN_DIR)/cef-helper && removed_stale=1; fi; \
106	trap - EXIT INT TERM; \
107	echo "Installed: $(LOCAL_BIN_DIR)/$(BINARY_NAME)"; \
108	if [ "$$removed_stale" -eq 1 ]; then echo "Removed stale: $(LOCAL_BIN_DIR)/cef-helper"; fi
109
110# Development targets
111dev: ## Run in development mode
112	@echo "Running in development mode..."
113	go run $(MAIN_PATH)
114
115run: build-quick ## Build and run
116	@echo "Running $(BINARY_NAME)..."
117	$(DIST_DIR)/$(BINARY_NAME)
118
119generate: ## Generate code (SQLC)
120	@echo "Generating code with SQLC..."
121	sqlc generate
122	@echo "Code generation complete"
123
124mocks: ## Generate mock implementations with mockery
125	@echo "Generating mocks with mockery..."
126	mockery
127	@echo "Mock generation complete"
128
129# Testing
130test: ## Run tests
131	@echo "Running tests..."
132	GOFLAGS=-mod=mod go test -v ./...
133
134test-race: ## Run tests with race detection
135	@echo "Running tests with race detection..."
136	GOFLAGS=-mod=mod go test -race -v ./...
137
138test-cover: ## Run tests with coverage
139	@echo "Running tests with coverage..."
140	GOFLAGS=-mod=mod go test -coverprofile=coverage.out ./...
141	go tool cover -html=coverage.out -o coverage.html
142	@echo "Coverage report: coverage.html"
143
144stress-omnibox-callbacks: ## Run placeholder omnibox callback stress harness
145	GOFLAGS=-mod=mod CGO_ENABLED=0 go run ./scripts/stress_omnibox_callbacks.go
146
147verify-purego: ## Ensure callback path stays cgo/export free
148	bash ./scripts/verify_purego_only.sh
149
150verify-generated: ## Verify tracked generated systemviews artifacts are committed
151	@echo "Verifying tracked generated systemviews artifacts..."
152	@git diff --exit-code -- assets/systemviews internal/ui/systemviews || { \
153		echo "Tracked generated systemviews artifacts are out of date. Run 'make build-systemviews' and commit the result. (The asset manifest itself is an untracked build artifact and is not compared.)"; \
154		exit 1; \
155	}
156
157verify-systemviews-assets: build-systemviews ## Verify release embeds a compressed systemviews WASM asset
158	@echo "Verifying embedded systemviews WASM asset..."
159	DUMBER_REQUIRE_SYSTEMVIEWS_WASM=1 GOFLAGS="$(GOFLAGS)" go test -count=1 -run 'TestWebUIAssetsIncludesCompressedSystemviewsWASM|TestAssetManifestMatchesEmbeddedArtifacts' ./assets
160	go run ./cmd/systemviews-assets -check -dir assets/systemviews
161
162# Linting
163lint: ## Run golangci-lint
164	@echo "Running golangci-lint..."
165	golangci-lint run
166
167lint-fix: ## Run golangci-lint with --fix
168	@echo "Running golangci-lint with --fix..."
169	golangci-lint run --fix
170
171staticcheck: ## Run Staticcheck
172	@echo "Running staticcheck..."
173	staticcheck ./...
174
175# Format code
176fmt: ## Format Go code with gofmt
177	@echo "Formatting Go code..."
178	go fmt ./...
179
180# Tools installation
181install-golangci-lint: ## Install pinned golangci-lint
182	@echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION) to $(TOOL_BIN_DIR)..."
183	@mkdir -p $(TOOL_BIN_DIR)
184	# Build the pinned version with the active Go toolchain instead of using the
185	# upstream install.sh helper, which currently misidentifies release assets now
186	# that golangci-lint publishes sibling .sbom.json files for each tarball.
187	# Run outside this module so Go resolves the requested tool version independently.
188	cd "$${TMPDIR:-/tmp}" && GOBIN=$(TOOL_BIN_DIR) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
189
190install-staticcheck: ## Install pinned Staticcheck with the active Go toolchain
191	@echo "Installing staticcheck $(STATICCHECK_VERSION)..."
192	go install honnef.co/go/tools/cmd/staticcheck@$(STATICCHECK_VERSION)
193
194install-tools: install-golangci-lint install-staticcheck ## Install development tools
195	@echo "Installing development tools..."
196	go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
197	@echo "Tools installed successfully"
198
199# Cleanup
200clean: ## Clean build artifacts
201	@echo "Cleaning build artifacts..."
202	rm -rf $(DIST_DIR)
203	rm -f $(BINARY_NAME)
204	rm -f assets/systemviews/wasm_exec.js assets/systemviews/systemviews.wasm assets/systemviews/systemviews.wasm.br assets/systemviews/asset-manifest.json
205	rm -f coverage.out coverage.html
206	go clean -cache
207	go clean -testcache
208
209# Project initialization
210init: install-tools ## Initialize project dependencies and tools
211	@echo "Initializing project..."
212	go mod tidy
213	@echo "Project initialized! Run 'make help' for available commands."
214
215# Check setup
216check: ## Run local all-clear checks (tools, build, generated assets, tests, constraints)
217	@echo "Checking project setup..."
218	@echo "Go version:"
219	@go version
220	@echo "\nSQLC version:"
221	@sqlc version
222	@echo "\nGolangci-lint version:"
223	@golangci-lint version
224	@echo "\nBuilding project..."
225	@$(MAKE) build-quick
226	@echo "\nVerifying generated systemviews artifacts..."
227	@$(MAKE) verify-generated
228	@echo "\nRunning tests..."
229	@$(MAKE) test
230	@echo "\nVerifying purego-only constraints..."
231	@$(MAKE) verify-purego
232	@echo "\nAll checks passed!"
233
234# Documentation
235man: build-quick ## Install man pages to ~/.local/share/man/man1/
236	@echo "Installing man pages..."
237	$(DIST_DIR)/$(BINARY_NAME) gen-docs
238
239# Native release targets
240.PHONY: release-snapshot release
241
242release-snapshot: build-systemviews ## Build snapshot using goreleaser
243	@echo "Building snapshot with goreleaser..."
244	goreleaser release --snapshot --clean
245
246release: ## Create full release using goreleaser
247	@echo "Building release with goreleaser..."
248	GITHUB_TOKEN=$$(gh auth token) goreleaser release --clean
249
250# Flatpak targets
251flatpak-deps: ## Install Flatpak build dependencies (Arch)
252	@echo "Installing Flatpak build dependencies..."
253	sudo pacman -S --needed flatpak flatpak-builder
254	flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
255	flatpak install --user -y flathub org.gnome.Platform//48 org.gnome.Sdk//48
256	flatpak install --user -y flathub org.freedesktop.Sdk.Extension.golang//24.08
257	flatpak install --user -y flathub org.freedesktop.Sdk.Extension.node20//24.08
258	@echo "Flatpak dependencies installed!"
259
260flatpak-build: ## Build Flatpak bundle locally
261	@echo "Building Flatpak bundle..."
262	flatpak-builder --force-clean --user --repo=flatpak-repo flatpak-build flatpak/dev.bnema.Dumber.yml
263	flatpak build-bundle flatpak-repo dumber.flatpak dev.bnema.Dumber
264	@echo "Flatpak bundle created: dumber.flatpak"
265
266flatpak-install: ## Install Flatpak locally for testing
267	@echo "Installing Flatpak locally..."
268	flatpak-builder --force-clean --user --install flatpak-build flatpak/dev.bnema.Dumber.yml
269	@echo "Flatpak installed! Run with: make flatpak-run"
270
271flatpak-run: ## Run the installed Flatpak
272	flatpak run dev.bnema.Dumber
273
274flatpak-clean: ## Clean Flatpak build artifacts
275	@echo "Cleaning Flatpak build artifacts..."
276	rm -rf flatpak-build flatpak-repo .flatpak-builder dumber.flatpak
277	@echo "Flatpak artifacts cleaned!"

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close