-
Notifications
You must be signed in to change notification settings - Fork 144
/
build_firmware.sh
executable file
·77 lines (65 loc) · 1.95 KB
/
build_firmware.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
#! /bin/bash
set -e
set -o nounset
set -o pipefail
PREFIXES_TO_CLEAN=$AMENT_PREFIX_PATH
FW_TARGETDIR=$(pwd)/firmware
PREFIX=$(ros2 pkg prefix micro_ros_setup)
# Parse cli arguments
UROS_FAST_BUILD=off
UROS_VERBOSE_BUILD=off
UROS_EXTRA_BUILD_ARGS=""
while getopts "vf" o
do
case "$o" in
f)
echo "Fast-Build active, ROS workspace will not be re-built!"
UROS_FAST_BUILD=on
;;
v)
echo "Building in verbose mode"
UROS_VERBOSE_BUILD=on
;;
[?])
echo "Usage: ros2 run micro_ros_setup build_firmware.sh [options] -- [build_args]"
echo "Options:"
echo " -v Print verbose build output."
echo " -f Activate Fast-Build. Without this, mcu_ws will get rebuilt completely."
echo "Build args: These options will get directly forwarded to the build system (currently only supported for zephyr)."
exit 1
;;
esac
done
shift $((OPTIND-1))
if [[ -n "$@" ]]; then
UROS_EXTRA_BUILD_ARGS=("$@")
fi
export UROS_FAST_BUILD
export UROS_VERBOSE_BUILD
export UROS_EXTRA_BUILD_ARGS
# Checking if firmware exists
if [ -d $FW_TARGETDIR ]; then
RTOS=$(head -n1 $FW_TARGETDIR/PLATFORM)
PLATFORM=$(head -n2 firmware/PLATFORM | tail -n1)
if [ -f $FW_TARGETDIR/TRANSPORT ]; then
TRANSPORT=$(head -n1 firmware/TRANSPORT)
fi
else
echo "Firmware folder not found. Please use ros2 run micro_ros_setup create_firmware_ws.sh to create a new project."
exit 1
fi
# clean paths
. $(dirname $0)/clean_env.sh
# source dev_ws
if [ $RTOS != "host" ]; then
set +o nounset
. $FW_TARGETDIR/dev_ws/install/setup.bash
set -o nounset
fi
# Building specific firmware folder
echo "Building firmware for $RTOS platform $PLATFORM"
if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then
. $PREFIX/config/$RTOS/generic/build.sh
else
. $PREFIX/config/$RTOS/$PLATFORM/build.sh
fi