-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
211 lines (181 loc) · 5.55 KB
/
Makefile
File metadata and controls
211 lines (181 loc) · 5.55 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# StormDB v0.4-alpha Makefile
.PHONY: build clean test install deps run dev plugins build-all test-all
# Build directory
BUILD_DIR = build
PLUGINS_DIR = $(BUILD_DIR)/plugins
# Application binary
APP_NAME = stormdb
APP_BINARY = $(BUILD_DIR)/$(APP_NAME)
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOTEST = $(GOCMD) test
GOGET = $(GOCMD) get
GOMOD = $(GOCMD) mod
# Main application entry point
MAIN_PATH = ./cmd/stormdb
# Plugin directories
PLUGIN_DIRS = $(wildcard plugins/*)
# Default target
all: build-all
# Build everything (core + plugins)
build-all: build plugins
# Install dependencies
deps:
@echo "Installing dependencies..."
$(GOMOD) download
$(GOMOD) tidy
# Build the application
build: deps
@echo "Building $(APP_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(APP_BINARY) $(MAIN_PATH)
@echo "Build complete: $(APP_BINARY)"
# Build all plugins
plugins: build
@echo "Building plugins..."
@mkdir -p $(PLUGINS_DIR)
@for plugin_dir in $(PLUGIN_DIRS); do \
echo "Building plugin: $$plugin_dir"; \
cd $$plugin_dir && $(MAKE) plugin && cd ../..; \
done
@echo "All plugins built successfully"
# Build specific plugin
plugin-%:
@echo "Building plugin: plugins/$*"
@mkdir -p $(PLUGINS_DIR)
@cd plugins/$* && $(MAKE) plugin
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@for plugin_dir in $(PLUGIN_DIRS); do \
echo "Cleaning plugin: $$plugin_dir"; \
cd $$plugin_dir && $(MAKE) clean && cd ../..; \
done
@echo "Clean complete"
# Run tests for core and plugins
test-all: test test-plugins
# Run core tests
test:
@echo "Running core tests..."
$(GOTEST) -v ./core/... ./cmd/...
# Run plugin tests
test-plugins:
@echo "Running plugin tests..."
@for plugin_dir in $(PLUGIN_DIRS); do \
echo "Testing plugin: $$plugin_dir"; \
cd $$plugin_dir && $(MAKE) test && cd ../..; \
done
# Test specific plugin
test-plugin-%:
@echo "Testing plugin: plugins/$*"
@cd plugins/$* && $(MAKE) test
# Install the application and plugins
install: build-all
@echo "Installing $(APP_NAME)..."
cp $(APP_BINARY) /usr/local/bin/$(APP_NAME)
@echo "Installing plugins..."
@sudo mkdir -p /usr/local/lib/stormdb/plugins
@sudo cp $(PLUGINS_DIR)/*.so /usr/local/lib/stormdb/plugins/ 2>/dev/null || true
@echo "Installation complete"
# Run the application in development mode
dev: build-all
@echo "Starting $(APP_NAME) in development mode..."
@mkdir -p ./config
STORMDB_CONFIG=./config/core.yaml $(APP_BINARY)
# Run the application
run: build
@echo "Starting $(APP_NAME)..."
$(APP_BINARY)
# Run with plugins
run-with-plugins: build-all
@echo "Starting $(APP_NAME) with plugins..."
STORMDB_PLUGIN_DIR=$(PLUGINS_DIR) $(APP_BINARY)
# Format code (core and plugins)
fmt:
@echo "Formatting code..."
$(GOCMD) fmt ./...
@for plugin_dir in $(PLUGIN_DIRS); do \
echo "Formatting plugin: $$plugin_dir"; \
cd $$plugin_dir && $(MAKE) fmt && cd ../..; \
done
# Lint code (requires golangci-lint)
lint:
@echo "Linting core code..."
golangci-lint run
@for plugin_dir in $(PLUGIN_DIRS); do \
echo "Linting plugin: $$plugin_dir"; \
cd $$plugin_dir && $(MAKE) lint && cd ../..; \
done
# Check for security issues (requires gosec)
security:
@echo "Checking for security issues..."
gosec ./...
@for plugin_dir in $(PLUGIN_DIRS); do \
if [ -f $$plugin_dir/Makefile ]; then \
echo "Security check for plugin: $$plugin_dir"; \
cd $$plugin_dir && gosec . && cd ../..; \
fi \
done
# Docker build
docker-build:
@echo "Building Docker image..."
docker build -t stormdb:v0.4-alpha .
# Docker run
docker-run:
@echo "Running Docker container..."
docker run -p 8080:8080 -p 5432:5432 stormdb:v0.4-alpha
# Development setup
setup-dev:
@echo "Setting up development environment..."
@mkdir -p config logs plugins
@if [ ! -f config/core.yaml ]; then \
cp config/core.yaml.example config/core.yaml 2>/dev/null || \
echo "Warning: No example config found"; \
fi
# List available plugins
list-plugins:
@echo "Available plugins:"
@for plugin_dir in $(PLUGIN_DIRS); do \
if [ -f $$plugin_dir/plugin.go ]; then \
echo " - $$(basename $$plugin_dir)"; \
fi \
done
# Plugin status
plugins-status:
@echo "Plugin build status:"
@for plugin_dir in $(PLUGIN_DIRS); do \
plugin_name=$$(basename $$plugin_dir); \
if [ -f $(PLUGINS_DIR)/$$plugin_name.so ]; then \
echo " ✓ $$plugin_name - built"; \
else \
echo " ✗ $$plugin_name - not built"; \
fi \
done
# Show help
help:
@echo "Available targets:"
@echo " build-all - Build application and all plugins"
@echo " build - Build the core application"
@echo " plugins - Build all plugins"
@echo " plugin-<name> - Build specific plugin"
@echo " clean - Clean build artifacts"
@echo " test-all - Run all tests (core + plugins)"
@echo " test - Run core tests"
@echo " test-plugins - Run plugin tests"
@echo " test-plugin-<name> - Test specific plugin"
@echo " install - Install application and plugins"
@echo " dev - Run in development mode"
@echo " run - Run the application"
@echo " run-with-plugins - Run with plugins loaded"
@echo " fmt - Format code"
@echo " lint - Lint code"
@echo " security - Check for security issues"
@echo " docker-build - Build Docker image"
@echo " docker-run - Run Docker container"
@echo " setup-dev - Setup development environment"
@echo " list-plugins - List available plugins"
@echo " plugins-status - Show plugin build status"
@echo " deps - Install dependencies"
@echo " help - Show this help message"