-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
116 lines (77 loc) · 3.89 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
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
.PHONY: clean prerequisites pre-commit cmake-configure cmake-build cmake-test cmake-install cmake-uninstall test-build test-build-memcheck test-build-test test-build-test-install test-build-test-install-ccov test-coverage test-valgrind test-sanitizer-address test-sanitizer-leak test-sanitizer-memory test-sanitizer-undefined test-sanitizer test-cppcheck test-clang-tidy test-export-mode docs-clean docs-pip-requirements docs docs-check docs-serve
########################################################################################
# Variables
########################################################################################
# Extra arguments to pass to pre-commit.
PRE_COMMIT_EXTRA_ARGS ?=
# Preset to use for CMake.
PRESET ?= default
# Extra arguments to pass to CMake when configuring.
CONFIGURE ?=
########################################################################################
# Development Environment Management
########################################################################################
# Remove common intermediate files.
clean:
-rm -rf \
out \
docs/_build
# Install standalone tools
prerequisites:
pipx install --force pre-commit==4.2.0
pipx install --force watchfiles==1.0.4
########################################################################################
# Lint
########################################################################################
# Run pre-commit with autofix against all files.
pre-commit:
pre-commit run --all-files $(PRE_COMMIT_EXTRA_ARGS)
########################################################################################
# CMake build and test
########################################################################################
_PRESET_ARGS = --preset $(PRESET)
cmake-configure:
cmake -S . $(_PRESET_ARGS) $(CONFIGURE)
cmake-build-template-%:
cmake --build $(_PRESET_ARGS) --target $*
cmake-build: cmake-build-template-all
cmake-test:
ctest $(_PRESET_ARGS)
cmake-install:
cmake --build $(_PRESET_ARGS) --target install
cmake-uninstall:
cmake --build $(_PRESET_ARGS) --target uninstall
test-build: cmake-configure cmake-build
test-build-memcheck: test-build cmake-build-template-ExperimentalMemCheck
test-build-doxygen: cmake-configure cmake-build-template-cppfront-practice-doxygen
test-build-test: test-build cmake-test
test-build-test-install: test-build-test cmake-install cmake-uninstall
test-build-test-install-ccov: test-build-test-install cmake-build-template-ccov-all
test-coverage:
$(MAKE) test-build-test-install-ccov CONFIGURE="-DBUILD_TESTING=ON -DCODE_COVERAGE=ON $(CONFIGURE) --fresh"
test-valgrind:
$(MAKE) test-build-memcheck CONFIGURE="-DBUILD_TESTING=ON -DUSE_VALGRIND=ON $(CONFIGURE) --fresh"
test-sanitizer-template-%:
$(MAKE) test-build-test CONFIGURE="-DBUILD_TESTING=ON -DUSE_SANITIZER=$* $(CONFIGURE) --fresh"
test-sanitizer-address: test-sanitizer-template-address
test-sanitizer-leak: test-sanitizer-template-leak
test-sanitizer-memory: test-sanitizer-template-memory
test-sanitizer-undefined: test-sanitizer-template-undefined
test-sanitizer: test-sanitizer-template-address test-sanitizer-template-leak test-sanitizer-template-memory test-sanitizer-template-undefined
test-cppcheck:
$(MAKE) test-build CONFIGURE="-DBUILD_TESTING=ON -DUSE_CPPCHECK=ON $(CONFIGURE) --fresh"
test-clang-tidy:
$(MAKE) test-build CONFIGURE="-DBUILD_TESTING=ON -DUSE_CLANGTIDY=ON $(CONFIGURE) --fresh"
########################################################################################
# Documentation
########################################################################################
docs-clean:
cmake -E rm -rf docs/_build/html
docs-pip-requirements:
pip install -r docs/requirements.txt
docs: docs-pip-requirements
mkdocs build -d docs/_build/html $(MKDOCS_EXTRA_OPTS)
docs-check:
$(MAKE) docs MKDOCS_EXTRA_OPTS="--strict $(MKDOCS_EXTRA_OPTS)"
docs-serve: docs-pip-requirements
mkdocs serve $(MKDOCS_EXTRA_OPTS)