-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (44 loc) · 1.79 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
CXX=g++
CPPFLAGS=-std=c++11 -Wall -Weffc++ -Wextra -Wshadow -Wwrite-strings -Werror -Wno-pragmas
CPPFLAGS+=-Wpedantic -pedantic-errors -Wdisabled-optimization
CPPFLAGS+=-Wcast-align -Wcast-qual
CPPFLAGS+=-Wfloat-equal -Wformat=2
CPPFLAGS+=-Wmissing-declarations -Wmissing-include-dirs
CPPFLAGS+=-Wpointer-arith -Wredundant-decls -Wsequence-point
CPPFLAGS+=-Wswitch -Wundef -Wunreachable-code
CPPFLAGS+=-Wunused-but-set-parameter -Wwrite-strings -Wctor-dtor-privacy
CPPFLAGS+=-fno-optimize-sibling-calls -fprofile-arcs -ftest-coverage -O0 -g
CPPFLAGS+=-fsanitize=address -fsanitize-address-use-after-scope -fsanitize=undefined
CPPFLAGS+=-fno-inline
CPPFLAGS+=-Winit-self -Wold-style-cast -Woverloaded-virtual
CPPFLAGS+=-Wsign-conversion -Wno-sign-promo
CPPFLAGS+=-Wstrict-overflow=5 -Wswitch-default -Wunused
SOURCEDIR=src/tests
OUTPUTDIR=bin
SOURCES=$(wildcard $(SOURCEDIR)/test_*.cpp)
TESTS=$(subst test_,,$(basename $(notdir $(SOURCES))))
define HANDLE_TEST
$(OUTPUTDIR)/$(1)/$(1):$(SOURCEDIR)/test_$(1).cpp
@echo
@mkdir -p $(OUTPUTDIR)/$(1)
@echo "$(SOURCEDIR)/test_$(1).cpp -> $(OUTPUTDIR)/$(1)/$(1)"
@$(CXX) $(SOURCEDIR)/test_$(1).cpp $(CPPFLAGS) -o $(OUTPUTDIR)/$(1)/$(1)
$(1):$(OUTPUTDIR)/$(1)/$(1)
@echo
@./$(OUTPUTDIR)/$(1)/$(1)
@gcov $(OUTPUTDIR)/$(1)/*.gcno > $(OUTPUTDIR)/$(1)/$(1).log
@mv *.gcov $(OUTPUTDIR)/$(1)/
@awk '/inline/ { found=1; next } found' bin/yalo/$(1).h.gcov \
| grep '[A-Za-z]' \
| grep -Ev ':[[:space:]]*[0-9]+:[[:space:]]*#' > bin/$(1)_executable.txt
@cat bin/$(1)_executable.txt | grep -Ev '^\s*[0-9]+:' > bin/$(1)_unexecuted.txt
@cat bin/$(1)_unexecuted.txt
@wc -l bin/$(1)_executable.txt bin/$(1)_unexecuted.txt
endef
$(foreach test,$(TESTS),$(eval $(call HANDLE_TEST,$(test))))
# Default target
test: $(TESTS)
clean:
@$(CXX) --version
@gcov --version
@rm -Rf $(OUTPUTDIR)