-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (87 loc) · 3.26 KB
/
Makefile
File metadata and controls
97 lines (87 loc) · 3.26 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
# Colors
GREEN := \033[32m
CYAN := \033[36m
YELLOW := \033[33m
GRAY := \033[90m
BOLD := \033[1m
RESET := \033[0m
# Config
BIN_DIR := /usr/local/bin
BINARY := path
.DEFAULT_GOAL := help
.PHONY: build install uninstall health clean rebuild test help
# ============================================================
# Build
# ============================================================
build:
@echo "Building $(BINARY)..."
@swift build -c release
@echo "$(GREEN)Build complete!$(RESET) Binary at .build/release/$(BINARY)"
# ============================================================
# Install
# ============================================================
install:
@if [ ! -f .build/release/$(BINARY) ]; then \
echo "$(YELLOW)No binary found.$(RESET) Run 'make build' first."; \
exit 1; \
fi
@mkdir -p $(BIN_DIR)
@echo "Installing $(BINARY) to $(BIN_DIR)..."
@if [ -f $(BIN_DIR)/$(BINARY) ]; then rm $(BIN_DIR)/$(BINARY); fi
@cp .build/release/$(BINARY) $(BIN_DIR)/$(BINARY)
@echo "$(GREEN)Installed!$(RESET)"
# ============================================================
# Uninstall
# ============================================================
uninstall:
@if [ -f $(BIN_DIR)/$(BINARY) ]; then \
echo "Removing $(BIN_DIR)/$(BINARY)..."; \
rm $(BIN_DIR)/$(BINARY); \
echo "$(GREEN)Uninstalled!$(RESET)"; \
else \
echo "$(YELLOW)$(BINARY) not found in $(BIN_DIR).$(RESET)"; \
fi
# ============================================================
# Health
# ============================================================
health:
@if [ -x $(BIN_DIR)/$(BINARY) ]; then \
echo "$(GREEN)$(BINARY) installed$(RESET)"; \
else \
echo "$(YELLOW)$(BINARY) not installed$(RESET)"; \
exit 1; \
fi
# ============================================================
# Rebuild (clean + build + install)
# ============================================================
rebuild: clean build install
# ============================================================
# Test
# ============================================================
test:
@swift test
# ============================================================
# Clean
# ============================================================
clean:
@echo "Cleaning build artifacts..."
@swift package clean
@rm -rf .build
@echo "$(GREEN)Done!$(RESET)"
# ============================================================
# Help
# ============================================================
help:
@echo ""
@echo "$(BOLD)Usage:$(RESET) make $(CYAN)[target]$(RESET)"
@echo ""
@echo "$(YELLOW)Targets:$(RESET)"
@echo " $(CYAN)build$(RESET) $(GRAY)-$(RESET) $(GREEN)Build the release binary$(RESET)"
@echo " $(CYAN)install$(RESET) $(GRAY)-$(RESET) $(GREEN)Copy binary to /usr/local/bin$(RESET)"
@echo " $(CYAN)rebuild$(RESET) $(GRAY)-$(RESET) $(GREEN)Clean, build, and install$(RESET)"
@echo " $(CYAN)uninstall$(RESET) $(GRAY)-$(RESET) $(GREEN)Remove binary from /usr/local/bin$(RESET)"
@echo " $(CYAN)health$(RESET) $(GRAY)-$(RESET) $(GREEN)Check if binary is installed$(RESET)"
@echo " $(CYAN)test$(RESET) $(GRAY)-$(RESET) $(GREEN)Run tests$(RESET)"
@echo " $(CYAN)clean$(RESET) $(GRAY)-$(RESET) $(GREEN)Remove build artifacts$(RESET)"
@echo " $(CYAN)help$(RESET) $(GRAY)-$(RESET) $(GREEN)Show this help message (default)$(RESET)"
@echo ""