forked from usdot-fhwa-stol/carma-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
carma_build.bash
executable file
·108 lines (90 loc) · 3.29 KB
/
carma_build.bash
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
#!/bin/bash
# Copyright (C) 2018-2021 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# This scipt builds the CARMA platform and its Autoware.ai dependancies.
usage() {
echo "USAGE carma_build [OPTION]
carma_build will build the CARMA Platform including any drivers in the same workspace as well as any required Autoware.ai components
-a Path to Autoware.ai workspace. If this is not specified it is assumed CARMA and Autoware.ai share a workspace
-c Path to CARMA workspace.
-x Skip Autoware.ai build. In this case Autoware.ai will be sourced from the location specified by -a
-r CARMA rebuild flag. This will do a clean build of the CARMA code. Autoware.ai code is always cleaned before building even without this flag.
-m Additional build arguments to pass to CARMA's catkin_make install
-b Additional build arguments to pass to Autoware.ai's colcon build
-h Print help
";
}
# Default environment variables
carma_workspace="$(realpath ../..)"
autoware_src="$(realpath ${carma_workspace}/../autoware.ai)"
skip_autoware=false
rebuild_carma=false
carma_build_args=""
autoware_build_args=""
# Read Options
while getopts a:c:xrhm:b: option
do
case "${option}"
in
a) autoware_src="$(realpath ${OPTARG})";;
c) carma_workspace="$(realpath ${OPTARG})";;
x) skip_autoware=true;;
r) rebuild_carma=true;;
m) carma_build_args=${OPTARG};;
b) autoware_build_args=${OPTARG};;
h) usage; exit 0;;
\?) echo "Unknown option: -$OPTARG" >&2; exit 1;;
:) echo "Missing option argument for -$OPTARG" >&2; exit 1;;
*) echo "Unimplemented option: -$OPTARG" >&2; exit 1;;
esac
done
echo "
Attempting to build CARMA
CARMA Workspace: ${carma_workspace}
Autoware Source Dir: ${autoware_src}
"
# Clean workspace if needed
old_pwd="${PWD}"
cd ${carma_workspace}
if [ "${rebuild_carma}" = true ]; then
echo "Clean CARMA build requested with -r option"
echo "Claning carma workspace"
rm -rf build devel install
fi
cd ${old_pwd}
###
# Build autoware or skip if requested
###
if [ "${skip_autoware}" = true ]; then
echo "Skipping Autoware build due to -x option"
source ${autoware_src}/ros/install/setup.bash
else
cd ${autoware_src}/autoware/ros
if [ -z "${autoware_build_args}" ]; then
./carma_autoware_build -a ${autoware_src}
else
./carma_autoware_build -a ${autoware_src} -b ${autoware_build_args}
fi
source ${autoware_src}/ros/install/setup.bash
echo "Autoware built successfuly. Binaries sourced from $(realpath ./install/setup.bash)"
fi
###
# Build CARMA
###
source /opt/autoware.ai/ros/install/setup.bash
echo "Autoware built successfuly. Binaries sourced from $(realpath ./install/setup.bash)"
echo "Building CARMA"
cd ${carma_workspace}
colcon build --cmake-args ${carma_build_args}
echo "CARMA built successfuly. Binaries sourced from $(realpath ./install/setup.bash)"