This repository was archived by the owner on Apr 17, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
162 lines (134 loc) · 5.61 KB
/
Makefile
File metadata and controls
162 lines (134 loc) · 5.61 KB
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
# Revision History -- at the bottom of the document
################################################################################
# The targets in this file are used in .gitlab-ci.yml and the files created
# are found in the .gitignore
################################################################################
# Changing any names below can change the target names which will require that
# you update .gitlab_ci.yml and .gitignore
################################################################################
################################################################################
# Variable definitions
################################################################################
# Executable names
PROJECT = project
GTEST = test_${PROJECT}
# Compilation command and flags
CXX=g++
CXXVERSION= -std=c++14
CXXFLAGS= ${CXXVERSION} -g
CXXWITHCOVERAGEFLAGS = ${CXXFLAGS} -fprofile-arcs -ftest-coverage
LINKFLAGS= -lgtest
# Directories
SRC_DIR = src
PROJECT_SRC_DIR = src/project
GTEST_DIR = test
SRC_INCLUDE = include
INCLUDE = -I ${SRC_INCLUDE}
# Tool variables
GCOV = gcov
LCOV = lcov
COVERAGE_RESULTS = results.coverage
COVERAGE_DIR = coverage
STATIC_ANALYSIS = cppcheck
STYLE_CHECK = cpplint
DESIGN_DIR = docs/design
DOXY_DIR = docs/code
################################################################################
# Targets
################################################################################
# Default goal
.DEFAULT_GOAL := compileProject
################################################################################
# Clean-up targets
################################################################################
.PHONY: clean-cov
clean-cov:
rm -rf *.gcov *.gcda *.gcno ${COVERAGE_RESULTS} ${COVERAGE_DIR}
.PHONY: clean-docs
clean-docs:
rm -rf docs/code/html
.PHONY: clean-exec
clean-exec:
rm -rf ${PROJECT} ${GTEST} ${PROJECT}.exe ${GTEST}.exe
.PHONY: clean-obj
clean-obj:
rm -rf ${SRC}/*.o
.PHONY: clean-temp
clean-temp:
rm -rf *~ \#* .\#* \
${SRC_DIR}/*~ ${SRC_DIR}/\#* ${SRC_DIR}/.\#* \
${GTEST_DIR}/*~ ${GTEST_DIR}/\#* ${GTEST_DIR}/.\#* \
${SRC_INCLUDE}/*~ ${SRC_INCLUDE}/\#* ${SRC_INCLUDE}/.\#* \
${PROJECT_SRC_DIR}/*~ ${PROJECT_SRC_DIR}/\#* ${PROJECT_SRC_DIR}/.\#* \
${DESIGN_DIR}/*~ ${DESIGN_DIR}/\#* ${DESIGN_DIR}/.\#* \
*.gcov *.gcda *.gcno
.PHONY: clean
clean: clean-cov clean-docs clean-exec clean-obj clean-temp
################################################################################
# Compilaton targets
################################################################################
# default rule for compiling .cc to .o
%.o: %.cpp
${CXX} ${CXXFLAGS} -c $< -o $@
# Compilation targets
# compilation for performing testing
# using the files in include, src, and test, but not src/project
${GTEST}: ${GTEST_DIR} ${SRC_DIR} clean-exec
${CXX} ${CXXFLAGS} -o ./${GTEST} ${INCLUDE} \
${GTEST_DIR}/*.cpp ${SRC_DIR}/*.cpp ${LINKFLAGS}
# compilation for making the project
# using the files in include, src, and src/project, but not test
compileProject: ${SRC_DIR} ${PROJECT_SRC_DIR} clean-exec
${CXX} ${CXXVERSION} -o ${PROJECT} ${INCLUDE} \
${SRC_DIR}/*.cpp ${PROJECT_SRC_DIR}/*.cpp
################################################################################
# Test targets
################################################################################
# To perform all tests
all: ${GTEST} memcheck coverage docs static style
# To perform the memory checks
memcheck: ${GTEST}
valgrind --tool=memcheck --leak-check=yes --error-exitcode=1 ./${GTEST}
# To perform the code coverage checks
coverage: clean-exec clean-cov
${CXX} ${CXXWITHCOVERAGEFLAGS} -o ./${GTEST} ${INCLUDE} \
${GTEST_DIR}/*.cpp ${SRC_DIR}/*.cpp ${LINKFLAGS}
./${GTEST}
# Determine code coverage
${LCOV} --capture --gcov-tool ${GCOV} --directory . --output-file \
${COVERAGE_RESULTS} --rc lcov_branch_coverage=1
# Only show code coverage for the source code files (not library files)
${LCOV} --extract ${COVERAGE_RESULTS} */*/*/${SRC_DIR}/* -o \
${COVERAGE_RESULTS}
#Generate the HTML reports
genhtml ${COVERAGE_RESULTS} --output-directory ${COVERAGE_DIR}
#Remove all of the generated files from gcov
make clean-temp
# To perform the static check
static: ${SRC_DIR} ${GTEST_DIR}
${STATIC_ANALYSIS} --verbose --enable=all ${SRC_DIR} ${GTEST_DIR} \
${SRC_INCLUDE} --suppress=missingInclude --error-exitcode=1
# To perform the style check
style: ${SRC_DIR} ${GTEST_DIR} ${SRC_INCLUDE} ${PROJECT_SRC_DIR}
${STYLE_CHECK} ${SRC_DIR}/* ${GTEST_DIR}/* ${SRC_INCLUDE}/* \
${PROJECT_SRC_DIR}/*
################################################################################
# Documentation target
################################################################################
# To produce the documentation
.PHONY: docs
docs: ${SRC_INCLUDE}
doxygen ${DOXY_DIR}/doxyfile
################################################################################
# Revision History
################################################################################
# Updated: 2022-12-15 Nicole Wilson <n.wilson@uleth.ca>
# Removed all references to OS as the pipelines are now running on Ubuntu
################################################################################
# Updated: 2022-10-19 Dr. J. Anvik <john.anvik@uleth.ca>
# Changed the static command to make the pipeline fail on exit with errors.
################################################################################
# Updated: 2022-09-11 Nicole Wilson <n.wilson@uleth.ca>
# Added reference to OS in setting of STYLE_CHECK.
# This is a temporary measure until the pipelines are running on Ubuntu
################################################################################