-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·65 lines (55 loc) · 1.17 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
#!/bin/bash
function help() {
echo "$0 [options] [build|upload|all]"
echo ""
echo "build build the code (default action)"
echo "upload upload the code"
echo "all build and upload if build is success"
echo ""
echo "-h show this help"
echo "-b set board (default=esp32:esp32:esp32)"
echo "-p set port (default=/dev/ttyESP32)"
}
: ${ARDUINO_BOARD:="esp32:esp32:esp32"}
: ${ARDUINO_PORT:="/dev/ttyESP32"}
board=$ARDUINO_BOARD
port=$ARDUINO_PORT
while getopts "hb:p:" arg; do
case $arg in
h)
help
exit
;;
b)
board=$OPTARG
;;
p)
port=$OPTARG
;;
esac
done
shift $((OPTIND-1))
target=$1
if [ -z $target ]; then
target=build
fi
function build() {
echo "building for $board..."
arduino-cli compile -b $board --warnings all .
}
function upload() {
echo "uploading for $board at $port..."
arduino-cli upload -b $board -p $port .
while [ $? -ne 0 ]; do
arduino-cli upload -b $board -p $port .
done
}
if [ $target == "build" ]; then
build
fi
if [ $target == "upload" ]; then
upload
fi
if [ $target == "all" ]; then
build && upload
fi