Makefile RawHistoryFolder
1# Makefile for dumb-browser
2
3.PHONY: build test lint clean install-tools dev generate help
4
5# Variables
6BINARY_NAME=dumb-browser
7MAIN_PATH=./cmd/dumb-browser
8
9# Version information from git
10VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.0.0-dev")
11COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
12BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
13
14# Linker flags
15LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
16
17# Default target
18help: ## Show this help message
19 @echo "Available targets:"
20 @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
21
22# Build targets
23build: ## Build the binary
24 @echo "Building $(BINARY_NAME) $(VERSION)..."
25 CGO_ENABLED=0 go build $(LDFLAGS) -o $(BINARY_NAME) $(MAIN_PATH)
26
27build-wails: ## Build with CGO enabled for Wails (when needed)
28 @echo "Building $(BINARY_NAME) $(VERSION) with CGO enabled..."
29 CGO_ENABLED=1 go build $(LDFLAGS) -o $(BINARY_NAME) $(MAIN_PATH)
30
31# Development targets
32dev: ## Run in development mode
33 @echo "Running in development mode..."
34 go run $(MAIN_PATH)
35
36generate: ## Generate code (SQLC)
37 @echo "Generating code with SQLC..."
38 sqlc generate
39 @echo "Code generation complete"
40
41# Testing
42test: ## Run tests
43 @echo "Running tests..."
44 CGO_ENABLED=0 go test -v ./...
45
46test-race: ## Run tests with race detection
47 @echo "Running tests with race detection..."
48 CGO_ENABLED=1 go test -race -v ./...
49
50# Linting
51lint: ## Run golangci-lint
52 @echo "Running golangci-lint..."
53 golangci-lint run
54
55lint-fix: ## Run golangci-lint with --fix
56 @echo "Running golangci-lint with --fix..."
57 golangci-lint run --fix
58
59# Tools installation
60install-tools: ## Install development tools
61 @echo "Installing development tools..."
62 go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
63 go install github.com/wailsapp/wails/v3/cmd/wails3@latest
64 go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
65 @echo "Tools installed successfully"
66
67# Cleanup
68clean: ## Clean build artifacts
69 @echo "Cleaning build artifacts..."
70 rm -f $(BINARY_NAME)
71 go clean -cache
72 go clean -testcache
73
74# Project initialization
75init: install-tools ## Initialize project dependencies and tools
76 @echo "Project dependencies and tools installed!"
77 @echo "Ready for development. Run 'make help' for available commands."
78
79# Check setup
80check: ## Check that all tools and dependencies are working
81 @echo "Checking project setup..."
82 @echo "Go version:"
83 @go version
84 @echo "\nSQLC version:"
85 @sqlc version
86 @echo "\nWails version:"
87 @wails3 version
88 @echo "\nGolangci-lint version:"
89 @golangci-lint version
90 @echo "\nBuilding project..."
91 @make build
92 @echo "\nRunning tests..."
93 @make test
94 @echo "\n✅ All checks passed! Project is ready for development."