-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (45 loc) · 1.82 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
CFLAGS_DEBUG = -g -fprofile-arcs -ftest-coverage
CFLAGS_RELEASE = -O3 -DNDEBUG
CFLAGS = -std=c99 -pedantic -Wall -Wno-override-init -Wno-unused-function -Werror
IMPL_HEADERS = ./arr/arr.h ./vec/vec.h ./heap/heap.h ./mem/pool/pool.h ./map/map.h ./set/set.h ./llist/llist.h
IMPL_SRCS = ./vec/vec.c ./heap/heap.c ./mem/pool/pool.c ./map/map.c ./set/set.c ./llist/llist.c
IMPL_OBJS = $(patsubst ./%.c,./%.o,$(IMPL_SRCS))
TEST_SRCS = ./test/test_arr.c ./test/test_vec.c ./test/test_heap.c ./test/test_map.c ./test/test_mem_pool.c ./test/test_set.c ./test/test_util.c ./test/test_llist.c
TEST_OBJS = $(patsubst ./%.c,./%.o,$(TEST_SRCS))
libds.a: $(IMPL_OBJS)
ar -rc libds.a $(IMPL_OBJS)
$(IMPL_OBJS): ./%.o: ./%.c ./%.h
$(CC) $(CFLAGS) $(CFLAGS_RELEASE) -c -o $@ $<
$(TEST_OBJS): test/%.o: test/%.c
$(CC) $(CFLAGS) $(CFLAGS_DEBUG) -c -o $@ $<
test/test: $(TEST_SRCS) $(IMPL_SRCS) $(IMPL_HEADERS) clean-coverage
$(CC) $(CFLAGS) $(CFLAGS_DEBUG) -Wno-c11-extensions -o test/test test/test.c $(TEST_SRCS) test/munit/munit.c -lm
.PHONY: test
test: test/test
./test/test
.PHONY: coverage
coverage: test
gcovr -s \
--exclude-lines-by-pattern '\s*assert\(.*' \
--exclude-unreachable-branches \
--html-details ./coverage/coverage.html \
--exclude test/test.c \
--exclude test/munit/munit.c \
$(foreach src,$(patsubst ./test/%.c,test/%.c,$(TEST_SRCS)),--exclude $(src))
xdg-open ./coverage/coverage.html
# Remove all previous coverage data
.PHONY: clean-coverage
clean-coverage:
find . -name '*.gcda' -delete;
rm -f ./coverage/*
.PHONY: clean
clean: clean-coverage
find . -name '*.gcno' -delete
find . -name '*.o' -delete;
rm -f ./test/test
rm -f ./libds.a
.PHONY: format
format: $(IMPL_SRCS) $(TEST_SRCS) $(IMPL_HEADERS) ./test/test.c
clang-format -style=file -i $(IMPL_SRCS) $(TEST_SRCS) $(IMPL_HEADERS) ./test/test.c
.PHONY: run
run: test