-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (49 loc) · 1.94 KB
/
Makefile
File metadata and controls
65 lines (49 loc) · 1.94 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
SHELL := bash
.PHONY: all configure build test clean coverage coverage-setup sanitize \
format format-check install-hooks
BUILD_DIR := build
COVERAGE_DIR := build-coverage
SANITIZE_DIR := build-sanitize
VENV := coverage/.venv
GCOVR := $(VENV)/bin/gcovr
# Native build. TwkPaint is a geometry library — the WASM build is handled
# by OpenRV-annotation-wasm, which consumes this repo as a submodule.
all: build
configure:
cmake -B $(BUILD_DIR) -G Ninja
build: configure
cmake --build $(BUILD_DIR)
test: build
ctest --test-dir $(BUILD_DIR) --output-on-failure
# Create the venv and install coverage tools. Reruns only when
# requirements.txt changes (gcovr binary acts as the sentinel).
coverage-setup: $(GCOVR)
$(GCOVR): coverage/requirements.txt
python3 -m venv $(VENV)
$(VENV)/bin/pip install --quiet --upgrade pip
$(VENV)/bin/pip install --quiet -r coverage/requirements.txt
# Build with --coverage, run tests, and generate an HTML report.
coverage: coverage-setup
cmake -B $(COVERAGE_DIR) -G Ninja -DENABLE_COVERAGE=ON
cmake --build $(COVERAGE_DIR)
ctest --test-dir $(COVERAGE_DIR) --output-on-failure
mkdir -p coverage/report
$(GCOVR) --config coverage/gcovr.cfg
# Sanitize: builds with AddressSanitizer + UBSanitizer and runs tests.
sanitize:
cmake -B $(SANITIZE_DIR) -G Ninja -DENABLE_SANITIZERS=ON
cmake --build $(SANITIZE_DIR)
ctest --test-dir $(SANITIZE_DIR) --output-on-failure
CPP_SOURCES := $(shell find TwkMath TwkPaint tests -name '*.cpp' -o -name '*.h')
# Format all C++ sources in-place.
format:
clang-format -i $(CPP_SOURCES)
# Check formatting without modifying files (used in CI and the pre-commit hook).
format-check:
clang-format --dry-run --Werror $(CPP_SOURCES)
# Symlink the pre-commit hook into .git/hooks so it runs automatically.
install-hooks:
ln -sf ../../hooks/pre-commit .git/hooks/pre-commit
@echo "pre-commit hook installed."
clean:
rm -rf $(BUILD_DIR) $(COVERAGE_DIR) $(SANITIZE_DIR) $(VENV) coverage/report/