-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
159 lines (127 loc) Β· 5.86 KB
/
Makefile
File metadata and controls
159 lines (127 loc) Β· 5.86 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
####################################################################################################
## Variables
####################################################################################################
# Build configuration
BUILD_TYPE ?= Debug
BUILD_DIR := build
CMAKE_OPTIONS ?=
NPROC := $(shell nproc 2>/dev/null || echo 4)
# Directories
DOC_DIR := docs
VENV_DIR := .venv
SHELL := /bin/bash
.SHELLFLAGS := -e -o pipefail -c
.DEFAULT_GOAL := help
####################################################################################################
## Help
####################################################################################################
.PHONY: help
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
####################################################################################################
## Build Targets
####################################################################################################
.PHONY: build
build: ## Build the project (debug by default, use BUILD_TYPE=Release for optimized)
@echo "Configuring with CMake (BUILD_TYPE=$(BUILD_TYPE))..."
@cmake -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DSERPENT_BUILD_TESTS=ON $(CMAKE_OPTIONS)
@echo "Building..."
@cmake --build $(BUILD_DIR) -j$(NPROC)
.PHONY: release
release: ## Build optimized release version
@$(MAKE) build BUILD_TYPE=Release
.PHONY: clean
clean: ## Remove build artifacts
@echo "Cleaning build directory..."
@rm -rf $(BUILD_DIR)
@rm -rf ./site ./doxygen
.PHONY: rebuild
rebuild: clean build ## Clean and rebuild
####################################################################################################
## Testing
####################################################################################################
.PHONY: test
test: build ## Run all tests
@echo "Running tests..."
@cd $(BUILD_DIR) && ctest --output-on-failure
.PHONY: test-verbose
test-verbose: build ## Run tests with verbose output
@cd $(BUILD_DIR) && ctest --output-on-failure --verbose
.PHONY: test-valgrind
test-valgrind: build ## Run tests with Valgrind memory checker
@echo "Running tests with Valgrind..."
@valgrind --leak-check=full --suppressions=valgrind.supp ./$(BUILD_DIR)/serpent_test
####################################################################################################
## Examples
####################################################################################################
.PHONY: examples
examples: build ## Build and run all examples
@echo "Running examples..."
@for f in $$(find $(BUILD_DIR) -maxdepth 1 -name "*_example" -type f -executable); do \
echo ""; echo "=== Running $$(basename $$f) ==="; $$f; \
done
####################################################################################################
## Code Quality
####################################################################################################
.PHONY: format
format: ## Format C++ code using `clang-format`
@echo "Formatting code..."
@find src include test -name '*.cc' -o -name '*.h' 2>/dev/null | xargs -r clang-format -i
.PHONY: lint
lint: ## Run static analysis (`clang-tidy` and `cppcheck`)
@echo "Running cppcheck..."
@cppcheck --enable=all --inconclusive --quiet --std=c++20 -Iinclude --suppress=missingIncludeSystem src include test
@echo "Running clang-tidy..."
@if [ -f $(BUILD_DIR)/compile_commands.json ]; then find src -name '*.cc' | head -5 | \
xargs -I{} clang-tidy {} -p $(BUILD_DIR); else echo "Build first to generate compile_commands.json"; fi
####################################################################################################
## Documentation
####################################################################################################
.PHONY: docs-mkdocs
docs-mkdocs: ## Build MkDocs documentation
@echo "Building MkDocs documentation..."
@mkdocs build
.PHONY: docs-mkdocs-serve
docs-mkdocs-serve: ## Serve MkDocs documentation locally
@echo "Serving MkDocs at http://localhost:8001..."
@mkdocs serve -a localhost:8001
.PHONY: docs-doxygen
docs-doxygen: ## Generate API documentation with Doxygen
@echo "Generating Doxygen API docs..."
@doxygen Doxyfile
.PHONY: docs-doxygen-serve
docs-doxygen-serve: ## Serve Doxygen documentation locally
@echo "Serving Doxygen docs at http://localhost:8002..."
@cd ./doxygen/html && python3 -m http.server 8002
####################################################################################################
## Dependencies
####################################################################################################
.PHONY: install-deps
install-deps: ## Install system dependencies (Debian/Ubuntu)
@echo "Installing system dependencies..."
sudo apt-get update
sudo apt-get install -y cmake build-essential clang clang-format clang-tidy \
cppcheck valgrind gdb doxygen graphviz python3 python3-pip python3-venv
.PHONY: install-python-deps
install-python-deps: ## Install Python dependencies for docs
@echo "Setting up Python environment..."
@python3 -m venv $(VENV_DIR)
@$(VENV_DIR)/bin/pip install mkdocs mkdocs-material
.PHONY: submodules
submodules: ## Initialize and update git submodules
@echo "Updating git submodules..."
@git submodule update --init --recursive
####################################################################################################
## Additonal Targets
####################################################################################################
.PHONY: setup-hooks
setup-hooks: ## Install Git hooks (pre-commit and pre-push)
@echo "Installing Git hooks..."
@pre-commit install --hook-type pre-commit
@pre-commit install --hook-type pre-push
@pre-commit install-hooks
.PHONY: test-hooks
test-hooks: ## Run Git hooks on all files manually
@echo "Running Git hooks..."
@pre-commit run --all-files