forked from ros2-realtime-demo/pendulum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravis.sh
executable file
·99 lines (91 loc) · 2.44 KB
/
travis.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
#!/bin/bash
: '
Author: Lander Usategui, lander at erlerobotics dot com
'
set -e
# Export colors
export RED="\033[31m"
export GREEN="\033[32m"
export YELLOW="\033[33m"
export BLUE="\033[34m"
export PURPLE="\e[0;35m"
export RESET="\e[0m"
# Paths
export WS="/root/ros2_ws"
export WS_SYMLINK="/root/ros2_symlink"
export ROS2_DISTRO="dashing"
function prepare_ws()
{
echo -e "${YELLOW}Preparing work spaces${RESET}"
cd ${WS} || exit
cp -r /tmp/pendulum src
cd ${WS_SYMLINK} || exit
cp -r /tmp/pendulum src
result=$?
if [ $result -ne 0 ]; then
echo -e "${RED}prepare_ws failed${RESET}"
exit $result
else
echo -e "${BLUE}prepare_ws function successfully finished${RESET}"
fi
}
function run_rosdep()
{
echo -e "${YELLOW}Making sure that everything is installed${RESET}"
cd ${WS} || exit
apt update -qq && rosdep update
rosdep install -q -y --from-paths . --ignore-src --rosdistro \
"${ROS2_DISTRO}" \
--as-root=apt:false || true
result=$?
if [ $result -ne 0 ]; then
echo -e "${RED}run_rosdep failled${RESET}"
exit $result
else
echo -e "${BLUE}All dependencies successfully installed${RESET}"
fi
}
function compile_ws()
{
source /opt/ros/"${ROS2_DISTRO}"/setup.bash
cd ${WS} || exit
echo -e "${YELLOW}###### Packages to be compiled ######${RESET}"
echo -e "${PURPLE}"
colcon list --names-only
echo -e "${RESET}"
echo -e "${YELLOW}Compile the WS for ROS2${RESET}"
colcon build --merge-install
echo -e "${YELLOW}Testing WS${RESET}"
colcon test --merge-install --return-code-on-test-failure
result=$?
if [ $result -ne 0 ]; then
echo -e "${RED}Error compiling the ws${RESET}"
exit $result
else
echo -e "${BLUE}WS compiled successfully${RESET}"
fi
}
function compile_ws_symlink()
{
source /opt/ros/"${ROS2_DISTRO}"/setup.bash
cd ${WS_SYMLINK} || exit
echo -e "${YELLOW}###### Packages to be compiled ######${RESET}"
echo -e "${PURPLE}"
colcon list --names-only
echo -e "${RESET}"
echo -e "${YELLOW}Compile the WS for ROS2 using --symlink-install${RESET}"
colcon build --symlink-install
result=$?
if [ $result -ne 0 ]; then
echo -e "${RED}Error compiling the WS_SYMLINK${RESET}"
exit $result
else
echo -e "${BLUE}WS_SYMLINK compiled successfully${RESET}"
fi
}
prepare_ws
run_rosdep
compile_ws
compile_ws_symlink
#If we're here everything is okay
echo -e "${GREEN}All steps successfully completed${RESET}"