-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (68 loc) · 2.01 KB
/
Makefile
File metadata and controls
86 lines (68 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.PHONY: all build generate clean test run-daemon install-tools dev install-air install
# Binary output directory
BIN_DIR := bin
# Proto paths
PROTO_DIR := proto
PROTO_FILES := $(shell find $(PROTO_DIR) -name '*.proto')
all: generate build
# Build all binaries
build: build-map build-mapd
build-map:
@mkdir -p $(BIN_DIR)
go build -o $(BIN_DIR)/map ./cmd/map
build-mapd:
@mkdir -p $(BIN_DIR)
go build -o $(BIN_DIR)/mapd ./cmd/mapd
# Generate protobuf code
generate:
@mkdir -p proto/map/v1
protoc -Iproto --go_out=proto --go_opt=paths=source_relative \
--go-grpc_out=proto --go-grpc_opt=paths=source_relative \
map/v1/types.proto map/v1/daemon.proto
# Install required tools
install-tools:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# Clean build artifacts
clean:
rm -rf $(BIN_DIR)
find $(PROTO_DIR) -name '*.pb.go' -delete
# Run tests
test:
go test -v ./...
# Development helpers
run-daemon:
go run ./cmd/mapd
run-cli:
go run ./cmd/map $(ARGS)
# Quick iteration: generate + build
rebuild: generate build
# Download dependencies
deps:
go mod download
go mod tidy
# Install air for hot reloading
install-air:
@command -v air >/dev/null 2>&1 || { \
echo "Installing air..."; \
go install github.com/air-verse/air@latest; \
}
# Development mode with hot reloading
# Watches for changes, rebuilds, and copies binaries to ~/.local/bin
dev: install-air
@mkdir -p ~/.local/bin
@rm -rf tmp
@echo "Starting development mode with hot reloading..."
@echo "Binaries will be copied to ~/.local/bin on each rebuild"
@echo "Press Ctrl+C to stop"
@air -c .air.toml
# Build and copy to ~/.local/bin (used by air for hot reload)
dev-build: build
@mkdir -p ~/.local/bin
@cp $(BIN_DIR)/map $(BIN_DIR)/mapd ~/.local/bin/
@echo "Binaries copied to ~/.local/bin"
# Install binaries to ~/.local/bin (one-time)
install: build
@mkdir -p ~/.local/bin
cp $(BIN_DIR)/map $(BIN_DIR)/mapd ~/.local/bin/
@echo "Installed map and mapd to ~/.local/bin"