-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·140 lines (120 loc) · 4.68 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
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
#!/bin/bash
set -e
increment_version ()
{
declare -a part=( ${1//\./ } )
declare new
declare -i carry=1
for (( CNTR=${#part[@]}-1; CNTR>=0; CNTR-=1 )); do
len=${#part[CNTR]}
new=$((part[CNTR]+carry))
part[CNTR]=${new}
# [ ${#new} -gt $len ] && carry=1 || carry=0
# [ $CNTR -gt 0 ] && part[CNTR]=${new: -len} || part[CNTR]=${new}
break;
done
new="${part[*]}"
new="${new// /.}"
echo $new
}
build ()
{
echo ''
echo '###################################################################################################'
echo BUILDING $targetname VERSION $VERSION...
echo '###################################################################################################'
echo ''
set -x
$HOME/arduino_ide/arduino-builder \
-compile \
-hardware $HOME/Arduino/hardware \
-tools $HOME/arduino_ide/tools-builder \
-libraries $HOME/Arduino/libraries \
-fqbn=$FQBN \
-ide-version=10812 \
-build-path $HOME/Arduino/espMQTT/builds/tmp \
-warnings=none \
-build-cache $HOME/Arduino/espMQTT/builds/cache \
-prefs=build.warn_data_percentage=75 \
-prefs="build.extra_flags=-DESP8266 -DWEBSOCKET_DISABLED=true -DASYNC_TCP_SSL_ENABLED -DUSE_HARDWARESERIAL -DESPMQTT_BUILDSCRIPT -DMYTZ=TZ_Europe_Amsterdam -DESPMQTT_VERSION=\"$VERSION\" -D$targetname" \
\"$HOME/Arduino/espMQTT/espMQTT.ino\"
{ set +x; } 2>/dev/null
if [ $? -ne 0 ]
then
echo ''
echo '###################################################################################################'
echo BUILDING $targetname VERSION $VERSION FAILED!!!
echo '###################################################################################################'
echo ''
exit $?
fi
echo $VERSION > $HOME/Arduino/espMQTT/builds/v$VERSION/$targetname.version
cp $HOME/Arduino/espMQTT/builds/tmp/espMQTT.ino.bin $HOME'/Arduino/espMQTT/builds/v'$VERSION'/'$targetname'_'$VERSION.bin
gzip -9 $HOME/Arduino/espMQTT/builds/tmp/espMQTT.ino.bin
mv $HOME/Arduino/espMQTT/builds/tmp/espMQTT.ino.bin.gz $HOME'/Arduino/espMQTT/builds/v'$VERSION'/'$targetname'_'$VERSION.bin.gz
echo ''
echo '###################################################################################################'
echo BUILDING $targetname VERSION $VERSION FINISHED.
echo '###################################################################################################'
echo ''
}
VERSION=$(git describe --tags | sed 's/v//')
DIFFERENCE=$(git diff | wc -w)
TARGET=$1
if [ -z "$TRAVISBUILD" ]
then
if [ $DIFFERENCE -eq 0 ]
then
if [[ $1 == "release" ]]
then
TARGET=$2
# IF CURRENT VERSION CONTAINS A - (SO NOT LATEST TAG) CREATE NEW VERSION TAG
if [[ $VERSION == *"-"* ]]
then
VERSION=$(echo $VERSION | sed 's/-.*//' | sed 's/v//')
VERSION=$(increment_version $VERSION)
git tag v$VERSION
git push --tags
VERSION=$VERSION
fi
fi
else
VERSION=$VERSION-DIRTY-$(date +%s)
fi
fi
VERSION=$VERSION
mkdir -p ./builds/v$VERSION
rm -rf ./builds/tmp
mkdir ./builds/tmp
rm -rf ./builds/cache
mkdir ./builds/cache
echo $VERSION > version
FQBN=esp8266com:esp8266:nodemcuv2:xtal=80,vt=flash,exception=disabled,ssl=basic,eesz=4M,led=2,ip=lm2n,dbg=Disabled,lvl=None____,wipe=none
declare -a TARGETS=("ESPMQTT_WHR930" "ESPMQTT_GROWATT_MODBUS_1" "ESPMQTT_GROWATT_MODBUS_2" "ESPMQTT_DDM18SD" "ESPMQTT_WEATHER" "ESPMQTT_AMGPELLETSTOVE" "ESPMQTT_BATHROOM" "ESPMQTT_BEDROOM2" "ESPMQTT_OPENTHERM" "ESPMQTT_SMARTMETER" "ESPMQTT_GROWATT" "ESPMQTT_SDM120" "ESPMQTT_WATERMETER" "ESPMQTT_DDNS" "ESPMQTT_GENERIC8266" "ESPMQTT_MAINPOWERMETER" "ESPMQTT_NOISE" "ESPMQTT_SOIL" "ESPMQTT_DIMMER" "ESPMQTT_OBD2" "ESPMQTT_LIVINGROOM" "ESPMQTT_BBQTEMP")
for targetname in "${TARGETS[@]}"
do
if [ "$TARGET" == "" ]
then
build
else
if [ "$TARGET" == "$targetname" ]
then
build
fi
fi
done
declare -a TARGETS=("ESPMQTT_BHT002" "ESPMQTT_DUCOBOX" "ESPMQTT_SONOFFS20" "ESPMQTT_SONOFFBULB" "ESPMQTT_SONOFFPOWR2" "ESPMQTT_GARDEN" "ESPMQTT_SONOFF_FLOORHEATING" "ESPMQTT_IRRIGATION" "ESPMQTT_BLITZWOLF" "ESPMQTT_SONOFF4CH" "ESPMQTT_SONOFFDUAL" "ESPMQTT_SONOFFS20_PRINTER" "ESPMQTT_SONOFFPOW" "ESPMQTT_QSWIFIDIMMERD01" "ESPMQTT_QSWIFIDIMMERD02" "ESPMQTT_ZMAI90" "ESPMQTT_SONOFFTH" "ESPMQTT_RELAY" "ESPMQTT_TUYA_2GANGDIMMERV2" "ESPMQTT_QSWIFISWITCH1C" "ESPMQTT_QSWIFISWITCH2C")
#FQBN=esp8266com:esp8266:esp8285:xtal=80,exception=legacy,ssl=all,CrystalFreq=26,eesz=1M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none
FQBN=esp8266com:esp8266:esp8285:xtal=80,vt=flash,exception=disabled,ssl=basic,ResetMethod=nodemcu,CrystalFreq=26,eesz=1M,led=2,ip=lm2n,dbg=Disabled,lvl=None____,wipe=none,baud=115200
for targetname in "${TARGETS[@]}"
do
if [ "$TARGET" == "" ]
then
build
else
if [ "$TARGET" == "$targetname" ]
then
build
fi
fi
done