-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·115 lines (94 loc) · 2.4 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
#!/bin/bash
#
# Copyright (c) 2017, The Apollo Authors. All Rights Reserved
#
# VERSION: 1.0
# FILEIN: ros
# FILEOUT: install/ros_$MACHINE_ARCH
#------------------------ global variable --------------------------
CURRENT_PATH=`pwd`
MACHINE_ARCH="$(uname -m)"
INSTALL_PATH="${CURRENT_PATH}/install/ros_$MACHINE_ARCH"
FASTRTPS_PATH="${CURRENT_PATH}/third_party/fast-rtps"
TP_LIB_PATH="${CURRENT_PATH}/third_party/lib"
BUILD_TYPE="Release"
export LD_LIBRARY_PATH="${CURRENT_PATH}/third_party/fast-rtps/lib:$LD_LIBRARY_PATH"
#--------------------------- function ------------------------------
function info() {
(>&2 echo -e "[\e[34m\e[1mINFO\e[0m] $*")
}
function error() {
(>&2 echo -e "[\e[33m\e[1mERROR\e[0m] $*")
}
function ok() {
(>&2 echo -e "[\e[32m\e[1m OK \e[0m] $*")
}
function print_delim() {
echo '============================'
}
function success() {
print_delim
ok $1
print_delim
}
function fail() {
print_delim
error $1
print_delim
exit -1
}
function print_usage() {
echo 'Usage:
./build.sh [OPTION]'
echo 'Options:
build: run build only
clean: run environment clean
'
return 0
}
function build() {
build_ros
}
function clean() {
clean_ros
}
function build_ros() {
# TODO: add the third-party package for FASTRTPS
#rm -f ${FASTRTPS_PATH} ${TP_LIB_PATH}
#ln -sf ${FASTRTPS_PATH}_${MACHINE_ARCH} ${FASTRTPS_PATH} &&
#ln -sf ${TP_LIB_PATH}_${MACHINE_ARCH} ${TP_LIB_PATH} &&
./catkin/bin/catkin_make_isolated --install --source . \
--install-space ${INSTALL_PATH} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DFASTRTPS_PATH=${FASTRTPS_PATH} --cmake-args --no-warn-unused-cli &&
echo "done"
cp -r ${CURRENT_PATH}/third_party/fast-rtps/lib/* ${INSTALL_PATH}/lib/ &&
cp -r ${CURRENT_PATH}/third_party/lib/* ${INSTALL_PATH}/lib/ &&
cp -r ${CURRENT_PATH}/third_party/bin/* ${INSTALL_PATH}/bin/ &&
find -name "*.pyc" -print0 | xargs -0 rm -rf
if [ $? -ne 0 ]; then
fail 'Build ros failed!'
fi
success 'Build ros succeed!'
}
function clean_ros() {
find -name "*.pyc" -print0 | xargs -0 rm -rf &&
rm -rf .catkin_workspace &&
rm -rf build_isolated &&
rm -rf devel_isolated &&
rm -rf install
if [ $? -ne 0 ]; then
fail 'Clean ros failed!'
fi
success 'Clean ros succeed!'
}
case $1 in
build)
build
;;
clean)
clean
;;
*)
print_usage
;;
esac