-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
90 lines (76 loc) · 3.05 KB
/
Makefile
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
.PHONY: help all with-api clean docs build-frontend clean-frontend install install-with-api .FORCE
# Colors for help target
BLUE := \033[34m
CYAN := \033[36m
GREEN := \033[32m
RESET := \033[0m
# Go source files
GO_FILES := $(shell find . -type f -name '*.go')
# Force target to ensure rebuilding
.FORCE:
# Default target: build without API
all: bin/monokit
# Help target
help:
@echo "$(CYAN)Monokit Build System$(RESET)"
@echo "$(BLUE)Available targets:$(RESET)"
@echo " $(GREEN)make$(RESET) Build monokit (minimal build, no API)"
@echo " $(GREEN)make help$(RESET) Show this help message"
@echo " $(GREEN)make with-api$(RESET) Build monokit with API server (includes frontend)"
@echo " $(GREEN)make clean$(RESET) Clean all build artifacts"
@echo " $(GREEN)make clean-frontend$(RESET) Clean only frontend build artifacts"
@echo " $(GREEN)make docs$(RESET) Generate swagger documentation"
@echo " $(GREEN)make install$(RESET) Install minimal monokit"
@echo " $(GREEN)make install-with-api$(RESET) Install monokit with API (includes frontend)"
# Build with API support (includes frontend)
with-api: clean-frontend build-frontend bin/monokit-with-api
# Build the frontend assets
build-frontend:
@echo "$(BLUE)Building frontend assets...$(RESET)"
cd frontend && npm install && npm run build
mkdir -p common/api/frontend/build
cp -r frontend/build/* common/api/frontend/build/
@echo "$(GREEN)Frontend build complete$(RESET)"
# Clean frontend build artifacts
clean-frontend:
@echo "$(BLUE)Cleaning frontend artifacts...$(RESET)"
rm -rf frontend/build
rm -rf common/api/frontend/build
@echo "$(GREEN)Frontend clean complete$(RESET)"
# Clean all build artifacts
clean: clean-frontend
@echo "$(BLUE)Cleaning all build artifacts...$(RESET)"
rm -rf bin/
@echo "$(GREEN)Clean complete$(RESET)"
# Generate swagger documentation
docs:
@echo "$(BLUE)Generating swagger documentation...$(RESET)"
swag init --parseDependency --parseInternal -g common/api/server.go
@echo "$(GREEN)Documentation generation complete$(RESET)"
# Build minimal binary (no API)
bin/monokit: .FORCE
@echo "$(BLUE)Building minimal monokit...$(RESET)"
@mkdir -p bin
@rm -f bin/monokit
@rm -rf common/api/frontend/build
CGO_ENABLED=0 go build -tags "" -o bin/monokit
strip bin/monokit
@echo "$(GREEN)Build complete: bin/monokit$(RESET)"
# Build binary with API (includes frontend)
bin/monokit-with-api: .FORCE
@echo "$(BLUE)Building monokit with API...$(RESET)"
@mkdir -p bin
@rm -f bin/monokit
CGO_ENABLED=0 go build -tags "with_api" -o bin/monokit
strip bin/monokit
@echo "$(GREEN)Build complete: bin/monokit (with API)$(RESET)"
# Install minimal build
install: bin/monokit
@echo "$(BLUE)Installing minimal monokit...$(RESET)"
install -m 755 bin/monokit /usr/local/bin/monokit
@echo "$(GREEN)Installation complete$(RESET)"
# Install with API
install-with-api: with-api
@echo "$(BLUE)Installing monokit with API...$(RESET)"
install -m 755 bin/monokit /usr/local/bin/monokit
@echo "$(GREEN)Installation complete$(RESET)"