-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
165 lines (112 loc) · 4.88 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# ------------------------------------------------------------------------------------------ Macros
CXX := g++
CXXFLAGS := -Wall -Wextra -Werror -pedantic -std=c++17 -g
SYSFLAGS := -lgtest -lstdc++
ifeq ($(shell uname), Linux)
SYSFLAGS += -pthread -lrt -lm
endif
GRAPH_SOURCES := src/graph/graph.cpp
GRAPH_OBJECTS := graph.o
ALGORITMS_SOURCES := src/algorithms/algorithms.cpp
ALGORITMS_OBJECTS := algorithms.o
COMMON_SOURCES := $(GRAPH_SOURCES) \
$(ALGORITMS_SOURCES)
MATRIX_TEST_SOURCES := tests/unit/matrix/test_matrix.cpp
GRAPH_TEST_SOURCES := tests/unit/graph/test_graph.cpp
CONTAINERS_TEST_SOURCES := tests/unit/containers/test_priority_queue.cpp \
tests/unit/containers/test_queue.cpp \
tests/unit/containers/test_stack.cpp \
ALGORITMS_TEST_SOURCES := tests/unit/algorithms/test_algorithms.cpp
COMMON_TEST_SOURCES := $(MATRIX_TEST_SOURCES) \
$(CONTAINERS_TEST_SOURCES) \
$(GRAPH_TEST_SOURCES) \
$(ALGORITMS_TEST_SOURCES)
CLI_SOURCES := gui/cli/cli.cpp \
gui/cli/main.cpp
APP := SimpleNavigator
# ----------------------------------------------------------------------------------------- Targets
.PHONY: all
all: test
.PHONY: help
help:
@grep -E '^[a-zA-Z0-9 - _]+:.*#' Makefile | sort | while read -r l; do \
printf "\033[1;5m\033[1;33m$$(echo $$l | cut -f 1 -d':')\033[00m: $$(echo $$l | cut -f 2- -d'#').\n"; done
.PHONY: docker
docker:
./tests/docker/run.sh
# ------------------------------------------------------------------------------------- Application
.PHONY: install
install: #install the console application
$(CXX) $(CXXFLAGS) $(COMMON_SOURCES) $(CLI_SOURCES) -o $(APP)
.PHONY: unistall
unistall: #unistall the console application
- rm $(APP)
# ------------------------------------------------------------------------------------------- Tests
.PHONY: gcov_report
gcov_report: test # checks the coverage of the project libraries
@ lcov -t "SimpleNavigator" -o SimpleNavigator.info -c -d . --no-external
@ genhtml -o gcov_report SimpleNavigator.info
- rm -rf *.gcno *.gcda *.info
open gcov_report/index.html
.PHONY: test
test: #testing of all project sources
$(CXX) $(CXXFLAGS) --coverage $(COMMON_SOURCES) $(COMMON_TEST_SOURCES) \
tests/unit/main.cpp -o test $(SYSFLAGS) && ./test
.PHONY: test_algorithms
test_algorithms: #testing of GraphAlgorithms class
$(CXX) $(CXXFLAGS) --coverage $(ALGORITMS_TEST_SOURCES) $(ALGORITMS_SOURCES) $(GRAPH_SOURCES) \
tests/unit/main.cpp -o test_algorithms $(SYSFLAGS) && ./test_algorithms
.PHONY: test_graph
test_graph: #testing of Graph class
$(CXX) $(CXXFLAGS) --coverage $(GRAPH_TEST_SOURCES) $(GRAPH_SOURCES) \
tests/unit/main.cpp -o test_graph $(SYSFLAGS) && ./test_graph
.PHONY: test_containers
test_containers: #testing of container classes
$(CXX) $(CXXFLAGS) --coverage $(CONTAINERS_TEST_SOURCES) \
tests/unit/main.cpp -o test_containers $(SYSFLAGS) && ./test_containers
.PHONY: test_matrix
test_matrix: #testing of Matrix class
$(CXX) $(CXXFLAGS) --coverage $(MATRIX_TEST_SOURCES) \
tests/unit/main.cpp -o test_matrix $(SYSFLAGS) && ./test_matrix
# ---------------------------------------------------------------------------------------- Archives
.PHONY: s21_graph
s21_graph: $(GRAPH_OBJECTS) #creatating a Graph class archive
ar src s21_graph.a $? && rm -rf $?
$(GRAPH_OBJECTS): $(GRAPH_SOURCES)
$(CXX) $(CXXFLAGS) -c $? -o $@
.PHONY: s21_graph_algorithms
s21_graph_algorithms: $(ALGORITMS_OBJECTS) #creating a GraphAlgorithm class archive
ar src s21_graph_algorithms.a $? && rm -rf $?
$(ALGORITMS_OBJECTS): $(ALGORITMS_SOURCES)
$(CXX) $(CXXFLAGS) -c $? -o $@
# -------------------------------------------------------------------------------------- Components
.PHONY: boost_program_options
boost_program_options: #installing libboost-program-options-dev for console application
sudo apt update && sudo apt install -y libboost-program-options-dev
.PHONY: install_doxygen
install_doxygen: #installing Doxygen
sudo apt update && sudo apt-get doxygen
# ----------------------------------------------------------------------------------------- Linters
.PHONY: style
style: #checking code for Google style
find . \( -name "*.h" -o -name "*.c" -o -name "*.hpp" -o -name "*.cpp" \) -print0 \
| xargs --null clang-format -n --style=Google
cppcheck:
cppcheck --enable=all --force --suppress=missingIncludeSystem --language=c++ \
$(GRAPH_SOURCES) $(ALGORITMS_SOURCES)
.PHONY: leaks
leaks: #checking code for leaks using Valgrind utility
valgrind --tool=memcheck --track-fds=yes --quiet --trace-children=yes \
--track-origins=yes --leak-check=full --show-leak-kinds=all -s ./test
# ------------------------------------------------------------------------------- Abstracts Targets
clean:
- rm test
- rm test_graph
- rm test_containers
- rm test_algorithms
- rm test_matrix
- rm *.dot
- rm -rf gcov_report
- rm *.gcno *.gcda *.info
- rm -rf dvi/doxygen
rebuild: clean all