-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·164 lines (141 loc) · 3.71 KB
/
build
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
SRC_VER=`cat platformio.ini | grep 'version =' | awk '{print $3}'`
SRC_REV=`cat platformio.ini | grep 'revision =' | awk '{print $3}'`
DATE=`date +%Y%m%d`
OUTDIR=".pio/build"
RELDIR="releases"
BINDIR="binaries"
DEFAULT="robot"
INSDIR=$RELDIR/installer/airobot_installer
showHelp () {
echo ""
echo "************************************************"
echo "** Build release flavor or installer package **"
echo "************************************************"
echo ""
echo "Usage: ./build [board|all|installer|help|print]"
echo ""
echo "example: ./build all"
echo "example: ./build robot"
echo "example: ./build joystick"
echo ""
echo "Build installer option will make a installer package for Linux"
echo "with OTA support and USB support"
echo ""
}
updateInstallerBinaries () {
echo ""
echo "***********************************************"
echo "** Update installer binaries.."
echo "***********************************************"
echo ""
cp $OUTDIR/$DEFAULT/partitions.bin $INSDIR/system/
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin $INSDIR/system/
cp ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin $INSDIR/system/
cp ~/.platformio/packages/tool-esptoolpy/esptool.py $INSDIR/system/
cp ~/.platformio/packages/framework-arduinoespressif32/tools/espota.py $INSDIR/system/
chmod 755 $INSDIR/install.sh
}
updateFlavorBinaries() {
rm -f $INSDIR/*.bin
rm -f $INSDIR/*.py # old installer
cp $RELDIR/$BINDIR/*/*${DATE}.bin $INSDIR/
}
clean () {
rm -r $RELDIR/$BINDIR
}
build () {
pio run -s -e $1 -t clean
echo ""
echo "***********************************************"
echo "** Building $1"
echo "***********************************************"
echo ""
pio run -s -e $1
echo ""
echo "***********************************************"
echo "** Firmware $1 output:"
echo -n "** MD5:"
FIRMDIR=$RELDIR/$BINDIR/$1
mkdir -p $FIRMDIR
cp $OUTDIR/$1/firmware.bin $FIRMDIR/airobot_${1}_rev${SRC_REV}_${DATE}.bin
md5sum $FIRMDIR/airobot_${1}_rev${SRC_REV}_${DATE}.bin
echo "***********************************************"
echo ""
}
buildInstaller () {
echo ""
mkdir -p $INSDIR/system
updateInstallerBinaries
updateFlavorBinaries
printOutput
cd $INSDIR/..
rm -f airobot_rev${SRC_REV}_${DATE}.zip
zip -r airobot_rev${SRC_REV}_${DATE}.zip airobot_installer
echo ""
du -hs airobot_rev${SRC_REV}_${DATE}.zip
echo ""
}
publish_release () {
cd $INSDIR/..
COMMIT_LOG=`git log -1 --format='%ci %H %s'`
tag="v${SRC_VER}"
rname="rev${SRC_REV}v${SRC_VER}"
echo "***********************************************"
echo "** Publishing release $tag ($rname)"
echo "***********************************************"
echo ""
github-release upload --owner hpsaturn --repo airobot --tag $tag --release-name $rname --body "${COMMIT_LOG}" airobot_rev${SRC_REV}_${DATE}.zip
}
printOutput () {
echo ""
mkdir -p $INSDIR
FIRMDIR=$RELDIR/$BINDIR
rm -f $INSDIR/md5output.txt
touch $INSDIR/md5output.txt
cd $FIRMDIR
for flavor in *; do
MD5FLAVOR=`md5sum $flavor/airobot_${flavor}_rev${SRC_REV}_${DATE}.bin`
echo $MD5FLAVOR >> ../../$INSDIR/md5output.txt
done
cat ../../$INSDIR/md5output.txt
cd ../..
echo ""
}
if [ "$1" = "" ]; then
showHelp
else
case "$1" in
clean)
clean
;;
installer)
buildInstaller
;;
help)
showHelp
;;
--help)
showHelp
;;
-help)
showHelp
;;
print)
printOutput
;;
all)
clean
build robot
build joystick
printOutput
;;
publish)
publish_release
;;
*)
build $1
;;
esac
fi
exit 0