-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (119 loc) · 3.9 KB
/
Makefile
File metadata and controls
137 lines (119 loc) · 3.9 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
.PHONY: build test test-verbose test-coverage clean fmt lint verify help binaries
# Module directories
MODULES := \
src/lib \
src/executor \
src/executor-event-loop \
src/cli \
src/db \
src/debugger \
src/logger \
src/mmap-go-prototype \
src/sut/register \
src/sut/broadcast
# Binary names
BINARIES := detsys detsys-debug detsys-logger
# Default target
help:
@echo "Available targets:"
@echo " build - Build all modules"
@echo " binaries - Build all executable binaries"
@echo " test - Run all tests"
@echo " test-verbose - Run tests with verbose output"
@echo " test-coverage - Run tests with coverage report"
@echo " clean - Clean build artifacts and binaries"
@echo " fmt - Format Go code in all modules"
@echo " lint - Run linter on all modules"
@echo " verify - Verify and tidy all module dependencies"
@echo " help - Show this help message"
# Build all modules
build:
@echo "Building all modules..."
@for module in $(MODULES); do \
echo " Building $$module..."; \
(cd $$module && go build ./...) || exit 1; \
done
@echo "Build completed successfully!"
# Build executable binaries
binaries: build
@echo "Building executable binaries..."
@cd src/cli && go build -o ../../detsys .
@cd src/debugger/cmd/detsys-debug && go build -o ../../../../detsys-debug .
@cd src/logger/cmd/reactor_logger && go build -o ../../../../detsys-logger .
@echo "Binaries created: $(BINARIES)"
# Run all tests
test:
@echo "Running tests..."
@for module in $(MODULES); do \
echo " Testing $$module..."; \
(cd $$module && go test ./...) || exit 1; \
done
# Run tests with verbose output
test-verbose:
@echo "Running tests with verbose output..."
@for module in $(MODULES); do \
echo " Testing $$module..."; \
(cd $$module && go test -v ./...) || exit 1; \
done
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
@for module in $(MODULES); do \
echo " Testing $$module with coverage..."; \
(cd $$module && go test -coverprofile=coverage.out ./... && \
go tool cover -func=coverage.out | tail -1) || exit 1; \
done
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -f $(BINARIES)
@for module in $(MODULES); do \
echo " Cleaning $$module..."; \
(cd $$module && go clean ./... && rm -f coverage.out coverage.html) || exit 1; \
done
@echo "Clean completed!"
# Format Go code
fmt:
@echo "Formatting Go code..."
@for module in $(MODULES); do \
echo " Formatting $$module..."; \
(cd $$module && go fmt ./...) || exit 1; \
done
@echo "Code formatting completed!"
# Run linter (requires golangci-lint to be installed)
lint:
@echo "Running linter..."
@if command -v golangci-lint >/dev/null 2>&1; then \
for module in $(MODULES); do \
echo " Linting $$module..."; \
(cd $$module && golangci-lint run) || exit 1; \
done; \
else \
echo "golangci-lint not found. Install it with:"; \
echo " go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
fi
# Verify and tidy module dependencies
verify:
@echo "Verifying module dependencies..."
@for module in $(MODULES); do \
echo " Processing $$module..."; \
(cd $$module && go mod verify && go mod tidy) || exit 1; \
done
@echo "Module verification completed!"
# Quick development cycle: format, build, test
dev: fmt build test
@echo "Development cycle completed!"
# CI/CD pipeline: verify, build, lint, test with coverage
ci: verify build lint test-coverage binaries
@echo "CI pipeline completed!"
# Build just the lib module (for dependencies)
build-lib:
@echo "Building src/lib..."
@cd src/lib && go build ./...
# Build specific binaries
build-cli: build-lib
@cd src/cli && go build -o ../../detsys .
build-debugger: build-lib
@cd src/debugger/cmd/detsys-debug && go build -o ../../../../detsys-debug .
build-logger: build-lib
@cd src/logger/cmd/reactor_logger && go build -o ../../../../detsys-logger .