-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (91 loc) · 3.01 KB
/
Makefile
File metadata and controls
114 lines (91 loc) · 3.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.PHONY: all build install clean test fmt vet
# Binary output directory
BIN_DIR := bin
# Command directories
COMMANDS := git-commitAll git-evars git-exec git-list-executables git-replicate git-treeconfig git-update
# Go parameters
GOCMD := go
GOBUILD := $(GOCMD) build
GOTEST := $(GOCMD) test
GOFMT := $(GOCMD) fmt
GOVET := $(GOCMD) vet
GOMOD := $(GOCMD) mod
GOINSTALL := $(GOCMD) install
# Build flags
LDFLAGS := -ldflags="-s -w"
all: deps fmt vet build
deps:
@echo "Installing dependencies..."
@$(GOCMD) get github.com/fatih/color
build: $(BIN_DIR)
@echo "Building all commands..."
@for cmd in $(COMMANDS); do \
echo " Building $$cmd..."; \
$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/$$cmd ./cmd/$$cmd || exit 1; \
done
@echo "Build complete!"
$(BIN_DIR):
@mkdir -p $(BIN_DIR)
install:
@echo "Installing all commands to GOPATH/bin..."
@for cmd in $(COMMANDS); do \
echo " Installing $$cmd..."; \
$(GOINSTALL) $(LDFLAGS) ./cmd/$$cmd || exit 1; \
done
@echo "Install complete!"
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BIN_DIR)
@echo "Clean complete!"
test:
@echo "Running tests..."
@$(GOTEST) -v ./...
fmt:
@echo "Formatting code..."
@$(GOFMT) ./...
vet:
@echo "Checking Go version..."
@go version | grep -qE 'go1\.(2[4-9]|[3-9][0-9])' || (echo "Error: Go 1.24 or later is required" && exit 1)
@echo "Vetting code..."
@$(GOVET) ./...
tidy:
@echo "Tidying go.mod..."
@$(GOMOD) tidy
# Individual command builds
git-commitAll: $(BIN_DIR)
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/git-commitAll ./cmd/git-commitAll
git-evars: $(BIN_DIR)
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/git-evars ./cmd/git-evars
git-exec: $(BIN_DIR)
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/git-exec ./cmd/git-exec
git-list-executables: $(BIN_DIR)
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/git-list-executables ./cmd/git-list-executables
git-replicate: $(BIN_DIR)
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/git-replicate ./cmd/git-replicate
git-treeconfig: $(BIN_DIR)
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/git-treeconfig ./cmd/git-treeconfig
git-update: $(BIN_DIR)
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/git-update ./cmd/git-update
# Build the release tool (dev-only, not installed with other commands)
release-tool: $(BIN_DIR)
@echo "Building release tool..."
@$(GOBUILD) $(LDFLAGS) -o $(BIN_DIR)/release ./cmd/release
@echo "Release tool built at $(BIN_DIR)/release"
# Help target
help:
@echo "Available targets:"
@echo " all - Format, vet, and build all commands (default)"
@echo " build - Build all commands to bin/ directory"
@echo " clean - Remove build artifacts"
@echo " fmt - Format all Go code"
@echo " help - Show this help message"
@echo " install - Install all commands to GOPATH/bin"
@echo " release-tool - Build the release tool (dev-only)"
@echo " test - Run all tests"
@echo " tidy - Tidy go.mod and go.sum"
@echo " vet - Run go vet on all code"
@echo ""
@echo "Individual command targets:"
@for cmd in $(COMMANDS); do \
echo " $$cmd"; \
done