-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
138 lines (93 loc) · 4.98 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
.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 docs-linkcheck template-watch template-build
########################################################################################
# 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 copier==9.3.1
pipx install --force pre-commit==4.0.0
pipx install --force watchfiles==0.24.0
########################################################################################
# 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) $(if $(FRESH_CMAKE_CACHE),--fresh)
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-ss-cpp-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_CMAKE_CACHE=1
test-valgrind:
$(MAKE) test-build-memcheck CONFIGURE="-DBUILD_TESTING=ON -DUSE_VALGRIND=ON $(CONFIGURE)" FRESH_CMAKE_CACHE=1
test-sanitizer-template-%:
$(MAKE) test-build-test CONFIGURE="-DBUILD_TESTING=ON -DUSE_SANITIZER=$* $(CONFIGURE)" FRESH_CMAKE_CACHE=1
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_CMAKE_CACHE=1
test-clang-tidy:
$(MAKE) test-build CONFIGURE="-DBUILD_TESTING=ON -DUSE_CLANGTIDY=ON $(CONFIGURE)" FRESH_CMAKE_CACHE=1
test-export-mode:
$(MAKE) test-build-test-install CONFIGURE="-DBUILD_TESTING=ON -DVCPKG_EXPORT_MODE=ON $(CONFIGURE)" FRESH_CMAKE_CACHE=1
########################################################################################
# Documentation
########################################################################################
docs-clean:
cmake -E rm -rf docs/_build/html
docs-pip-requirements:
pip install -r docs/requirements.txt
docs-doxygen: cmake-build-template-ss-cpp-doxygen
docs: docs-pip-requirements docs-doxygen docs-clean
sphinx-build -T $(SPHINX_EXTRA_OPTS) -c docs docs docs/_build/html
docs-check:
$(MAKE) docs SPHINX_EXTRA_OPTS="--keep-going -W $(SPHINX_EXTRA_OPTS)"
docs-linkcheck:
$(MAKE) docs SPHINX_EXTRA_OPTS="-b linkcheck $(SPHINX_EXTRA_OPTS)"
docs-serve: docs-pip-requirements docs-doxygen docs-clean
python -m http.server --directory docs/_build/html &
watchfiles "make docs" docs src README.md LICENSE --ignore-paths docs/_build
########################################################################################
# Template
########################################################################################
template-watch:
watchfiles "make template-build" template includes copier.yml
template-build:
find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yml)$$' | xargs -I {} rm -r {}
copier copy -r HEAD --data-file includes/copier-answers-sample.yml $(COPIER_EXTRA_OPTS) -f . .
rm -rf .copier-answers.yml