-
Notifications
You must be signed in to change notification settings - Fork 58
/
build.sh
executable file
·127 lines (101 loc) · 2.5 KB
/
build.sh
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
#!/bin/bash
print_usage()
{
echo "Build novatel_oem7_driver"
echo "Usage: "
echo " $0 -h"
echo " $0 [-c] [-d | -r] [-p] [-t]"
echo
echo "Where:"
echo " -h: Print this help message and exit."
echo " -c: Clean all intermediate files."
echo " -d: Build debug binaries"
echo " -r: Build release binaries; can't be combined with -d"
echo " -t: Run tests using local binaries."
echo " -p: Build .deb package(s)"
echo " -f: Full build, equivalent to '$0 -crtp'"
echo
echo "Examples"
echo " '$0' Build local binaries; used for local development."
echo " '$0 -f' Full build: Used for production artifacts."
echo " '$0 -r' Release build, no tests or .deb packages"
echo " '$0 -cd' Clean Debug build, no packages."
}
build_deb_pkg()
{
./create-$ROS_DISTRO-package.sh
}
on_invalid_args()
{
print_usage
exit 1
}
INSTALL=
CLEAN=
DEBUG_FLAG=
ROSDOC=
BUILD_DEB_PKG=
RUN_TESTS=
NO_ARGS=on_invalid_args
while getopts "hcdrpft" OPT; do
NO_ARGS=
case $OPT in
h )
print_usage
exit 0
;;
c )
CLEAN=clean
;;
d )
INSTALL=install
DEBUG_FLAG=-DCMAKE_BUILD_TYPE=Debug
;;
r )
INSTALL=install
DEBUG_FLAG=
;;
p )
INSTALL=install
BUILD_DEB_PKG=build_deb_pkg
;;
t )
RUN_TESTS=run_tests
CATKIN_TEST_RESULTS=catkin_test_results
;;
f )
CLEAN=clean
INSTALL=install
BUILD_DEB_PKG=build_deb_pkg
RUN_TESTS=run_tests
CATKIN_TEST_RESULTS=catkin_test_results
;;
* )
on_invalid_args
;;
esac
done
$NO_ARGS
if [[ $CLEAN ]];
then
# Remove all intermediate and temporary files.
rm -rf .ros devel build doc install
rm -rf *.deb src/*.ddeb
rm -rf src/novatel_oem7_driver/debian src/novatel_oem7_driver/obj-*
rm -rf src/novatel_oem7_msgs/debian src/novatel_oem7_msgs/obj-*
rm -f src/CMakeLists.txt
if [[ -z $INSTALL && -z $RUN_TESTS && -z $BUILD_DEB_PKG ]];
then
exit 0
fi
fi
set -e
# Build local artifacts
source /opt/ros/$ROS_DISTRO/setup.bash
catkin_make $DEBUG_FLAG $CLEAN $INSTALL $RUN_TESTS
$CATKIN_TEST_RESULTS
if [[ $INSTALL ]];
then
rosdoc_lite src/novatel_oem7_driver -o doc
$BUILD_DEB_PKG
fi