v0.14.0 76d1892

Makefile RawHistoryFolder

1# Makefile for dumber
2
3.PHONY: build build-frontend test lint clean install-tools dev generate help check init build-static build-no-gui
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=.
14DIST_DIR=dist
15
16# Detect number of CPU cores for parallel compilation
17NPROCS?=$(shell nproc 2>/dev/null || echo 1)
18
19# Local caches to avoid $HOME permission issues (override via .env.local)
20# GOMODCACHE?=$(CURDIR)/tmp/go-mod
21# GOCACHE?=$(CURDIR)/tmp/go-cache
22# GOTMPDIR?=$(CURDIR)/tmp
23# GOENV=GOMODCACHE=$(GOMODCACHE) GOCACHE=$(GOCACHE) GOTMPDIR=$(GOTMPDIR)
24GOENV=
25
26# Version information from git
27VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.0.0-dev")
28COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
29BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
30
31# Linker flags
32LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
33
34# Default target
35help: ## Show this help message
36	@echo "Available targets:"
37	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
38
39# Build targets
40build: build-frontend ## Build the application with GUI (frontend assets, then Go binary with WebKitGTK)
41	@echo "Building $(BINARY_NAME) $(VERSION) with GUI using $(NPROCS) cores..."
42	@mkdir -p $(DIST_DIR) tmp tmp/go-cache tmp/go-mod
43	$(GOENV) CGO_ENABLED=1 go build -p $(NPROCS) $(LDFLAGS) -tags=webkit_cgo -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_PATH)
44	@echo "✅ Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)"
45
46build-frontend: ## Build Svelte GUI with Tailwind CSS and main-world script
47	@echo "Building Svelte GUI with Tailwind CSS and main-world script..."
48	@cd gui && npm install --silent && npm run build
49	@echo "GUI build complete"
50
51build-no-gui: build-frontend ## Build binary without GUI (CGO disabled, CLI-only functionality)
52	@echo "Building $(BINARY_NAME) $(VERSION) (CLI-only, no GUI) using $(NPROCS) cores..."
53	@mkdir -p $(DIST_DIR) tmp tmp/go-cache tmp/go-mod
54	$(GOENV) CGO_ENABLED=0 go build -p $(NPROCS) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME)-no-gui $(MAIN_PATH)
55	@echo "✅ Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)-no-gui"
56
57build-static: build-no-gui ## Alias for build-no-gui (backward compatibility)
58	@echo "Note: build-static is deprecated, use build-no-gui instead"
59
60# GUI build with WebKitGTK 6.0 (GTK4)
61.PHONY: build-gui run-gui
62build-gui: build ## Alias for default build (backward compatibility)
63	@echo "Note: build-gui is now the default 'build' target"
64
65run-gui: ## Run the GUI with native WebKitGTK 6.0 (requires GTK4/WebKitGTK 6 dev packages)
66	@echo "Running GUI (webkit_cgo) using $(NPROCS) cores…"
67	@mkdir -p tmp tmp/go-cache tmp/go-mod
68	$(GOENV) CGO_ENABLED=1 go run -p $(NPROCS) -tags=webkit_cgo $(MAIN_PATH)
69
70.PHONY: check-webkit
71check-webkit: ## Check system has GTK4/WebKitGTK 6.0/JavaScriptCore 6.0
72	@echo "Checking pkg-config versions..."
73	@which pkg-config >/dev/null 2>&1 || (echo "pkg-config not found" && exit 1)
74	@echo "gtk4:            $$(pkg-config --modversion gtk4 2>/dev/null || echo not found)"
75	@echo "webkitgtk-6.0:    $$(pkg-config --modversion webkitgtk-6.0 2>/dev/null || echo not found)"
76	@echo "javascriptcoregtk-6.0: $$(pkg-config --modversion javascriptcoregtk-6.0 2>/dev/null || echo not found)"
77
78# Development targets
79dev: ## Run in development mode
80	@echo "Running in development mode..."
81	go run $(MAIN_PATH)
82
83generate: ## Generate code (SQLC)
84	@echo "Generating code with SQLC..."
85	sqlc generate
86	@echo "Code generation complete"
87
88# Testing
89test: ## Run tests
90	@echo "Running tests..."
91	@mkdir -p tmp tmp/go-cache tmp/go-mod
92	$(GOENV) CGO_ENABLED=0 go test -v ./...
93
94test-race: ## Run tests with race detection
95	@echo "Running tests with race detection..."
96	@mkdir -p tmp tmp/go-cache tmp/go-mod
97	$(GOENV) CGO_ENABLED=1 go test -race -v ./...
98
99# Linting
100lint: ## Run golangci-lint
101	@echo "Running golangci-lint..."
102	golangci-lint run
103
104lint-fix: ## Run golangci-lint with --fix
105	@echo "Running golangci-lint with --fix..."
106	golangci-lint run --fix
107
108# Format code
109fmt: ## Format Go code with gofmt
110	@echo "Formatting Go code with gofmt..."
111	go fmt ./...
112
113# Tools installation
114install-tools: ## Install development tools
115	@echo "Installing development tools..."
116	go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
117	go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
118	@echo "Tools installed successfully"
119
120# Cleanup
121clean: ## Clean build artifacts
122	@echo "Cleaning build artifacts..."
123	rm -rf $(DIST_DIR)
124	rm -f $(BINARY_NAME)  # Remove any old binaries in root
125	rm -rf gui/dist gui/node_modules
126	rm -f assets/gui/gui.min.js assets/gui/homepage.min.js assets/gui/homepage.css assets/gui/main-world.min.js assets/gui/color-scheme.js
127	go clean -cache
128	go clean -testcache
129
130# Project initialization
131init: install-tools ## Initialize project dependencies and tools
132	@echo "Project dependencies and tools installed!"
133	@echo "Ready for development. Run 'make help' for available commands."
134
135# Check setup
136check: ## Check that all tools and dependencies are working
137	@echo "Checking project setup..."
138	@echo "Go version:"
139	@$(GOENV) go version
140	@echo "\nSQLC version:"
141	@$(GOENV) sqlc version
142	@echo "\nGolangci-lint version:"
143	@$(GOENV) golangci-lint version
144	@echo "\nBuilding project..."
145	@$(MAKE) build
146	@echo "\nTesting built binary..."
147	@$(DIST_DIR)/$(BINARY_NAME) version
148	@echo "\nRunning tests..."
149	@$(MAKE) test
150	@echo "\n✅ All checks passed! Project is ready for development."
151
152# Native release targets
153.PHONY: release-snapshot release
154
155release-snapshot: build-frontend ## Build snapshot using native goreleaser (no git tags required)
156	@echo "Building snapshot with goreleaser..."
157	goreleaser release --snapshot --clean
158
159release: ## Create full release (amd64 only) using native goreleaser
160	@echo "Building release with goreleaser..."
161	GITHUB_TOKEN=$$(gh auth token) goreleaser release --clean

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