-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (75 loc) · 2.57 KB
/
Makefile
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
# Makefile
MAKEFLAGS = -rR --no-print-directories --warn-undefined-variables
unexport MAKEFLAGS
.NOTPARALLEL:
CONFARGS ?=
GENERATOR = $(shell hash ninja 2>/dev/null && echo -GNinja)
TIME = $(shell hash time 2>/dev/null && echo time)
NICE = ionice -c 3 nice -n 40
RUN = $(shell \
hash systemd-notify 2>/dev/null && \
hash systemd-run 2>/dev/null && \
systemd-notify --booted && \
echo systemd-run --user -tdqp MemoryMax=10G)
# Path to build directory
BSUF ?= $(if $(value CC),$(CC),default)
B ?= ./_build/$(BSUF)
ARGS ?=
# Set to 1 to rerun failed only.
F ?=
# Regex filter to run only these tests
R ?=
ifneq ($(R),)
R_ALL_TARGETS = $(shell \
cd tests && printf "%s\n" *.c | \
sed 's/\.c//; s/.*/ckd_&_gnu\nckd_&_nognu/' )
TARGETS = $(shell <<<"$(R_ALL_TARGETS)" tr ' ' '\n' | grep "$(R)" | tr '\n' ' ' )
ifeq ($(TARGETS),)
$(error No CMake target found for $(R): $(R_ALL_TARGETS))
endif
endif
# The number of build jobs.
JOBS ?=
all: test
config:
$(NICE) cmake -S. -B$(B) -DCKD_DEV=1 --check-system-vars --log-context -Werror=dev -Wdev $(GENERATOR) $(CONFARGS) $(ARGS)
build: config
$(RUN) $(NICE) $(TIME) cmake --build $(B) -j $(JOBS) $(if $(value VERBOSE),--verbose) $(if $(value TARGETS),--target $(TARGETS))
gen: config
$(NICE) cmake --build $(B) --target ckdint_gen
test: build
cd $(B) && $(NICE) ctest $(if $(value R),-R "$R") $(if $F,--rerun-failed -j1) --output-on-failure $(ARGS)
wc $(B)/include/*.h $(B)/include/*/*.h
clean:
rm -rf $(B)
distclean:
rm -rf ./_build
lint: cpplint clang-tidy
cpplint:
$(NICE) cpplint \
--filter=-whitespace/tab,-runtime/int,-readability/casting,-readability/todo,-build/header_guard,-whitespace/comma,-whitespace/parens,-whitespace/braces,-whitespace/semicolon \
--linelength=150 \
gen/*.h gen/*/*.h
clang-tidy:
$(NICE) clang-tidy -p $(B) gen/*.h
coverage:
$(MAKE) BSUF=coverage ARGS=-DCKD_COVERAGE=1
gcovr -r $(PWD) -e test -f _build/coverage/include -j $$(nproc)
measure:
./scripts/measure.sh output
###############################################################################
see: gen
cat $(B)/include/ckdint.h
grep -C5 AA $(B)/include/*.h $(B)/include/*/*.h || true
shorttest: gen
gcc -xc -o $(B)/shorttest.out $(B)/include/ckdint.h
$(B)/shorttest.out
test_gcc: VERSION=11
test_gcc:
docker build --build-arg VERSION=$(VERSION) -f Dockerfile.gcc -t ckdint-gcc-$(VERSION) .
docker run -ti --rm -v $(PWD):/mnt -u $$(id -u):$$(id -g) -w /mnt ckdint-gcc-$(VERSION) \
make BSUF=docker-gcc-$(VERSION)
doxygen: CONFARGS = -DCKD_DOXYGEN=1
doxygen: BSUF = doxygen
doxygen: TARGETS = doxygen
doxygen: build