-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (119 loc) · 4.46 KB
/
Makefile
File metadata and controls
151 lines (119 loc) · 4.46 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
.DEFAULT_GOAL := help
# SHELL := /bin/bash
################################### Conan
CONAN_PROFILE ?= profiles/macos-clang14
.PHONY: conan-setup
conan-setup: ## setup conan with conancenter remote
conan remote add conancenter https://center2.conan.io --force
.PHONY: deps
deps: ## install conan dependencies
conan install . --output-folder=build --build=missing --profile=$(CONAN_PROFILE)
################################### Build and Test
all: build
.PHONY: build
build: ## build library and run tests
conan build . --build=missing --profile=$(CONAN_PROFILE)
.PHONY: test
test: ## run unit tests (RERUN=1 to rerun failed only)
cd build/Release && ctest --output-on-failure $(if $(RERUN),--rerun-failed)
.PHONY: package
package: ## create conan package and run test_package
conan create . --build=missing --profile=$(CONAN_PROFILE)
################################### Benchmarks
.PHONY: bench-deps
bench-deps: ## install benchmark dependencies
conan install . --build=missing --profile=$(CONAN_PROFILE) -o with_benchmarks=True
.PHONY: bench-build
bench-build: ## build benchmarks
conan build . --build=missing --profile=$(CONAN_PROFILE) -o with_benchmarks=True
.PHONY: bench
bench: ## run benchmarks
./build/Release/bench/loon_benchmarks
.PHONY: clean
clean: ## clean all build and generated files
@rm -rf build
@rm -rf coverage
@rm -rf site
@rm -rf cppcheck-cache
@rm -f cppcheck_report.txt
@find . -name "*.gcda" -delete
@find . -name "*.gcno" -delete
################################### Coverage
COVERAGE_PROFILE ?= profiles/macos-clang14-coverage
COVERAGE_DIR ?= coverage
.PHONY: coverage
coverage: ## build with coverage and generate HTML report
conan build . --build=missing --profile=$(COVERAGE_PROFILE)
@mkdir -p $(COVERAGE_DIR)
gcovr --root . \
--filter include/ \
--exclude-unreachable-branches \
--xml coverage/coverage.xml \
--html-details $(COVERAGE_DIR)/index.html
@echo "Coverage report: $(COVERAGE_DIR)/index.html"
.PHONY: coverage-clean
coverage-clean: ## clean coverage data
@rm -rf $(COVERAGE_DIR)
@find . -name "*.gcda" -delete
@find . -name "*.gcno" -delete
################################### Static Analysis
CPPCHECK_CACHE_DIR ?= cppcheck-cache
SOURCES := $(shell find include test test_package bench -iname "*.hpp" -o -iname "*.cpp" 2>/dev/null)
.PHONY: check-format
check-format: ## Check clang format errors
clang-format --style=file --dry-run -Werror $(SOURCES)
.PHONY: format
format: ## Apply clang format to code
clang-format --style=file -i $(SOURCES)
.PHONY: check
check: ## Run static analysis checks using cppcheck
@mkdir -p $(CPPCHECK_CACHE_DIR)
@cppcheck --version
cppcheck --quiet \
--enable=all \
--std=c++23 \
--cppcheck-build-dir=$(CPPCHECK_CACHE_DIR) \
--inline-suppr \
--check-level=exhaustive \
--error-exitcode=1 \
--checkers-report=cppcheck_report.txt \
--language=c++ \
--suppressions-list=config/cppcheck-suppressions.txt \
./include/loon/*.hpp
.PHONY: tidy
tidy: ## Run clang-tidy static analysis
@clang-tidy --version
clang-tidy --warnings-as-errors=* ./include/loon/*.hpp -- -std=c++23
.PHONY: iwyu
iwyu: ## Run include-what-you-use analysis
@include-what-you-use --version || echo "Install: brew install include-what-you-use"
@for file in ./include/loon/*.hpp; do \
echo "Checking $$file..."; \
include-what-you-use -std=c++23 $$file 2>&1 || true; \
done
.PHONY: check-all
check-all: check tidy ## Run all static analysis checks (cppcheck + clang-tidy)
################################### Documentation
DOCS_VENV := .venv-docs
.PHONY: docs-setup
docs-setup: ## Setup Python venv and install docs dependencies
@python3 -m venv $(DOCS_VENV)
@$(DOCS_VENV)/bin/pip install --upgrade pip
@$(DOCS_VENV)/bin/pip install -r docs-src/requirements.txt
@echo "Docs environment ready. Run 'make docs' or 'make docs-serve'"
.PHONY: docs
docs: ## Build documentation site
@test -d $(DOCS_VENV) || (echo "Run 'make docs-setup' first" && exit 1)
$(DOCS_VENV)/bin/mkdocs build
@echo "Documentation: site/index.html"
.PHONY: docs-serve
docs-serve: ## Serve documentation locally with hot-reload
@test -d $(DOCS_VENV) || (echo "Run 'make docs-setup' first" && exit 1)
$(DOCS_VENV)/bin/mkdocs serve
.PHONY: docs-clean
docs-clean: ## Clean generated documentation
@rm -rf site
@rm -rf $(DOCS_VENV)
################################### Other targets
help: ## Show this help message
@grep '##' $(MAKEFILE_LIST) | grep -v grep | awk 'BEGIN {FS = ": .*##"}; {printf "\033[36m%-38s\033[0m %s\n", $$1, $$2}'