-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (121 loc) · 4.33 KB
/
Makefile
File metadata and controls
145 lines (121 loc) · 4.33 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
138
139
140
141
142
143
144
145
.PHONY: all build test test-full test-careful coverage clean check install \
cross-build build-linux build-windows build-darwin \
work-on-lifecycle work-on-procio work-on-introspection \
work-off-lifecycle work-off-procio work-off-introspection work-off-all
# Go parameters
GOCMD=go
GOWORK=$(GOCMD) work
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOTOOL=$(GOCMD) tool
GOINSTALL=$(GOCMD) install
BINARY_NAME=loam
BINARY_UNIX=$(BINARY_NAME)
# --- OS Detection & Command Abstraction ---
ifeq ($(OS),Windows_NT)
BINARY := $(BINARY_NAME).exe
RM := del /F /Q
# Windows needs backslashes for 'go work edit -dropuse' to match go.work content
DROP_WORK = if exist go.work ( $(GOWORK) edit -dropuse $(subst /,\,$(1)) )
INIT_WORK = if not exist go.work ( echo "Initializing go.work..." & $(GOWORK) init . )
else
BINARY := $(BINARY_UNIX)
RM := rm -f
# Linux/macOS uses forward slashes
DROP_WORK = [ -f go.work ] && $(GOWORK) edit -dropuse $(1)
INIT_WORK = [ -f go.work ] || ( echo "Initializing go.work..." && $(GOWORK) init . )
endif
# Default target
all: build
# Build the binary for the current platform
build:
@echo "Building for $(GOOS)/$(GOARCH)..."
$(GOBUILD) -v -o $(BINARY_NAME) ./cmd/loam
# Run go vet for static analysis
vet:
@echo "Running go vet..."
$(GOCMD) vet ./...
# Run tests excluding stress/benchmarks (Fast Feedback)
test:
@echo "Running tests (excluding stress/benchmarks)..."
$(GOTEST) -timeout 60s ./pkg/... ./cmd/... ./internal/... ./tests/e2e ./tests/reactivity ./tests/typed
# Run all tests
test-full:
@echo "Running all tests (including stress/benchmarks)..."
$(GOTEST) -race -timeout 120s ./...
# Run tests about concurrency and file system (slower, more careful)
test-careful:
@echo "Running careful tests (concurrency and file system)..."
$(GOTEST) -race -timeout 60s -v ./pkg/adapters/fs ./pkg/adapters/lifecycle
# Run coverage tests
coverage:
@echo "Running tests with coverage..."
$(GOTEST) -race -timeout 120s -coverprofile="coverage.out" ./...
$(GOTOOL) cover -func="coverage.out"
# Clean build artifacts
clean:
@echo "Cleaning up..."
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME).exe
rm -f $(BINARY_NAME)-*
# Verify all code and examples compile
check:
@echo "Running static analysis and compilation check..."
$(GOCMD) vet ./...
# Install the binary
install:
@echo "Installing loam..."
$(GOINSTALL) ./cmd/loam
# Cross-platform builds
cross-build: build-linux build-windows build-darwin
build-linux:
@echo "Building for Linux..."
GOOS=linux GOARCH=amd64 $(GOBUILD) -v -o $(BINARY_NAME)-linux-amd64 ./cmd/loam
build-windows:
@echo "Building for Windows..."
GOOS=windows GOARCH=amd64 $(GOBUILD) -v -o $(BINARY_NAME)-windows-amd64.exe ./cmd/loam
build-darwin:
@echo "Building for macOS..."
GOOS=darwin GOARCH=amd64 $(GOBUILD) -v -o $(BINARY_NAME)-darwin-amd64 ./cmd/loam
# --- Dependency Management (Dev vs Prod) ---
# Helper to get the correct path (uses WORK_PATH if provided, else default)
GET_PATH = $(if $(WORK_PATH),$(WORK_PATH),$(1))
# Enable local development mode for lifecycle
# Usage: make work-on-lifecycle [WORK_PATH=../lifecycle]
work-on-lifecycle:
@echo "Enabling local lifecycle..."
@$(INIT_WORK)
$(GOWORK) use $(call GET_PATH,../lifecycle)
# Enable local development mode for procio
# Usage: make work-on-procio [WORK_PATH=../procio]
work-on-procio:
@echo "Enabling local procio..."
@$(INIT_WORK)
$(GOWORK) use $(call GET_PATH,../procio)
# Enable local development mode for introspection
# Usage: make work-on-introspection [WORK_PATH=../introspection]
work-on-introspection:
@echo "Enabling local introspection..."
@$(INIT_WORK)
$(GOWORK) use $(call GET_PATH,../introspection)
# Disable local lifecycle
# Usage: make work-off-lifecycle [WORK_PATH=../lifecycle]
work-off-lifecycle:
@echo "Disabling local lifecycle..."
@$(call DROP_WORK,$(call GET_PATH,../lifecycle))
# Disable local procio
# Usage: make work-off-procio [WORK_PATH=../procio]
work-off-procio:
@echo "Disabling local procio..."
@$(call DROP_WORK,$(call GET_PATH,../procio))
# Disable local introspection
# Usage: make work-off-introspection [WORK_PATH=../introspection]
work-off-introspection:
@echo "Disabling local introspection..."
@$(call DROP_WORK,$(call GET_PATH,../introspection))
# Disable local development mode by removing go.work (nuclear option)
work-off-all:
@echo "Disabling local workspace mode..."
@$(RM) go.work