-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·219 lines (165 loc) · 6.08 KB
/
Makefile
File metadata and controls
executable file
·219 lines (165 loc) · 6.08 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#! /usr/bin/make -f
# Makefile -*-makefile-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
INSTALL_PREFIX?=.install/
BUILD_DIR?=.build
DEST?=$(INSTALL_PREFIX)
CMAKE_FLAGS?=
TARGETS := test clean all ctest
export
.update-submodules:
git submodule update --init --recursive
touch .update-submodules
.gitmodules: .update-submodules
CONFIG?=Asan
export
ifeq ($(strip $(TOOLCHAIN)),)
_build_name?=build-system/
_build_dir?=.build/
_configuration_types?="RelWithDebInfo;Debug;Tsan;Asan;Gcov"
_cmake_args=-DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/etc/toolchain.cmake
else
_build_name?=build-$(TOOLCHAIN)
_build_dir?=.build/
_configuration_types?="RelWithDebInfo;Debug;Tsan;Asan;Gcov"
_cmake_args=-DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/etc/$(TOOLCHAIN)-toolchain.cmake
endif
_build_path?=$(_build_dir)/$(_build_name)
_build_path:=$(subst //,/,$(_build_path))
_build_path:=$(patsubst %/,%,$(_build_path))
define run_cmake =
cmake \
-G "Ninja Multi-Config" \
-DCMAKE_CONFIGURATION_TYPES=$(_configuration_types) \
-DCMAKE_INSTALL_PREFIX=$(abspath $(INSTALL_PREFIX)) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_PREFIX_PATH=$(CURDIR)/infra/cmake \
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="./cmake/use-fetch-content.cmake;infra/cmake/bemancmakeinstrumentation.cmake" \
$(_cmake_args) \
$(CURDIR)
endef
default: test
$(_build_path):
mkdir -p $(_build_path)
$(_build_path)/CMakeCache.txt: | $(_build_path) .gitmodules
cd $(_build_path) && $(run_cmake)
$(_build_path)/compile_commands.json : $(_build_path)/CMakeCache.txt
.PHONY: compile_commands.json
compile_commands.json:
if [ "$(shell readlink compile_commands.json)" != "$(_build_path)/compile_commands.json" ] ; then \
ln -sf $(_build_path)/compile_commands.json ; \
fi
TARGET:=all
compile: $(_build_path)/CMakeCache.txt
compile: compile_commands.json
compile: ## Compile the project
cmake --build $(_build_path) --config $(CONFIG) --target all -- -k 0
compile-headers: $(_build_path)/CMakeCache.txt ## Compile the headers
cmake --build $(_build_path) --config $(CONFIG) --target all_verify_interface_header_sets -- -k 0
install: $(_build_path)/CMakeCache.txt compile ## Install the project
cmake --install $(_build_path) --config $(CONFIG) --component beman.optional --verbose
.PHONY: clean-install
clean-install:
-rm -rf .install
realclean: clean-install
ctest: $(_build_path)/CMakeCache.txt ## Run CTest on current build
cd $(_build_path) && ctest --parallel --output-on-failure -C $(CONFIG)
ctest_ : compile
cd $(_build_path) && ctest --parallel --output-on-failure -C $(CONFIG)
test: ctest_ ## Rebuild and run tests
cmake: | $(_build_path)
cd $(_build_path) && ${run_cmake}
clean: $(_build_path)/CMakeCache.txt ## Clean the build artifacts
cmake --build $(_build_path) --config $(CONFIG) --target clean
realclean: ## Delete the build directory
rm -rf $(_build_path)
env:
$(foreach v, $(.VARIABLES), $(info $(v) = $($(v))))
.PHONY : compile install ctest ctest_ test cmake clean realclean env
.PHONY: papers
papers:
$(MAKE) -C papers/P2988 papers
.DEFAULT: $(_build_path)/CMakeCache.txt ## Other targets passed through to cmake
cmake --build $(_build_path) --config $(CONFIG) --target $@ -- -k 0
PYEXECPATH ?= $(shell which python3.13 || which python3.12 || which python3.11 || which python3.10 || which python3.9 || which python3.8 || which python3)
PYTHON ?= $(notdir $(PYEXECPATH))
VENV := .venv
ACTIVATE := . $(VENV)/bin/activate &&
PYEXEC := $(ACTIVATE) $(PYTHON)
MARKER=.initialized.venv.stamp
PIP := $(PYEXEC) -m pip
PIP_SYNC := $(PYEXEC) -m piptools sync
PIPTOOLS_COMPILE := $(PYEXEC) -m piptools compile --no-header --strip-extras
PRE_COMMIT := $(ACTIVATE) pre-commit
PHONY: venv
venv: ## Create python virtual env
venv: $(VENV)/$(MARKER)
.PHONY: clean-venv
clean-venv:
clean-venv: ## Delete python virtual env
-rm -rf $(VENV)
realclean: clean-venv
.PHONY: show-venv
show-venv: venv
show-venv: ## Debugging target - show venv details
$(PYEXEC) -c "import sys; print('Python ' + sys.version.replace('\n',''))"
$(PIP) --version
@echo venv: $(VENV)
requirements.txt: requirements.in
$(PIPTOOLS_COMPILE) --output-file=$@ $<
requirements-dev.txt: requirements-dev.in
$(PIPTOOLS_COMPILE) --output-file=$@ $<
$(VENV):
$(PYEXECPATH) -m venv $(VENV)
$(PIP) install pip setuptools wheel
$(PIP) install pip-tools
$(VENV)/$(MARKER): requirements.txt requirements-dev.txt | $(VENV)
$(PIP_SYNC) requirements.txt
$(PIP_SYNC) requirements-dev.txt
touch $(VENV)/$(MARKER)
.PHONY: dev-shell
dev-shell: venv
dev-shell: ## Shell with the venv activated
$(ACTIVATE) $(notdir $(SHELL))
.PHONY: bash zsh
bash zsh: venv
bash zsh: ## Run bash or zsh with the venv activated
$(ACTIVATE) exec $@
.PHONY: lint
lint: venv
lint: ## Run all configured tools in pre-commit
$(PRE_COMMIT) run -a
.PHONY: lint-manual
lint-manual: venv
lint-manual: ## Run all manual tools in pre-commit
$(PRE_COMMIT) run --hook-stage manual -a
.PHONY: coverage
coverage: ## Build and run the tests with the GCOV profile and process the results
coverage: venv $(_build_path)/CMakeCache.txt
$(ACTIVATE) cmake --build $(_build_path) --config Gcov
$(ACTIVATE) ctest --build-config Gcov --output-on-failure --test-dir $(_build_path)
$(ACTIVATE) cmake --build $(_build_path) --config Gcov --target process_coverage
.PHONY: view-coverage
view-coverage: ## View the coverage report
sensible-browser $(_build_path)/coverage/coverage.html
.PHONY: docs
docs: ## Build the docs with Doxygen
doxygen docs/Doxyfile
.PHONY: mrdocs
mrdocs: ## Build the docs with Doxygen
-rm -rf docs/adoc
cd docs && NO_COLOR=1 mrdocs mrdocs.yml 2>&1 | sed 's/\x1b\[[0-9;]*m//g'
find docs/adoc -name '*.adoc' | xargs asciidoctor
.PHONY: testinstall
testinstall: install
testinstall: ## Test the installed package
cmake -S installtest -B installtest/.build
cmake --build installtest/.build --target test
.PHONY: clean-testinstall
clean-testinstall:
-rm -rf installtest/.build
realclean: clean-testinstall
# Help target
.PHONY: help
help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[.a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort