-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (149 loc) · 5.42 KB
/
Makefile
File metadata and controls
164 lines (149 loc) · 5.42 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
default: build test
################################################################
#
# Run all tests, checks, generate docs, generate man pages,
# ..., etc.
#
# This should always be run before pushing changes to the
# server.
#
################################################################
.PHONY: full_build # Build all targets, run tests, generate docs, ..., etc.
full_build: cppcheck clean build test examples man_pages doxygen coverage memcheck
################################################################
#
# Run static code checks on C++ code
#
################################################################
.PHONY: cppcheck # Run cppcheck
cppcheck:
@echo "Running cppcheck..."
@cppcheck --std=c++23 --language=c++ --enable=all \
-q --error-exitcode=255 \
-I . -I apps -I examples \
--inline-suppr \
--suppress=missingIncludeSystem \
--suppress=useStlAlgorithm \
apps/*/*.cpp
################################################################
#
# Run cmake when CMakeLists.txt changes
#
################################################################
./build/debug/Makefile: CMakeLists.txt
@echo "Running cmake..."
@mkdir -p build/debug
@mkdir -p build/release
@mkdir -p build/coverage
@cd build/debug && cmake -DCMAKE_BUILD_TYPE=Debug ../..
@cd build/release && cmake -DCMAKE_BUILD_TYPE=Release ../..
@cd build/coverage && cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_COVERAGE=ON ../..
################################################################
#
# Compile applications and tests
#
################################################################
.PHONY: build # Compile all applications and tests
build: ./build/debug/Makefile
cd build/debug && make -j 8
cd build/release && make -j 8
cd build/coverage && make -j 8
################################################################
#
# Delete all build objects
#
################################################################
.PHONY: clean # Clean build objects
clean:
@echo "Cleaning..."
@rm -rf build
@rm -rf doc
@$(MAKE) -C examples clean
################################################################
#
# Tests
#
################################################################
.PHONY: unit_and_app_test
unit_and_app_test: BUILD=debug
unit_and_app_test:
@parallel --jobs 24 --halt now,fail=1 "echo {} && {}" ::: build/$(BUILD)/test_*
.PHONY: integration_test
integration_test: BUILD=debug
integration_test:
@parallel --jobs 24 --halt now,fail=1 \
"echo $(BUILD): {} && PATH=./build/$(BUILD)/:$$PATH {}" ::: tests/integration/test_*.sh
.PHONY: test # Run tests
test:
@echo "Testing..."
@$(MAKE) --no-print-directory unit_and_app_test BUILD=debug
@$(MAKE) --no-print-directory unit_and_app_test BUILD=release
@$(MAKE) --no-print-directory integration_test BUILD=debug
@$(MAKE) --no-print-directory integration_test BUILD=release
################################################################
#
# Run valgrind to check for memory leaks and other issues
#
################################################################
.PHONY: memcheck # Run memcheck
memcheck:
@echo "Running memchecks..."
@parallel --jobs 24 --halt now,fail=1 \
"echo {} && valgrind --leak-check=full --error-exitcode=1 --quiet --suppressions=valgrind.suppressions {}" ::: build/debug/test_*
@parallel --jobs 24 --halt now,fail=1 \
"echo {} && valgrind --leak-check=full --error-exitcode=1 --quiet --suppressions=valgrind.suppressions {}" ::: build/release/test_*
################################################################
#
# Run gcov to generate a coverage report
#
################################################################
.PHONY: coverage # Generate a coverage report
coverage: build
@$(MAKE) --no-print-directory unit_and_app_test BUILD=coverage
@mkdir -p ./code_analysis
@echo "Running gcovr..."
@cd build/coverage/ && gcovr -r ../.. \
--filter=../../spoc/ \
--filter=../../apps/ \
--exclude='(.+)?_cmd.h$$' \
--exclude='../../apps/(.+)?.cpp$$' \
. | tee ../../code_analysis/coverage.txt
@grep TOTAL code_analysis/coverage.txt
.PHONY: examples # Build examples
examples:
@$(MAKE) -C examples
################################################################
#
# Documentation
#
################################################################
.PHONY: doxygen # Generate documentation
doxygen:
SPOC_PROJECT_NUMBER=$(git rev-parse --short HEAD) doxygen Doxyfile
.PHONY: man_pages # Generate man pages
man_pages:
@mkdir -p build/man
@find apps/*/*.md | xargs --verbose -P 8 -I {} bash -c 'pandoc -s -t man {} -o build/man/spoc_`basename {} .md`'
################################################################
#
# Install applications and man pages
#
# For this local installation to work, you must ensure that
# ~/.local/bin is in your path.
#
# To access the man pages, you also must ensure that
# ~/.local/share/man is in your manpath. You can check your
# manpath with the `manpath` command.
#
################################################################
.PHONY: install_local # Install applications and man pages to ~/.local directory
install_local: build man_pages
@mkdir -p $$HOME/.local/bin
@echo Installing applications to $$HOME/.local/bin
@install ./build/release/spoc_* $$HOME/.local/bin
@mkdir -p $$HOME/.local/share/man/man1
@echo Copying man pages to $$HOME/.local/share/man/man1
@cp ./build/man/spoc_*.1 $$HOME/.local/share/man/man1
.PHONY: help # Generate list of targets with descriptions
help:
@grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20