-
Notifications
You must be signed in to change notification settings - Fork 6
/
ros2_build.sh
executable file
·48 lines (41 loc) · 1.83 KB
/
ros2_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
#!/bin/bash
set -xe
# install dependencies
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116
echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list
apt update && apt install -y python3 python3-pip lcov cmake && rosdep update
apt update && apt install -y python3-rosinstall python3-colcon-common-extensions && pip3 install -U setuptools
apt list --upgradable 2>/dev/null | awk {'print $1'} | sed 's/\/.*//g' | grep $ROS_DISTRO | xargs apt install -y
REPO_NAME=$(basename -- ${TRAVIS_BUILD_DIR})
echo "repo: ${REPO_NAME} branch: ${TRAVIS_BRANCH}"
# use colcon as build tool to build the package, and optionally build tests
. "/opt/ros/${ROS_DISTRO}/setup.sh"
cd "/${ROS_DISTRO}_ws/"
if [ -f "./src/${REPO_NAME}/.rosinstall.master" ]; then
mkdir dep
cd "/${ROS_DISTRO}_ws/dep"
ln -s "../src/${REPO_NAME}/.rosinstall.master" .rosinstall
rosws update
cd "/${ROS_DISTRO}_ws/"
rosdep install --from-paths src dep --ignore-src --rosdistro "${ROS_DISTRO}" -r -y
else
rosdep install --from-paths src --ignore-src --rosdistro "${ROS_DISTRO}" -r -y
fi
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' -DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage'
if [ -z "${NO_TEST}" ]; then
# run unit tests
. ./install/setup.sh
if [ "${TRAVIS_BRANCH}" == "master" ] && [ -d "./dep" ]; then
touch dep/COLCON_IGNORE
fi
set +e
colcon test
set -e
colcon test-result --all --verbose
# get unit test code coverage result
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
cd "/${ROS_DISTRO}_ws/"
mv coverage.info /shared
fi