v0.31.0 bf0756b

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.12.2
18STATICCHECK_VERSION?=v0.7.0
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# Disable optimizations and inlining for ALL packages. purego callbacks
38# create mixed Go/C stack frames; the Go runtime (stack growth, GC,
39# scheduler) cannot reliably traverse optimised frames across these
40# boundaries. -N prevents register-only variables and stack slot reuse
41# that corrupt the runtime's stack walker. -l prevents inlining across
42# package boundaries. Both are required — -l alone is insufficient.
43GCFLAGS=-gcflags 'all=-N -l'
44
45# Default target
46help: ## Show this help message
47	@echo "Available targets:"
48	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
49
50# Build targets
51build: build-systemviews ## Build the application (pure Go, no CGO)
52	@echo "Building $(BINARY_NAME) $(VERSION) using $(NPROCS) cores..."
53	@mkdir -p $(DIST_DIR)
54	GOFLAGS="$(NATIVE_GOFLAGS)" CGO_ENABLED=0 go build -buildvcs=false -p $(NPROCS) $(GCFLAGS) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_PATH)
55	@rm -f $(DIST_DIR)/cef-helper
56	@echo "Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)"
57
58generate-systemviews: ## Generate Go code from systemviews templ components
59	@echo "Generating systemviews templ components..."
60	go tool templ generate -path internal/ui/systemviews -include-version=false
61	@echo "Systemviews templ generation complete"
62
63build-systemviews: generate-systemviews ## Build the WASM systemviews runtime
64	@echo "Building systemviews wasm assets..."
65	@command -v brotli >/dev/null 2>&1 || { echo "Error: brotli is required to build compressed systemviews assets. Install brotli and retry."; exit 1; }
66	@mkdir -p assets/systemviews
67	@cp "$$(go env GOROOT)/lib/wasm/wasm_exec.js" assets/systemviews/wasm_exec.js
68	GOFLAGS="$(WASM_GOFLAGS)" GOOS=js GOARCH=wasm go build -buildvcs=false -ldflags="-s -w" -o assets/systemviews/systemviews.wasm ./cmd/systemviews
69	brotli -f -o assets/systemviews/systemviews.wasm.br assets/systemviews/systemviews.wasm
70	@echo "Systemviews build complete"
71
72build-quick: ## Build quickly for backend development
73	@echo "Building $(BINARY_NAME) $(VERSION) (quick)..."
74	@mkdir -p $(DIST_DIR)
75	GOFLAGS="$(NATIVE_GOFLAGS)" CGO_ENABLED=0 go build -buildvcs=false -p $(NPROCS) $(GCFLAGS) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_PATH)
76	@rm -f $(DIST_DIR)/cef-helper
77	@echo "Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)"
78
79install-local: build-quick ## Install dumber to ~/.local/bin atomically
80	@echo "Installing $(BINARY_NAME) to $(LOCAL_BIN_DIR)..."
81	@mkdir -p $(LOCAL_BIN_DIR)
82	@tmp_dumber="$$(mktemp '$(LOCAL_BIN_DIR)/.dumber.tmp.XXXXXX')"; \
83	trap 'rm -f "$$tmp_dumber"' EXIT INT TERM; \
84	install -m 0755 $(DIST_DIR)/$(BINARY_NAME) "$$tmp_dumber"; \
85	mv -f "$$tmp_dumber" $(LOCAL_BIN_DIR)/$(BINARY_NAME); \
86	removed_stale=0; \
87	if [ -e $(LOCAL_BIN_DIR)/cef-helper ]; then rm -f $(LOCAL_BIN_DIR)/cef-helper && removed_stale=1; fi; \
88	trap - EXIT INT TERM; \
89	echo "Installed: $(LOCAL_BIN_DIR)/$(BINARY_NAME)"; \
90	if [ "$$removed_stale" -eq 1 ]; then echo "Removed stale: $(LOCAL_BIN_DIR)/cef-helper"; fi
91
92# Development targets
93dev: ## Run in development mode
94	@echo "Running in development mode..."
95	go run $(MAIN_PATH)
96
97run: build-quick ## Build and run
98	@echo "Running $(BINARY_NAME)..."
99	$(DIST_DIR)/$(BINARY_NAME)
100
101generate: ## Generate code (SQLC)
102	@echo "Generating code with SQLC..."
103	sqlc generate
104	@echo "Code generation complete"
105
106mocks: ## Generate mock implementations with mockery
107	@echo "Generating mocks with mockery..."
108	mockery
109	@echo "Mock generation complete"
110
111# Testing
112test: ## Run tests
113	@echo "Running tests..."
114	GOFLAGS=-mod=mod go test -v ./...
115
116test-race: ## Run tests with race detection
117	@echo "Running tests with race detection..."
118	GOFLAGS=-mod=mod go test -race -v ./...
119
120test-cover: ## Run tests with coverage
121	@echo "Running tests with coverage..."
122	GOFLAGS=-mod=mod go test -coverprofile=coverage.out ./...
123	go tool cover -html=coverage.out -o coverage.html
124	@echo "Coverage report: coverage.html"
125
126stress-omnibox-callbacks: ## Run placeholder omnibox callback stress harness
127	GOFLAGS=-mod=mod CGO_ENABLED=0 go run ./scripts/stress_omnibox_callbacks.go
128
129verify-purego: ## Ensure callback path stays cgo/export free
130	bash ./scripts/verify_purego_only.sh
131
132verify-generated: ## Verify generated systemviews artifacts are committed
133	@echo "Verifying generated systemviews artifacts..."
134	@git diff --exit-code -- assets/systemviews internal/ui/systemviews || { \
135		echo "Generated systemviews artifacts are out of date. Run 'make build-systemviews' and commit the result."; \
136		exit 1; \
137	}
138
139verify-systemviews-assets: ## Verify release embeds a compressed systemviews WASM asset
140	@echo "Verifying embedded systemviews WASM asset..."
141	DUMBER_REQUIRE_SYSTEMVIEWS_WASM=1 GOFLAGS=$(GOFLAGS) go test -count=1 -run TestWebUIAssetsIncludesCompressedSystemviewsWASM ./assets
142
143# Linting
144lint: ## Run golangci-lint
145	@echo "Running golangci-lint..."
146	golangci-lint run
147
148lint-fix: ## Run golangci-lint with --fix
149	@echo "Running golangci-lint with --fix..."
150	golangci-lint run --fix
151
152staticcheck: ## Run Staticcheck
153	@echo "Running staticcheck..."
154	staticcheck ./...
155
156# Format code
157fmt: ## Format Go code with gofmt
158	@echo "Formatting Go code..."
159	go fmt ./...
160
161# Tools installation
162install-golangci-lint: ## Install pinned golangci-lint
163	@echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION) to $(TOOL_BIN_DIR)..."
164	@mkdir -p $(TOOL_BIN_DIR)
165	# Build the pinned version with the active Go toolchain instead of using the
166	# upstream install.sh helper, which currently misidentifies release assets now
167	# that golangci-lint publishes sibling .sbom.json files for each tarball.
168	GOBIN=$(TOOL_BIN_DIR) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
169
170install-staticcheck: ## Install pinned Staticcheck with the active Go toolchain
171	@echo "Installing staticcheck $(STATICCHECK_VERSION)..."
172	go install honnef.co/go/tools/cmd/staticcheck@$(STATICCHECK_VERSION)
173
174install-tools: install-golangci-lint install-staticcheck ## Install development tools
175	@echo "Installing development tools..."
176	go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
177	@echo "Tools installed successfully"
178
179# Cleanup
180clean: ## Clean build artifacts
181	@echo "Cleaning build artifacts..."
182	rm -rf $(DIST_DIR)
183	rm -f $(BINARY_NAME)
184	rm -f assets/systemviews/wasm_exec.js assets/systemviews/systemviews.wasm assets/systemviews/systemviews.wasm.br
185	rm -f coverage.out coverage.html
186	go clean -cache
187	go clean -testcache
188
189# Project initialization
190init: install-tools ## Initialize project dependencies and tools
191	@echo "Initializing project..."
192	go mod tidy
193	@echo "Project initialized! Run 'make help' for available commands."
194
195# Check setup
196check: ## Run local all-clear checks (tools, build, generated assets, tests, constraints)
197	@echo "Checking project setup..."
198	@echo "Go version:"
199	@go version
200	@echo "\nSQLC version:"
201	@sqlc version
202	@echo "\nGolangci-lint version:"
203	@golangci-lint version
204	@echo "\nBuilding project..."
205	@$(MAKE) build-quick
206	@echo "\nVerifying generated systemviews artifacts..."
207	@$(MAKE) verify-generated
208	@echo "\nRunning tests..."
209	@$(MAKE) test
210	@echo "\nVerifying purego-only constraints..."
211	@$(MAKE) verify-purego
212	@echo "\nAll checks passed!"
213
214# Documentation
215man: build-quick ## Install man pages to ~/.local/share/man/man1/
216	@echo "Installing man pages..."
217	$(DIST_DIR)/$(BINARY_NAME) gen-docs
218
219# Native release targets
220.PHONY: release-snapshot release
221
222release-snapshot: build-systemviews ## Build snapshot using goreleaser
223	@echo "Building snapshot with goreleaser..."
224	goreleaser release --snapshot --clean
225
226release: ## Create full release using goreleaser
227	@echo "Building release with goreleaser..."
228	GITHUB_TOKEN=$$(gh auth token) goreleaser release --clean
229
230# Flatpak targets
231flatpak-deps: ## Install Flatpak build dependencies (Arch)
232	@echo "Installing Flatpak build dependencies..."
233	sudo pacman -S --needed flatpak flatpak-builder
234	flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
235	flatpak install --user -y flathub org.gnome.Platform//48 org.gnome.Sdk//48
236	flatpak install --user -y flathub org.freedesktop.Sdk.Extension.golang//24.08
237	flatpak install --user -y flathub org.freedesktop.Sdk.Extension.node20//24.08
238	@echo "Flatpak dependencies installed!"
239
240flatpak-build: ## Build Flatpak bundle locally
241	@echo "Building Flatpak bundle..."
242	flatpak-builder --force-clean --user --repo=flatpak-repo flatpak-build flatpak/dev.bnema.Dumber.yml
243	flatpak build-bundle flatpak-repo dumber.flatpak dev.bnema.Dumber
244	@echo "Flatpak bundle created: dumber.flatpak"
245
246flatpak-install: ## Install Flatpak locally for testing
247	@echo "Installing Flatpak locally..."
248	flatpak-builder --force-clean --user --install flatpak-build flatpak/dev.bnema.Dumber.yml
249	@echo "Flatpak installed! Run with: make flatpak-run"
250
251flatpak-run: ## Run the installed Flatpak
252	flatpak run dev.bnema.Dumber
253
254flatpak-clean: ## Clean Flatpak build artifacts
255	@echo "Cleaning Flatpak build artifacts..."
256	rm -rf flatpak-build flatpak-repo .flatpak-builder dumber.flatpak
257	@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