@@ -37,6 +37,7 @@ PATH="$HERE:$PATH"
37
37
. mfutil
38
38
39
39
annc () { echo -e " \033[0;32m$1 \033[0m" ; }
40
+ alrt () { echo -e " \033[0;31m$1 \033[0m" ; }
40
41
41
42
# Get arguments
42
43
BUILD=./.pio/build
@@ -153,8 +154,7 @@ ENAME=("-name" "marlin_config.json" \
153
154
" -o" " -name" " schema.yml" )
154
155
155
156
# Possible built firmware names (in the build folder)
156
- BNAME=(" -type" " f" \
157
- " -name" ' firmware*.hex' \
157
+ BNAME=(" -name" ' firmware*.hex' \
158
158
" -o" " -name" " firmware*.bin" \
159
159
" -o" " -name" " project*.bin" \
160
160
" -o" " -name" " Robin*.bin" \
@@ -176,44 +176,54 @@ set +e
176
176
echo " Building example $CONFIG ..."
177
177
mftest -s -a -n1 ; ERR=$?
178
178
179
- (( ERR)) && echo " Failed" || echo " Success"
179
+ (( ERR)) && alrt " Failed ( $ERR ) " || annc " Success"
180
180
181
181
set -e
182
182
183
- # Copy exports back to the configs
184
- if [[ -n $EXPNUM ]]; then
185
- annc " Exporting $EXPNUM "
186
- [[ -f Marlin/Config-export.h ]] && { cp Marlin/Config-export.h " $ARCSUB " /Config.h ; }
187
- find " $BUILD " " ${ENAME[@]} " -exec cp " {}" " $ARCSUB " \;
188
- fi
183
+ if [[ $ERR -gt 0 ]]; then
189
184
190
- # Copy potential firmware files into the config folder
191
- # TODO: Consider firmware that needs an STM32F4_UPDATE folder.
192
- # Currently only BOARD_CREALITY_F401RE env:STM32F401RE_creality
193
- if (( ARCHIVE)) ; then
194
- annc " Archiving"
195
- rm -f " $ARCSUB " /* .bin.tar.gz " $ARCSUB " /* .hex.tar.gz
196
- find " $BUILD " \( " ${BNAME[@]} " \) -exec sh -c '
197
- ARCSUB="$1"
198
- CONFIG="$2"
199
- shift 2
200
- for FILE in "$@"; do
201
- cd "${FILE%/*}"
202
- BASE=${FILE##*/}
203
- SHRT=${BASE%.*}
204
- SHASUM=$(sha256sum "$BASE" | cut -d" " -f1)
205
- tar -czf "$ARCSUB/$SHRT.tar.gz" "$BASE"
206
- echo "$CONFIG\n$SHASUM" > "$ARCSUB/$BASE.sha256.txt"
207
- rm "$BASE"
208
- cd - >/dev/null
209
- done
210
- ' sh " $ARCSUB " " $CONFIG " {} +
211
- fi
185
+ # Error? For --nofail simply log. Otherwise return the error.
186
+ if [[ -n $NOFAIL ]]; then
187
+ date +" %F %T [FAIL] $CONFIG " >> ./.pio/error-log.txt
188
+ else
189
+ exit $ERR
190
+ fi
212
191
213
- # Exit with error unless --nofail is set
214
- [[ $ERR -gt 0 && -z $NOFAIL ]] && exit $ERR
192
+ else
215
193
216
- # Reveal the configs after the build, if requested
217
- (( REVEAL)) && { annc " Revealing $ARCSUB " ; open " $ARCSUB " ; }
194
+ # Copy exports back to the configs
195
+ if [[ -n $EXPNUM ]]; then
196
+ annc " Exporting $EXPNUM "
197
+ [[ -f Marlin/Config-export.h ]] && { cp Marlin/Config-export.h " $ARCSUB " /Config.h ; }
198
+ find " $BUILD " \( " ${ENAME[@]} " \) -exec cp " {}" " $ARCSUB " \;
199
+ fi
200
+
201
+ # Copy potential firmware files into the config folder
202
+ # TODO: Consider firmware that needs an STM32F4_UPDATE folder.
203
+ # Currently only BOARD_CREALITY_F401RE env:STM32F401RE_creality
204
+ if (( ARCHIVE)) ; then
205
+ annc " Archiving"
206
+ rm -f " $ARCSUB " /* .bin.tar.gz " $ARCSUB " /* .hex.tar.gz
207
+ find " $BUILD " \( " ${BNAME[@]} " \) -exec sh -c '
208
+ ARCSUB="$1"
209
+ CONFIG="$2"
210
+ shift 2
211
+ for FILE in "$@"; do
212
+ cd "${FILE%/*}"
213
+ NAME=${FILE##*/}
214
+ SHRT=${NAME%.*}
215
+ SHASUM=$(sha256sum "$NAME" | cut -d" " -f1)
216
+ tar -czf "$ARCSUB/$SHRT.tar.gz" "$NAME"
217
+ echo "$CONFIG\n$SHASUM" > "$ARCSUB/$NAME.sha256.txt"
218
+ rm "$NAME"
219
+ cd - >/dev/null
220
+ done
221
+ ' sh " $ARCSUB " " $CONFIG " {} +
222
+ fi
223
+
224
+ # Reveal the configs after the build, if requested
225
+ (( REVEAL)) && { annc " Revealing $ARCSUB " ; open " $ARCSUB " ; }
226
+
227
+ fi
218
228
219
229
exit 0
0 commit comments