-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuild-workspace.sh
executable file
·106 lines (93 loc) · 2.87 KB
/
build-workspace.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
#!/bin/bash
# Copyright (c) 2024 Carnegie Mellon University, IBM Corporation, and others
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
## termination hook
trap ctrl_c INT QUIT TERM
function ctrl_c() {
exit
}
source ./cabot-common/build-utils.sh
function help {
echo "Usage: $0 [<option>] [<targets>]"
echo ""
echo "-h show this help"
echo "-d debug build"
echo "-w build docker ws"
echo "-o build host ws"
echo "Available services:"
show_available_services dcfiles
}
debug_build=0
build_docker_ws=0
build_host_ws=0
dcfiles=("docker-compose.yaml")
while getopts "hdwo" arg; do
case $arg in
h)
help
exit
;;
d)
debug_build=1
;;
w)
build_docker_ws=1
;;
o)
build_host_ws=1
;;
esac
done
shift $((OPTIND-1))
targets=$@
arch=$(uname -m)
if [ $arch != "x86_64" ] && [ $arch != "aarch64" ]; then
red "Unknown architecture: $arch"
exit 1
fi
if [[ $build_docker_ws -eq 0 ]] && [[ $build_host_ws -eq 0 ]]; then
help
exit 1
fi
if [[ $build_docker_ws -eq 1 ]]; then
build_workspace dcfiles targets arch debug_build
if [ $? != 0 ]; then exit 1; fi
fi
if [[ $build_host_ws -eq 1 ]]; then
scriptdir=$(dirname $0)
cd $scriptdir/host_ws
if [[ -z $ROS_DISTRO ]]; then
# try to find a
red "ROS_DISTRO is not set, so try to find the lastest ROS2 distro in the system"
source $(find /opt/ros/ -maxdepth 2 -name setup.bash -exec grep -l ament {} + | sort -r | head -1)
else
source /opt/ros/$ROS_DISTRO/setup.bash
fi
blue "$ROS_DISTRO is found"
blue "build host_ws"
if $debug; then
blue "colcon build --symlink-install"
colcon build --symlink-install
else
blue "colcon build"
colcon build
fi
if [ $? != 0 ]; then exit 1; fi
fi