Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (59 loc) · 2.76 KB
/
Copy pathMakefile
File metadata and controls
78 lines (59 loc) · 2.76 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
CXX := clang++
CXXFLAGS := -std=c++23 -Wall -Wextra -Wpedantic -Wno-c2y-extensions -I.
BUILD := build
PYTHON := python3
HEADERS := dasmig/namegen.hpp dasmig/core.hpp $(wildcard dasmig/core/*.hpp)
EXAMPLE_SRC := examples/example.cpp
EXAMPLE_BIN := $(BUILD)/example
TEST_SRC := tests/tests.cpp tests/catch_amalgamated.cpp
TEST_BIN := $(BUILD)/test_runner
BENCH_SRC := bench/bench.cpp
BENCH_FLAGS := -O2 -DNDEBUG
COV_FLAGS := -fprofile-instr-generate -fcoverage-mapping
COV_DIR := coverage
.PHONY: all clean lint test bench bench-gate test-embed coverage docs embed
all: $(EXAMPLE_BIN)
$(EXAMPLE_BIN): $(EXAMPLE_SRC) $(HEADERS) | $(BUILD)
$(CXX) $(CXXFLAGS) -o $@ $(EXAMPLE_SRC)
$(TEST_BIN): $(TEST_SRC) $(HEADERS) | $(BUILD)
$(CXX) $(CXXFLAGS) -o $@ $(TEST_SRC)
test: $(TEST_BIN)
./$(TEST_BIN)
# The same tests with the lite tier compiled in (DASMIG_NAME_EMBED).
test-embed: $(TEST_SRC) $(HEADERS) dasmig/namegen_data.hpp | $(BUILD)
$(CXX) $(CXXFLAGS) -DDASMIG_NAME_EMBED -o $(BUILD)/test_embed $(TEST_SRC)
./$(BUILD)/test_embed
# Regenerate the compiled-in copy of the lite tier.
embed:
$(PYTHON) scripts/embed.py resources --tier lite --name namegen --output dasmig/namegen_data.hpp
# Benchmarks (bench/): an optimized build run on each tier, and again with
# the lite tier compiled in where the library has data. Results in
# build/bench.tsv.
bench: $(BENCH_SRC) bench/bench.hpp $(HEADERS) | $(BUILD)
rm -f $(BUILD)/bench.tsv
$(CXX) $(CXXFLAGS) $(BENCH_FLAGS) -o $(BUILD)/bench $(BENCH_SRC)
./$(BUILD)/bench --tier lite --out $(BUILD)/bench.tsv
./$(BUILD)/bench --tier full --out $(BUILD)/bench.tsv
$(CXX) $(CXXFLAGS) $(BENCH_FLAGS) -DDASMIG_NAME_EMBED -DDASMIG_BENCH_EMBEDDED -o $(BUILD)/bench_embed $(BENCH_SRC)
./$(BUILD)/bench_embed --tier lite --out $(BUILD)/bench.tsv
# The instruction-count gate: the benchmark in --gate mode under cachegrind,
# compared with bench/gate_baseline.txt (scripts/gate.py). Needs Valgrind.
bench-gate: $(BENCH_SRC) bench/bench.hpp $(HEADERS) | $(BUILD)
$(CXX) $(CXXFLAGS) $(BENCH_FLAGS) -o $(BUILD)/bench_gate $(BENCH_SRC)
$(PYTHON) scripts/gate.py $(BUILD)/bench_gate
coverage: $(TEST_SRC) $(HEADERS) | $(BUILD)
$(CXX) $(CXXFLAGS) $(COV_FLAGS) -o $(BUILD)/test_cov $(TEST_SRC)
cd $(BUILD) && ./test_cov
llvm-profdata merge -sparse $(BUILD)/default.profraw -o $(BUILD)/tests.profdata
llvm-cov report $(BUILD)/test_cov --instr-profile=$(BUILD)/tests.profdata --sources $(HEADERS)
llvm-cov show $(BUILD)/test_cov --instr-profile=$(BUILD)/tests.profdata --sources $(HEADERS) --format=html -o $(COV_DIR)
@echo "Coverage report: $(COV_DIR)/index.html"
$(BUILD):
@mkdir -p $(BUILD)
docs:
doxygen Doxyfile
@echo "API docs: doc/api/html/index.html"
lint:
clang-tidy $(EXAMPLE_SRC) -- $(CXXFLAGS)
clean:
rm -rf $(BUILD) $(COV_DIR) doc/api