-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (51 loc) · 2.1 KB
/
Makefile
File metadata and controls
67 lines (51 loc) · 2.1 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
SHELL := /bin/bash
SRCS = $(shell find src test demo -name '*.h' -o -name '*.cc')
.PHONY: all demo test coverage coverage-html check doc clean
BUILD = build
BUILD_COV = build-cov
COV_OUT = coverage-html
all: $(BUILD)/CMakeCache.txt
cmake --build $(BUILD) -- -s
run-demo: all
$(BUILD)/dvrlib_demo
run-demo-zalg: all
$(BUILD)/dvrlib_demo --keep-free
run-demo-compare: all
@diff --width=160 -y <($(BUILD)/dvrlib_demo) <($(BUILD)/dvrlib_demo --keep-free) || true
run-tests: all
@$(BUILD)/dvrlib_test
run-coverage: $(BUILD_COV)/CMakeCache.txt
cmake --build $(BUILD_COV) -- -s
$(BUILD_COV)/dvrlib_test
@cd $(BUILD_COV)/CMakeFiles/dvrlib.dir/src && \
gcov *.gcno 2>/dev/null \
| awk '/File.*\/src\/[^/]+\.cc/{f=1; print} f && /Lines executed/{print; f=0}'; \
rm -f *.gcov 2>/dev/null || true
run-coverage-html: $(BUILD_COV)/CMakeCache.txt
@which lcov > /dev/null 2>&1 || { echo "lcov not found. Install with: sudo apt install lcov"; exit 1; }
cmake --build $(BUILD_COV) -- -s
$(BUILD_COV)/dvrlib_test
lcov --capture --directory $(BUILD_COV) --output-file $(BUILD_COV)/coverage.info
lcov --remove $(BUILD_COV)/coverage.info '*/build-cov/_deps/*' '/usr/*' --output-file $(BUILD_COV)/coverage.info
genhtml $(BUILD_COV)/coverage.info --output-directory $(COV_OUT)
@echo "================================================="
@echo "Report written to: $(COV_OUT)/index.html"
$(BUILD)/CMakeCache.txt:
cmake -B $(BUILD) -S . -DCMAKE_BUILD_TYPE=Debug
$(BUILD_COV)/CMakeCache.txt:
cmake -B $(BUILD_COV) -S . -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage"
check: $(BUILD)/CMakeCache.txt
# Commented out, clang-tidy reports too much (sometimes dangerous) nonsense
# @echo "--- clang-tidy ---"
# @find src test demo -name '*.cc' | xargs clang-tidy -p $(BUILD)
@echo "--- clang-format ---"
@clang-format --dry-run --Werror $(SRCS) && echo "format OK"
format_source:
@echo "--- clang-format ---"
@clang-format $(SRCS) -i --verbose
doc: $(BUILD)/CMakeCache.txt
cmake --build $(BUILD) --target doc
clean:
rm -rf $(BUILD) $(BUILD_COV) $(COV_OUT)