-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
77 lines (63 loc) · 1.96 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
# Author: Matt Williams <[email protected]>
SHELL:=$(shell command -v sh)
DEVKIT:=python3 dev-scripts/devkit.py
define _list =
cat << EOF
==============================
| Command || Description |
==============================
list -- Lists all available commands
rel -- Builds release mode with all optimization flags
dev -- Builds debugging mode with all unit tests and examples
format -- Recursively runs clang-format all legal cmake and source files
tidy -- Runs clang-tidy on on all legal source files
test -- Runs ctest on the test suite
install -- Installs optimized binaries, libraries, files and scripts
uninstall -- Uninstalls all binararies, libraries, files and scripts
clean -- Cleans all build artifacts
EOF
endef
define _uninstall =
if [ ! -d build ] || [ ! -f build/install_manifest.txt ]; then
echo "Cannot uninstall, no build folder found or no install_manifest.txt file found"
echo "Try running => make install"
exit 1
else
# xargs is linux only.
echo "Removing installed files.."
cat build/install_manifest.txt
sudo xargs rm < build/install_manifest.txt
echo
fi
endef
define _clean =
echo "Cleaning build artifacts.."
[ -d build ] && rm -rf build
[ -d build-debug ] && rm -rf build-debug
[ -d build-release ] && rm -rf build-release
echo
endef
list:
@$(call _list)
# Build in release mode, full optimizations, no debugging
rel:
@${DEVKIT} build --release
# Build in debugging mode with all debugging symbols, unit tests and examples.
dev:
@${DEVKIT} build --develop
# format recursively with clang-format
format:
@${DEVKIT} clang --format
# Statically analyze with clang-tidy
tidy:
@${DEVKIT} clang --tidy
test: dev
ctest --output-on-failure --test-dir build
install: rel
@sudo cmake --install build
uninstall:
@$(call _uninstall)
clean:
@$(call _clean)
.ONESHELL:
.Phony: list rel dev format tidy test install uninstall clean