Fix mftest -b and -u. Add --help.
This commit is contained in:
parent
1087e318e5
commit
71ec89a112
1 changed files with 29 additions and 17 deletions
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# mftest Select a test to apply and build
|
# mftest Select a test to apply and build
|
||||||
# mftest -b Build the auto-detected environment
|
# mftest -b [#] Build the auto-detected environment
|
||||||
# mftest -u Upload the auto-detected environment
|
# mftest -u [#] Upload the auto-detected environment
|
||||||
# mftest [name] [index] [-y] Set config options and optionally build a test
|
# mftest [name] [index] [-y] Set config options and optionally build a test
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -47,6 +47,18 @@ case $TESTENV in
|
||||||
t32) TESTENV='teensy31' ;;
|
t32) TESTENV='teensy31' ;;
|
||||||
t35) TESTENV='teensy35' ;;
|
t35) TESTENV='teensy35' ;;
|
||||||
t36) TESTENV='teensy35' ;;
|
t36) TESTENV='teensy35' ;;
|
||||||
|
|
||||||
|
-h|--help) echo -e "$(basename $0) : Marlin Firmware test, build, and upload\n"
|
||||||
|
echo "Usage: $(basename $0) ................. Select env and test to apply / run"
|
||||||
|
echo " $(basename $0) [-y] env ........ Select a test for env to apply / run"
|
||||||
|
echo " $(basename $0) [-y] env test ... Apply / run the specified env test"
|
||||||
|
echo " $(basename $0) -b [variant] .... Auto-build the specified variant"
|
||||||
|
echo " $(basename $0) -u [variant] .... Auto-build and upload the specified variant"
|
||||||
|
echo
|
||||||
|
echo "env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
|
||||||
# Build with the last-built env
|
# Build with the last-built env
|
||||||
-r) [[ -f "$STATE_FILE" ]] || { echo "No previous (-r) build state found." ; exit 1 ; }
|
-r) [[ -f "$STATE_FILE" ]] || { echo "No previous (-r) build state found." ; exit 1 ; }
|
||||||
read TESTENV <"$STATE_FILE"
|
read TESTENV <"$STATE_FILE"
|
||||||
|
@ -54,26 +66,26 @@ case $TESTENV in
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-[bu]) MB=$( grep "define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' )
|
-[bu]) MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' )
|
||||||
[[ -z $MB ]] && { echo "Error - Unable to read MOTHERBOARD setting." ; exit 1 ; }
|
[[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; }
|
||||||
BLINE=$( grep "define BOARD_$MB" Marlin/src/core/boards.h )
|
BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
|
||||||
BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
|
BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
|
||||||
BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
|
BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
|
||||||
[[ -z $BNUM ]] && { echo "Error - Unable to $MB in boards list." ; exit 1 ; }
|
[[ -z $BNUM ]] && { echo "Error - Can't find $MB in boards list." ; exit 1 ; }
|
||||||
readarray -t ENVS <<< $( grep -A1 "MB($MB)" Marlin/src/pins/pins.h | $SED -n '2 p' | grep -oE 'env:[^ ]+' | $SED -E 's/env://' )
|
readarray -t ENVS <<< $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | $SED -n '2 p' | grep -oE 'env:[^ ]+' | $SED -E 's/env://' )
|
||||||
[[ -z $ENVS ]] && { echo "Error - Unable to find target(s) for $MB ($BNUM)." ; exit 1 ; }
|
[[ -z $ENVS ]] && { echo "Error - Can't find target(s) for $MB ($BNUM)." ; exit 1 ; }
|
||||||
ECOUNT=${#ENVS[*]}
|
ECOUNT=${#ENVS[*]}
|
||||||
|
|
||||||
if [[ $ECOUNT == 1 ]]; then
|
if [[ $ECOUNT == 1 ]]; then
|
||||||
TARGET=$ENVS
|
TARGET=$ENVS
|
||||||
else
|
else
|
||||||
|
if [[ $CHOICE == 0 ]]; then
|
||||||
#
|
#
|
||||||
# List env names and numbers. Get selection.
|
# List env names and numbers. Get selection.
|
||||||
#
|
#
|
||||||
if [[ $CHOICE == 0 ]]; then
|
|
||||||
echo "Available targets for \"$BDESC\" | $MB ($BNUM):"
|
echo "Available targets for \"$BDESC\" | $MB ($BNUM):"
|
||||||
|
|
||||||
IND=0 ; for ENV in "${ENVS[@]}"; do echo " $IND) $ENV" ; done
|
IND=0 ; for ENV in "${ENVS[@]}"; do let IND++ ; echo " $IND) $ENV" ; done
|
||||||
|
|
||||||
if [[ $ECOUNT > 1 ]]; then
|
if [[ $ECOUNT > 1 ]]; then
|
||||||
for (( ; ; ))
|
for (( ; ; ))
|
||||||
|
@ -87,7 +99,7 @@ case $TESTENV in
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Detected \"$BDESC\" | $MB ($BNUM)."
|
echo "Detected \"$BDESC\" | $MB ($BNUM)."
|
||||||
[[ $CHOICE > $ECOUNT ]] && { echo "Environment selection is out of range." ; exit 1 ; }
|
[[ $CHOICE > $ECOUNT ]] && { echo "Environment selection out of range." ; exit 1 ; }
|
||||||
fi
|
fi
|
||||||
TARGET="${ENVS[$CHOICE-1]}"
|
TARGET="${ENVS[$CHOICE-1]}"
|
||||||
echo "Selected $TARGET"
|
echo "Selected $TARGET"
|
||||||
|
|
Reference in a new issue