-
Notifications
You must be signed in to change notification settings - Fork 5
/
arduino-build.sh
executable file
·60 lines (50 loc) · 1.2 KB
/
arduino-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
#!/bin/bash
PROJECT=seeed-ambd-firmware
BOARD=realtek:AmebaD:ameba_rtl8721d
COMMAND=$1
PORT=$2
CRTDIR=$(pwd)
#easylogger
INCLUDE+=" -I$CRTDIR/src/easylogger"
INCLUDE+=" -I$CRTDIR/src/easylogger/inc"
#ble
INCLUDE+=" -I$CRTDIR/src/ble"
#wifi
INCLUDE+=" -I$CRTDIR/src/wifi"
#esp_lib
INCLUDE+=" -I$CRTDIR/src/esp_lib"
#erpc
INCLUDE+=" -I$CRTDIR/src/erpc"
#erpc_shim
INCLUDE+=" -I$CRTDIR/src/erpc_shim"
#mdns
INCLUDE+=" -I$CRTDIR/src/mDNS"
FLAGS+=""
if [ "$COMMAND" = "--build" ];
then
echo "Building $PROJECT"
arduino-cli compile --fqbn $BOARD --verbose --build-property build.extra_flags="$INCLUDE $FLAGS" $PROJECT &
pid=$! # Process Id of the previous running command
while kill -0 $pid 2>/dev/null
do
echo "Still building..."
sleep 2
done
wait $pid
ret=$?
if [ $ret -eq 0 ]; then
echo "Building $PROJECT done"
else
exit "Building $PROJECT failed"
fi
elif [ "$COMMAND" = "--flash" ];
then
arduino-cli upload --fqbn $BOARD -p $PORT
elif [ "$COMMAND" = "--all" ];
then
arduino-cli compile --fqbn $BOARD --verbose --build-property build.extra_flags="$INCLUDE $FLAGS" $PROJECT
status=$?
[ $status -eq 0 ] && arduino-cli upload --fqbn $BOARD --port $PORT
else
echo "Nothing to do for target"
fi