-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
349 lines (279 loc) · 11.6 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
APT_INSTALL?=env DEBIAN_FRONTEND=noninteractive apt --yes --no-install-recommends install
MAKE_FLAGS?=-j14
CMAKE_DIR=./cmake/
BUILD_DIR=./build/
ROOT_DIR=../../
# Toolchains
TC?=generic
OPTIONS?=default
# Build type as in CMAKE_BUILD_TYPE
TYPE?=Debug
TARGETS?=all
ARGS?=
DEB_TARGET?=xenial
SUPP_PATH=../../../qa/sanitizers/
TEST_ENV=UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1:suppressions=${SUPP_PATH}/undefined.supp \
ASAN_OPTIONS=suppressions=${SUPP_PATH}/address.supp \
LSAN_OPTIONS=suppressions=${SUPP_PATH}/leak.supp
PKG_NAME=ariles2
FIND_ARILES_SOURCES=find ./extra_* ./tests/ ./include/ -iname "*.h" -or -iname "*.cpp"
#----------------------------------------------
# Cleaning
#----------------------------------------------
clean:
rm -Rf build;
rm -Rf include/${PKG_NAME}/internal/cpput_*.h
#git submodule update --init doc/dox/; cd doc/dox/; git clean -f; git reset --hard
#----------------------------------------------
# Generic targets
#----------------------------------------------
BUILD_SUBDIR=${BUILD_DIR}/${TC}-${TYPE}-OPTIONS_${OPTIONS}
build:
mkdir -p ${BUILD_SUBDIR};
cd ${BUILD_SUBDIR}; cmake -C ${ROOT_DIR}/cmake/options_${OPTIONS}.cmake\
-DCMAKE_BUILD_TYPE=${TYPE} \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_DIR}/toolchain_${TC}.cmake\
${EXTRA_CMAKE_PARAM} \
${ROOT_DIR};
cd ${BUILD_SUBDIR}; ${MAKE} ${MAKE_FLAGS} ${TARGETS}
build-tests: build
cd ${BUILD_SUBDIR}; env ${TEST_ENV} ctest ${ARGS}
# cd ${BUILD_SUBDIR}; ${MAKE} ${MAKE_FLAGS} test ${ARGS}
# -------
#----------------------------------------------
# debug mode (all)
# Build & test
#----------------------------------------------
debug-all:
${MAKE} build TC=${TC} TYPE=Debug TARGETS="${TARGETS}"
debug-all-tests:
${MAKE} build-tests TC=${TC} TYPE=Debug TARGETS="${TARGETS}"
all: debug-all
debug: debug-all
#----------------------------------------------
# release mode
# Build & test
#----------------------------------------------
release-all:
${MAKE} build TC=${TC} TYPE=Release TARGETS="${TARGETS}"
release-all-tests: release-all
${MAKE} build-tests TC=${TC} TYPE=Release TARGETS="${TARGETS}"
release: release-all
#----------------------------------------------
# Debian packages
#----------------------------------------------
deb: clean
${MAKE} build TC=${TC} TYPE=Release OPTIONS=deb_packages_${DEB_TARGET} TARGETS="pkg_deb" \
EXTRA_CMAKE_PARAM="${EXTRA_CMAKE_PARAM} -DDEB_BUILDPACKAGE_FLAGS='-d'"
deb-build: clean
${MAKE} build TC=${TC} TYPE=Release OPTIONS=deb_packages_${DEB_TARGET} TARGETS="pkg_deb" \
EXTRA_CMAKE_PARAM="${EXTRA_CMAKE_PARAM} -DDEB_BUILDPACKAGE_FLAGS='-us;-uc'"
cd build/generic-Release-OPTIONS_deb_packages_${DEB_TARGET}/Debian/${DEB_TARGET}/${PKG_NAME}-*-source; \
dpkg-buildpackage -us -uc -F
deb-install:
sudo dpkg -i build/generic-Release-OPTIONS_deb_packages_${DEB_TARGET}/Debian/${DEB_TARGET}/${PKG_NAME}-*.deb
deb-uninstall:
dpkg --get-selections ${PKG_NAME}* | awk '{print $1}' | xargs sudo dpkg -P
deb-cloudsmith:
ls build/generic-Release-OPTIONS_deb_packages_${DEB_TARGET}/Debian/${DEB_TARGET}/${PKG_NAME}-*.deb \
| xargs --no-run-if-empty -I {} cloudsmith push deb asherikov-aV7/all/ubuntu/${DEB_TARGET} {}
cmake_dependency: clean
mkdir -p build/cmake_dependency_test
cd build/cmake_dependency_test; cmake ../../tests/dependency/ -DARILES_COMPONENTS="rosparam;yaml-cpp;octave"
cd build/cmake_dependency_test; ${MAKE} ${MAKE_FLAGS}
#ppa-upload:
# cd build/generic-Release-OPTIONS_deb_packages_trusty/Debian/trusty/; \
# ftp -au ppa.launchpad.net:~asherikov/ubuntu/ppa/ \
# ${PKG_NAME}_*~${DEB_TARGET}.dsc \
# ${PKG_NAME}_*~${DEB_TARGET}.tar.xz \
# ${PKG_NAME}_*~${DEB_TARGET}_source.buildinfo \
# ${PKG_NAME}_*~${DEB_TARGET}_source.changes
#----------------------------------------------
# checks
#----------------------------------------------
test-ros: clean
${MAKE} build-tests TC=${TC} TYPE=Debug OPTIONS=default TARGETS="${TARGETS}" EXTRA_CMAKE_PARAM="${EXTRA_CMAKE_PARAM}"
${MAKE} build-tests TC=${TC} TYPE=Debug OPTIONS=ros TARGETS="${TARGETS}" EXTRA_CMAKE_PARAM="${EXTRA_CMAKE_PARAM}"
test-ros2: clean
#${MAKE} build-tests TC=${TC} TYPE=Debug OPTIONS=default TARGETS="${TARGETS}" EXTRA_CMAKE_PARAM="${EXTRA_CMAKE_PARAM}"
${MAKE} build-tests TC=${TC} TYPE=Debug OPTIONS=ros2 TARGETS="${TARGETS}" EXTRA_CMAKE_PARAM="${EXTRA_CMAKE_PARAM}"
test-noros: clean
${MAKE} build-tests TC=${TC} TYPE=Debug OPTIONS=noros TARGETS="${TARGETS}" EXTRA_CMAKE_PARAM="${EXTRA_CMAKE_PARAM}"
${MAKE} clangcheck SCANBUILD=scan-build18 OPTIONS=noros_tidy
${MAKE} cppcheck
${MAKE} spell
#----------------------------------------------
# other
#----------------------------------------------
addutils:
-git remote add --no-tags cmakeut https://github.com/asherikov/cmakeut
-git remote add --no-tags cpput https://github.com/asherikov/cpput
updateutils: addutils
git fetch --all
git show remotes/cmakeut/master:cmake/FindEigen3.cmake > cmake/FindEigen3.cmake
git show remotes/cmakeut/master:cmake/cmakeut_compiler_flags.cmake > cmake/cmakeut_compiler_flags.cmake
git show remotes/cmakeut/master:cmake/cmakeut_dump_variables.cmake > cmake/cmakeut_dump_variables.cmake
git show remotes/cmakeut/master:cmake/cmakeut_list_filenames.cmake > cmake/cmakeut_list_filenames.cmake
#
git show remotes/cpput/master:include/cpput/exception.h > include/ariles2/internal/exception.h
git show remotes/cpput/master:include/cpput/visibility.h > include/ariles2/internal/visibility.h
git show remotes/cpput/master:include/cpput/misc.h > include/ariles2/internal/misc.h
git show remotes/cpput/master:include/cpput/trace.h > include/ariles2/internal/trace.h
git show remotes/cpput/master:include/cpput/concat.h > include/ariles2/internal/concat.h
update:
git submodule update
doxclean:
cd doc/dox; git fetch --all; git checkout gh-pages; git pull
rm -Rf ./doc/dox/2
dox: doxclean clean
cd doc; doxygen
install-ros:
wget -qO- https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo tee /etc/apt/trusted.gpg.d/ros.asc
${MAKE} install-ros-${ROS_DISTRO}
${APT_INSTALL} dpkg
${APT_INSTALL} python3-rosdep python3-rosinstall python3-rosinstall-generator build-essential
bash -c 'source /opt/ros/${ROS_DISTRO}/setup.bash; rosdep init'
rosdep update
install-ros-noetic:
sh -c 'test -f /etc/apt/sources.list.d/ros-latest.list \
|| (echo "deb http://packages.ros.org/ros/ubuntu ${UBUNTU_DISTRO} main" > /etc/apt/sources.list.d/ros-latest.list)'
apt update -qq
${APT_INSTALL} ros-${ROS_DISTRO}-ros-base
install-ros-humble:
sh -c 'test -f /etc/apt/sources.list.d/ros2-latest.list \
|| (echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main ${UBUNTU_DISTRO} main" > /etc/apt/sources.list.d/ros2-latest.list)'
apt update -qq
${APT_INSTALL} ros-${ROS_DISTRO}-rclcpp
install-deps:
${APT_INSTALL} cmake libboost-all-dev libeigen3-dev
${APT_INSTALL} octave libpugixml-dev libyaml-cpp-dev rapidjson-dev libmsgpack-dev graphviz
${APT_INSTALL} libprotobuf-dev protobuf-compiler
${APT_INSTALL} libjsonnet-dev libjsonnet0
format:
${FIND_ARILES_SOURCES} | grep -v "better_enum.h" | xargs clang-format15 -verbose -i
cppcheck:
# --inconclusive
# false positive: constStatement, unsignedLessThanZero
cppcheck \
./ \
--inline-suppr \
--relative-paths \
--quiet --verbose --force \
--template='[{file}:{line}] {severity} {id} {message}' \
--language=c++ --std=c++11 \
--enable=warning \
--enable=style \
--enable=performance \
--enable=portability \
--suppress=uninitMemberVar \
--suppress=syntaxError \
--suppress=useInitializationList \
--suppress=functionStatic \
--suppress=unknownMacro \
--suppress=constStatement \
--suppress=unsignedLessThanZero \
--suppress=duplInheritedMember \
-i build \
-i tests/api_v2/regression_test_230.cpp \
{} \
3>&1 1>&2 2>&3 | tee cppcheck.err
test 0 -eq `cat cppcheck.err | wc -l && rm cppcheck.err`
# check headers
find ./ -type f -iname '*.hpp' -or -iname "*.h" \
| grep -v "better_enum.h" \
| grep -v ".*build/.*" \
| xargs --max-procs=1 --no-run-if-empty -I {} \
cppcheck \
--inline-suppr \
--relative-paths \
--quiet --verbose --force \
--template='[{file}:{line}] {severity} {id} {message}' \
--language=c++ --std=c++11 \
--enable=warning \
--enable=style \
--enable=performance \
--enable=portability \
--suppress=uninitMemberVar \
--suppress=syntaxError \
--suppress=useInitializationList \
--suppress=functionStatic \
--suppress=unknownMacro \
--suppress=constStatement \
--suppress=unsignedLessThanZero \
--suppress=duplInheritedMember \
--suppress=unreadVariable \
--suppress=unusedStructMember \
-i tests/api_v2/regression_test_230.cpp \
{} \
3>&1 1>&2 2>&3 | tee cppcheck.err
test 0 -eq `cat cppcheck.err | wc -l && rm cppcheck.err`
#
# make clangcheck SCANBUILD=scan-build-9 OPTIONS=ros
# make clangcheck SCANBUILD=scan-build11 OPTIONS=cpp11_on_noros_tidy
#
clangcheck:
${SCANBUILD} \
-o build/scanbuild_results \
--status-bugs \
--exclude ./build \
--exclude /usr/include/ \
--exclude /usr/local/include/ \
--exclude /usr/src/ \
--exclude /opt/ros/ \
-enable-checker core.CallAndMessage \
-enable-checker core.DivideZero \
-enable-checker core.DynamicTypePropagation \
-enable-checker core.NonNullParamChecker \
-enable-checker core.NullDereference \
-enable-checker core.StackAddressEscape \
-enable-checker core.UndefinedBinaryOperatorResult \
-enable-checker core.VLASize \
-enable-checker core.uninitialized.ArraySubscript \
-enable-checker core.uninitialized.Assign \
-enable-checker core.uninitialized.Branch \
-enable-checker core.uninitialized.CapturedBlockVariable \
-enable-checker core.uninitialized.UndefReturn \
-enable-checker cplusplus.InnerPointer \
-enable-checker cplusplus.Move \
-enable-checker cplusplus.NewDeleteLeaks \
-enable-checker deadcode.DeadStores \
-enable-checker nullability.NullPassedToNonnull \
-enable-checker nullability.NullReturnedFromNonnull \
-enable-checker nullability.NullableDereferenced \
-enable-checker nullability.NullablePassedToNonnull \
-enable-checker nullability.NullableReturnedFromNonnull \
-enable-checker optin.cplusplus.UninitializedObject \
-enable-checker optin.mpi.MPI-Checker \
-enable-checker optin.performance.GCDAntipattern \
-enable-checker optin.performance.Padding \
-enable-checker optin.portability.UnixAPI \
-enable-checker security.FloatLoopCounter \
-enable-checker security.insecureAPI.DeprecatedOrUnsafeBufferHandling \
-enable-checker security.insecureAPI.UncheckedReturn \
-enable-checker security.insecureAPI.getpw \
-enable-checker security.insecureAPI.gets \
-enable-checker security.insecureAPI.mkstemp \
-enable-checker security.insecureAPI.mktemp \
-enable-checker security.insecureAPI.vfork \
-enable-checker unix.API \
-enable-checker unix.Malloc \
-enable-checker unix.MallocSizeof \
-enable-checker unix.MismatchedDeallocator \
-enable-checker unix.Vfork \
-enable-checker unix.cstring.BadSizeArg \
-enable-checker unix.cstring.NullArg \
-enable-checker valist.CopyToSelf \
-enable-checker valist.Uninitialized \
-enable-checker valist.Unterminated \
${MAKE} build TC=${TC} TYPE=${TYPE} OPTIONS=${OPTIONS} TARGETS="${TARGETS}" EXTRA_CMAKE_PARAM="-DBUILD_SHARED_LIBS=OFF ${EXTRA_CMAKE_PARAM}"
# -enable-checker cplusplus.NewDelete
# -enable-checker optin.cplusplus.VirtualCall
spell_interactive:
${MAKE} spell SPELL_XARGS_ARG=-o
# https://github.com/myint/scspell
spell:
${FIND_ARILES_SOURCES} \
| grep -v "./tests/common/better_enum.h" \
| grep -v "./extra_visitors/rapidjson/src/istreamwrapper.h" \
| xargs ${SPELL_XARGS_ARG} scspell --use-builtin-base-dict --override-dictionary ./qa/scspell.dict
.PHONY: clean cmake build