Repository navigation
Expand file tree
/
Copy pathGNUmakefile
More file actions
109 lines (90 loc) · 3.05 KB
/
Copy pathGNUmakefile
File metadata and controls
109 lines (90 loc) · 3.05 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
# Standard stuff
.SUFFIXES:
MAKEFLAGS+= --no-builtin-rules
MAKEFLAGS+= --warn-undefined-variables
export hostSystemName=$(shell uname)
export GCOV=llvm-cov gcov
export CPM_USE_LOCAL_PACKAGES=YES
ifeq (${hostSystemName},Darwin)
export LLVM_PREFIX:=$(shell brew --prefix llvm)
export LLVM_DIR?=$(shell realpath ${LLVM_PREFIX})
export PATH:=${LLVM_DIR}/bin:${PATH}
export CXX:=clang++
# to test g++-15:
#XXX export CXX:=g++-15
#XXX export CXXFLAGS:=-stdlib=libstdc++
else ifeq (${hostSystemName},Linux)
export LLVM_DIR?=/usr/lib/llvm-19
export PATH:=${LLVM_DIR}/bin:${PATH}
export CXX:=clang++-19
endif
CPPFILES:= $(shell git ls-files ::*.cpp | grep -vw tests)
PRESET_NAME?=debug
BUILD_DIR:=build/$(PRESET_NAME)
.PHONY: all format test check distclean
all: $(BUILD_DIR)
cmake --workflow --preset $(PRESET_NAME)
clean: $(BUILD_DIR)
-ninja -C $< $@
-find $< -name '*.gcda' -delete
distclean: # XXX clean
rm -rf $(BUILD_DIR) build coverage/* *~ ctags
$(BUILD_DIR): CMakeLists.txt
-test -f CMakeUserPresets.json || ln -f -s cmake/CMakeUserPresets.json .
cmake --preset $(PRESET_NAME) --log-level=VERBOSE # --fresh
# -test -d build/Debug && ln -f -s $(CURDIR)/build/Debug $(CURDIR)/$(BUILD_DIR)
check: all
run-clang-tidy -p $(BUILD_DIR) $(CPPFILES)
fix: all
run-clang-tidy -p $(BUILD_DIR) -fix -checks='-*,\
hicpp-explicit-conversions,\
hicpp-member-init,\
hicpp-named-parameter,\
modernize-deprecated-headers,\
modernize-loop-convert,\
modernize-return-braced-init-list,\
modernize-use-nodiscard,\
modernize-use-std-print,\
modernize-use-trailing-return-type,\
performance-avoid-endl,\
performance-unnecessary-value-param,\
readability-avoid-const-params-in-decls,\
readability-braces-around-statements,\
readability-container-data-pointer,\
readability-container-size-empty,\
-readability-convert-member-functions-to-static,\
readability-else-after-return,\
readability-identifier-naming,\
readability-implicit-bool-conversion,\
readability-make-member-function-const,\
readability-redundant-member-init,\
readability-simplify-boolean-expr,\
readability-static-accessed-through-instance,\
readability-use-concise-preprocessor-directives,\
readability-use-std-min-max,\
' \
$(CPPFILES)
test: all
# NOTE: simple examples only!
# $(BUILD_DIR)/async_tcp_echo_server 8000
# cat rrcp.txt | $(BUILD_DIR)/async_tcp_echo_client localhost 8000
# -$(BUILD_DIR)/ async_tcp_echo_client localhost
# -echo | $(BUILD_DIR)/async_tcp_echo_client localhost 8001
# -killall async_tcp_echo_server
ctest --test-dir $(BUILD_DIR) --rerun-failed --output-on-failure
gcovr
format: .clang-format
-codespell
git ls-files ::*.cpp ::*.hpp ::*.json | xargs clang-format -i
git ls-files ::*CMakeLists.txt | xargs gersemi -i --no-warn-about-unknown-commands
git ls-files ::*.py | xargs black
# These rules keep make from trying to use the match-anything rule below
# to rebuild the makefiles--ouch!
CMakeLists.txt :: ;
GNUmakefile :: ;
.clang-tidy :: ;
.clang-format :: ;
# Anything we don't know how to build will use this rule. The command is
# a do-nothing command.
% :: $(BUILD_DIR)
ninja -C $< $@