forked from Livox-SDK/livox_ros_driver2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·70 lines (60 loc) · 1.6 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
#!/bin/bash
readonly VERSION_ROS1="ROS1"
readonly VERSION_ROS2="ROS2"
readonly VERSION_HUMBLE="humble"
pushd `pwd` > /dev/null
cd `dirname $0`
echo "Working Path: "`pwd`
ROS_VERSION=""
ROS_HUMBLE=""
# Set working ROS version
if [ "$1" = "ROS2" ]; then
ROS_VERSION=${VERSION_ROS2}
elif [ "$1" = "humble" ]; then
ROS_VERSION=${VERSION_ROS2}
ROS_HUMBLE=${VERSION_HUMBLE}
elif [ "$1" = "ROS1" ]; then
ROS_VERSION=${VERSION_ROS1}
else
echo "Invalid Argument"
exit
fi
echo "ROS version is: "$ROS_VERSION
# clear `build/` folder.
# TODO: Do not clear these folders, if the last build is based on the same ROS version.
rm -rf ../../build/
rm -rf ../../devel/
rm -rf ../../install/
# clear src/CMakeLists.txt if it exists.
if [ -f ../CMakeLists.txt ]; then
rm -f ../CMakeLists.txt
fi
# exit
# substitute the files/folders: CMakeList.txt, package.xml(s)
if [ ${ROS_VERSION} = ${VERSION_ROS1} ]; then
if [ -f package.xml ]; then
rm package.xml
fi
cp -f package_ROS1.xml package.xml
elif [ ${ROS_VERSION} = ${VERSION_ROS2} ]; then
if [ -f package.xml ]; then
rm package.xml
fi
cp -f package_ROS2.xml package.xml
cp -rf launch_ROS2/ launch/
fi
# build
pushd `pwd` > /dev/null
if [ $ROS_VERSION = ${VERSION_ROS1} ]; then
cd ../../
catkin_make -DROS_EDITION=${VERSION_ROS1}
elif [ $ROS_VERSION = ${VERSION_ROS2} ]; then
cd ../../
colcon build --cmake-args -DROS_EDITION=${VERSION_ROS2} -DHUMBLE_ROS=${ROS_HUMBLE}
fi
popd > /dev/null
# remove the substituted folders/files
if [ $ROS_VERSION = ${VERSION_ROS2} ]; then
rm -rf launch/
fi
popd > /dev/null