-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (112 loc) · 3.34 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
NAME = a.out
CXX = clang++
CXXFLAGS = -Wall -Werror -Wextra -Wshadow -MMD -MP -std=c++98 -I$(includes) -g
srcsdir = ./srcs
includes = ./includes
srcs = $(srcsdir)/main.cpp
objs = $(srcs:.cpp=.o)
depends = $(objs:.o=.d)
.PHONY: all
all: $(NAME)
$(NAME): $(objs)
$(CXX) $(CXXFLAGS) -o $(NAME) $(objs)
.PHONY: clean
clean:
$(RM) $(objs) $(objs) $(NAME)
$(RM) -rf *.dSYM
$(RM) -rf tester
$(RM) -rf *.gcda
$(RM) -rf *.gcno
$(RM) -rf *.info
$(RM) -rf tester.dSYM
$(RM) -rf *_exe
$(RM) -rf benchmark
$(RM) -rf *.log
$(RM) -rf *.d
$(RM) -rf *.o
$(RM) -rf a.out
$(RM) -rf *.csv
.PHONY: fclean
fclean: clean
$(RM) -rf $(NAME)
.PHONY: re
re: fclean all
gtestdir = ./test
gtest = $(gtestdir)/gtest $(gtestdir)/googletest-release-1.11.0
gbench = $(gtestdir)/benchmark
testdir = ./gtest
benchdir = ./gbench
$(gtest):
mkdir -p $(dir ../test)
curl -OL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
tar -xvzf release-1.11.0.tar.gz googletest-release-1.11.0
$(RM) -rf release-1.11.0.tar.gz
python3 googletest-release-1.11.0/googletest/scripts/fuse_gtest_files.py $(gtestdir)
mv googletest-release-1.11.0 $(gtestdir)
test_compile = clang++ -std=c++11 \
$(testdir)/gtest.cpp $(gtestdir)/googletest-release-1.11.0/googletest/src/gtest_main.cc $(gtestdir)/gtest/gtest-all.cc \
-g -fsanitize=address -fsanitize=undefined -fsanitize=leak \
-I$(gtestdir) -I/usr/local/opt/llvm/include -I$(includes) -lpthread -o tester
.PHONY: test
test: $(gtest) fclean
$(test_compile)
./tester # --gtest_filter=Vector.other
.PHONY: test_std
test_std: $(gtest) fclean
$(test_compile) -DLIB=std
./tester # --gtest_filter=Vector.other
mytest_compile = $(CXX) -Wall -Werror -Wextra -Wshadow -std=c++98 gtest/testlib_main.cpp -I$(includes) -I$(gtestdir)
.PHONY: mytest
mytest:
$(mytest_compile) -o mytest_exe
./mytest_exe
.PHONY: mytest_std
mytest_std:
$(mytest_compile) -DLIB=std -o mytest_std_exe
./mytest_std_exe
.PHONY: cave
cave: $(gtest) fclean
clang++ -std=c++11 -O0 $(testdir)/gtest.cpp $(gtestdir)/googletest-release-1.11.0/googletest/src/gtest_main.cc $(gtestdir)/gtest/gtest-all.cc \
-I$(gtestdir) -I/usr/local/opt/llvm/include -I$(includes) -lpthread -o tester -fprofile-arcs -ftest-coverage
./tester
lcov -c -b . -d . -o cov_test.info
lcov -r cov_test.info "*gtest*" -o cov_test.info
genhtml cov_test.info -o cov_test
$(RM) -rf cov_test.info
$(RM) -rf tester
$(RM) -rf *.gcda
$(RM) -rf *.gcno
$(RM) -rf *.info
$(RM) -rf tester.dSYM
open cov_test/index-sort-f.html
benchflg = clang++ -std=c++11 -O2
benchflg2 = $(benchdir)/gbench.cpp \
-isystem $(gbench)/include \
-L$(gbench)/build/src -lbenchmark -lpthread \
-I$(gtestdir) -I/usr/local/opt/llvm/include -I$(includes) -I$(benchdir) -o benchmark
.PHONY: bench
bench:
$(benchflg) \
$(benchflg2) \
-DUSE_LIB=ft
./benchmark \
--benchmark_out_format=csv \
--benchmark_out=benchmark.csv # --benchmark_filter=BM_VectorInsert_input_iterator
.PHONY: bench_std
bench_std:
$(benchflg) \
$(benchflg2) \
-DUSE_LIB=std
./benchmark \
--benchmark_out_format=csv \
--benchmark_out=benchmark_std.csv # --benchmark_filter=BM_VectorInsert_input_iterator
mybenchflg = @$(CXX) $(CXXFLAGS) -o mybenchmark_exe mybenchmark/mybench.cpp -I$(includes) -O0
.PHONY: mybench
mybench:
$(mybenchflg)
@./mybenchmark_exe
.PHONY: mybench_std
mybench_std:
$(mybenchflg) -DLIB=std
@./mybenchmark_exe
-include $(depends)