update code base to Marlin 2.0.9.2
This commit is contained in:
@@ -14,11 +14,9 @@ FORK=${INFO[1]}
|
||||
REPO=${INFO[2]}
|
||||
BRANCH=${INFO[5]}
|
||||
|
||||
git push --set-upstream origin $BRANCH
|
||||
git push --set-upstream origin HEAD:$BRANCH
|
||||
|
||||
which xdg-open >/dev/null && TOOL=xdg-open
|
||||
which gnome-open >/dev/null && TOOL=gnome-open
|
||||
which open >/dev/null && TOOL=open
|
||||
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
|
||||
URL="https://github.com/$FORK/$REPO/commits/$BRANCH"
|
||||
|
||||
if [ -z "$OPEN" ]; then
|
||||
|
@@ -5,29 +5,35 @@
|
||||
# Set all remotes in the current repo to HTTPS or SSH connection.
|
||||
# Useful when switching environments, using public wifi, etc.
|
||||
#
|
||||
# Optionally, specify a particular remote to change.
|
||||
#
|
||||
|
||||
GH_SSH="git@github\.com:"
|
||||
GH_HTTPS="https:\/\/github\.com\/"
|
||||
|
||||
case "$1" in
|
||||
-[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;;
|
||||
-[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;;
|
||||
-[Hh]) TYPE=HTTPS ; MATCH="git@" ; REPLACE="$GH_SSH/$GH_HTTPS" ;;
|
||||
-[Ss]) TYPE=SSH ; MATCH="https:" ; REPLACE="$GH_HTTPS/$GH_SSH" ;;
|
||||
*)
|
||||
echo "usage: `basename $0` -h | -s" 1>&2
|
||||
echo "Usage: `basename $0` -h | -s" 1>&2
|
||||
echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2
|
||||
echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
REMOTES=$(git remote -v | egrep "\t$MATCH" | gawk '{print $1 " " $2}' | sort -u | sed "s/$FORMULA/")
|
||||
AWK=$(which gawk || which awk)
|
||||
|
||||
if [[ -z $REMOTES ]]; then
|
||||
echo "Nothing to do." ; exit
|
||||
fi
|
||||
# Match all or specified remotes of the other type
|
||||
REGEX="\t$MATCH" ; [[ $# > 1 ]] && REGEX="^$2$REGEX"
|
||||
|
||||
REMOTES=$(git remote -v | egrep "$REGEX" | "$AWK" '{print $1 " " $2}' | sort -u | sed "s/$REPLACE/")
|
||||
|
||||
[[ -z $REMOTES ]] && { echo "Nothing to do." ; exit ; }
|
||||
|
||||
# Update a remote for each results pair
|
||||
echo "$REMOTES" | xargs -n2 git remote set-url
|
||||
|
||||
echo -n "Remotes set to $TYPE: "
|
||||
echo "$REMOTES" | gawk '{printf "%s ", $1}'
|
||||
echo "$REMOTES" | "$AWK" '{printf "%s ", $1}'
|
||||
echo
|
||||
|
@@ -6,6 +6,8 @@
|
||||
# Great way to clean up your branches after messing around a lot
|
||||
#
|
||||
|
||||
AWK=$(which gawk || which awk)
|
||||
|
||||
KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2"
|
||||
|
||||
echo "Fetching latest upstream and origin..."
|
||||
@@ -18,7 +20,7 @@ git branch --merged | egrep -v "^\*|$KEEP" | xargs -n 1 git branch -d
|
||||
echo
|
||||
|
||||
echo "Pruning Remotely-deleted Branches..."
|
||||
git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | gawk '{print $1}' | xargs -n 1 git branch -D
|
||||
git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | "$AWK" '{print $1}' | xargs -n 1 git branch -D
|
||||
echo
|
||||
|
||||
# List fork branches that don't match local branches
|
||||
|
193
buildroot/share/git/mfconfig
Executable file
193
buildroot/share/git/mfconfig
Executable file
@@ -0,0 +1,193 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mfconfig init source dest
|
||||
# mfconfig manual source dest
|
||||
#
|
||||
# The MarlinFirmware/Configurations layout could be broken up into branches,
|
||||
# but this makes management more complicated and requires more commits to
|
||||
# perform the same operation, so this uses a single branch with subfolders.
|
||||
#
|
||||
# init - Initialize the repo with a base commit and changes:
|
||||
# - Source will be an 'import' branch containing all current configs.
|
||||
# - Create an empty 'BASE' branch from 'init-repo'.
|
||||
# - Add Marlin config files, but reset all to defaults.
|
||||
# - Commit this so changes will be clear in following commits.
|
||||
# - Add changed Marlin config files and commit.
|
||||
#
|
||||
# manual - Manually import changes from the Marlin repo
|
||||
# - Replace 'default' configs with those from the Marlin repo.
|
||||
# - Wait for manual propagation to the rest of the configs.
|
||||
# - Run init with the given 'source' and 'dest'
|
||||
#
|
||||
|
||||
REPOHOME="`dirname ~/Projects/Maker/Firmware/.`"
|
||||
MARLINREPO="$REPOHOME/MarlinFirmware"
|
||||
CONFIGREPO="$REPOHOME/Configurations"
|
||||
|
||||
CEXA=config/examples
|
||||
CDEF=config/default
|
||||
BC=Configuration.h
|
||||
AC=Configuration_adv.h
|
||||
|
||||
COMMIT_STEPS=0
|
||||
|
||||
#cd "$CONFIGREPO" 2>/dev/null || { echo "Can't find Configurations repo!" ; exit 1; }
|
||||
|
||||
ACTION=${1:-init}
|
||||
IMPORT=${2:-"import-2.0.x"}
|
||||
EXPORT=${3:-"bugfix-2.0.x"}
|
||||
|
||||
echo -n "Doing grhh ... " ; grhh ; echo
|
||||
|
||||
if [[ $ACTION == "manual" ]]; then
|
||||
|
||||
#
|
||||
# Copy the latest default configs from MarlinFirmware/Marlin
|
||||
# or one of the import branches here, then use them to construct
|
||||
# a 'BASE' branch with only defaults as a starting point.
|
||||
#
|
||||
|
||||
echo "- Updating '$IMPORT' from Marlin..."
|
||||
|
||||
git checkout $IMPORT || exit
|
||||
|
||||
# Reset from the latest complete state
|
||||
#git reset --hard bugfix-2.0.x
|
||||
|
||||
cp "$MARLINREPO/Marlin/"Configuration*.h "$CDEF/"
|
||||
#git add . && git commit -m "Changes from Marlin ($(date '+%Y-%m-%d %H:%M'))."
|
||||
|
||||
echo "- Fix up the import branch and come back."
|
||||
|
||||
read -p "- Ready to init [y/N] ?" INIT_YES
|
||||
echo
|
||||
|
||||
[[ $INIT_YES == 'Y' || $INIT_YES == 'y' ]] || { echo "Done." ; exit ; }
|
||||
|
||||
ACTION='init'
|
||||
fi
|
||||
|
||||
if [[ $ACTION == "init" ]]; then
|
||||
#
|
||||
# Copy all configs from a source such as MarlinFirmware/Marlin
|
||||
# or one of the import branches here, then use them to construct
|
||||
# a 'BASE' branch with only defaults as a starting point.
|
||||
#
|
||||
|
||||
echo "- Initializing BASE branch..."
|
||||
|
||||
# Use the import branch as the source
|
||||
git checkout $IMPORT || exit
|
||||
|
||||
# Copy to a temporary location
|
||||
TEMP=$( mktemp -d ) ; cp -R config $TEMP
|
||||
|
||||
# Make sure we're not on the 'BASE' branch...
|
||||
git checkout init-repo >/dev/null 2>&1 || exit
|
||||
|
||||
# Create 'BASE' as a copy of 'init-repo' (README, LICENSE, etc.)
|
||||
git branch -D BASE 2>/dev/null
|
||||
git checkout init-repo -b BASE || exit
|
||||
|
||||
# Copy all config files into place
|
||||
echo "- Copying all configs from fresh $IMPORT..."
|
||||
cp -R "$TEMP/config" .
|
||||
|
||||
# Delete anything that's not a Configuration file
|
||||
find config -type f \! -name "Configuration*" -exec rm "{}" \;
|
||||
|
||||
# DEBUG: Commit the original config files for comparison
|
||||
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null
|
||||
|
||||
# Init Cartesian/SCARA/TPARA configurations to default
|
||||
echo "- Initializing Cartesian/SCARA/TPARA configs to default state..."
|
||||
|
||||
find "$CEXA" -name $BC ! -path */delta/* -print0 \
|
||||
| while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
|
||||
find "$CEXA" -name $AC ! -path */delta/* -print0 \
|
||||
| while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
|
||||
|
||||
# DEBUG: Commit the reset for review
|
||||
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Cartesian/SCARA/TPARA configs..." >/dev/null
|
||||
|
||||
# Create base Delta configurations
|
||||
cp "$CDEF"/* "$CEXA/delta/generic"
|
||||
|
||||
# DEBUG: Commit the reset for review
|
||||
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Generic Delta..." >/dev/null
|
||||
|
||||
cp -R "$TEMP/$CEXA/delta/generic"/Conf* "$CEXA/delta/generic"
|
||||
|
||||
# DEBUG: Commit Generic Delta changes for review
|
||||
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Apply Generic Delta..." >/dev/null
|
||||
|
||||
# Reset all Delta configs to the generic version
|
||||
find "$CEXA/delta" -name $BC ! -path */generic/* -print0 \
|
||||
| while read -d $'\0' F ; do cp "$CEXA/delta/generic/$BC" "$F" ; done
|
||||
find "$CEXA/delta" -name $AC ! -path */generic/* -print0 \
|
||||
| while read -d $'\0' F ; do cp "$CEXA/delta/generic/$AC" "$F" ; done
|
||||
|
||||
# DEBUG: Commit the Delta reset for review
|
||||
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Delta configs..." >/dev/null
|
||||
|
||||
# Reset all SCARA configs to the default cartesian
|
||||
find "$CEXA/SCARA" -name $BC \
|
||||
| while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
|
||||
find "$CEXA/SCARA" -name $AC \
|
||||
| while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
|
||||
|
||||
# DEBUG: Commit the SCARA reset for review
|
||||
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset SCARA..." >/dev/null
|
||||
|
||||
# Reset all TPARA configs to the default cartesian
|
||||
find "$CEXA/TPARA" -name $BC \
|
||||
| while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
|
||||
find "$CEXA/TPARA" -name $AC \
|
||||
| while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
|
||||
|
||||
# DEBUG: Commit the TPARA reset for review
|
||||
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null
|
||||
|
||||
# Update the %VERSION% in the README.md file
|
||||
SED=$(which gsed sed | head -n1)
|
||||
VERS=$( echo $EXPORT | $SED 's/release-//' )
|
||||
eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
|
||||
rm -f README.md~
|
||||
|
||||
# NOT DEBUGGING: Commit the 'BASE', ready for customizations
|
||||
((COMMIT_STEPS)) || git add . >/dev/null && git commit --amend --no-edit >/dev/null
|
||||
|
||||
# Create a new branch from 'BASE' for the final result
|
||||
echo "- Creating '$EXPORT' branch for the result..."
|
||||
git branch -D $EXPORT 2>/dev/null
|
||||
git checkout -b $EXPORT || exit
|
||||
|
||||
# Delete temporary branch
|
||||
git branch -D BASE 2>/dev/null
|
||||
|
||||
echo "- Applying example config customizations..."
|
||||
cp -R "$TEMP/config" .
|
||||
find config -type f \! -name "Configuration*" -exec rm "{}" \;
|
||||
|
||||
echo "- Adding path labels to all configs..."
|
||||
config-labels.py >/dev/null 2>&1
|
||||
|
||||
git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null
|
||||
|
||||
echo "- Copying extras from Marlin..."
|
||||
cp -R "$TEMP/config" .
|
||||
|
||||
# Apply labels again!
|
||||
config-labels.py >/dev/null 2>&1
|
||||
|
||||
git add . >/dev/null && git commit -m "Examples Extras" >/dev/null
|
||||
|
||||
rm -rf $TEMP
|
||||
|
||||
git push -f --set-upstream upstream "$EXPORT"
|
||||
|
||||
else
|
||||
|
||||
echo "Usage: mfconfig init|manual|rebase"
|
||||
|
||||
fi
|
@@ -49,7 +49,8 @@ while [[ $# -gt 0 ]]; do
|
||||
done
|
||||
|
||||
case "$REPO" in
|
||||
Marlin ) TARG=bugfix-1.1.x ; [[ $INDEX == 2 ]] && TARG=bugfix-2.0.x ; [[ $INDEX == 3 ]] && TARG=dev-2.1.x ;;
|
||||
Marlin ) TARG=bugfix-2.0.x ; [[ $INDEX == 1 ]] && TARG=bugfix-1.1.x ; [[ $INDEX == 3 ]] && TARG=dev-2.1.x ;;
|
||||
Configurations ) TARG=import-2.0.x ;;
|
||||
MarlinDocumentation ) TARG=master ;;
|
||||
esac
|
||||
|
||||
|
@@ -23,9 +23,7 @@ OLDBRANCH=${INFO[5]}
|
||||
# See if it's been pushed yet
|
||||
if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi
|
||||
|
||||
which xdg-open >/dev/null && TOOL=xdg-open
|
||||
which gnome-open >/dev/null && TOOL=gnome-open
|
||||
which open >/dev/null && TOOL=open
|
||||
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
|
||||
URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
|
||||
|
||||
if [ -z "$OPEN" ]; then
|
||||
|
@@ -67,11 +67,11 @@ if [[ $BRANCH == $TARG ]]; then
|
||||
# Allow working directly with the main fork
|
||||
echo
|
||||
echo -n "Pushing to origin/$TARG... "
|
||||
git push -f origin
|
||||
git push origin HEAD:$TARG
|
||||
|
||||
echo
|
||||
echo -n "Pushing to upstream/$TARG... "
|
||||
git push -f upstream
|
||||
git push upstream HEAD:$TARG
|
||||
|
||||
else
|
||||
|
||||
@@ -126,7 +126,7 @@ git push -f origin
|
||||
git push -f upstream | {
|
||||
while IFS= read -r line
|
||||
do
|
||||
[[ $line =~ "gh-pages -> gh-pages" ]] && opensite "http://marlinfw.org/"
|
||||
[[ $line =~ "gh-pages -> gh-pages" ]] && opensite "https://marlinfw.org/"
|
||||
echo "$line"
|
||||
done
|
||||
}
|
||||
@@ -135,4 +135,4 @@ git push -f upstream | {
|
||||
rm -rf ${TMPFOLDER}
|
||||
|
||||
# Go back to the branch we started from
|
||||
[[ $BRANCH != $CURR ]] && git checkout $BRANCH && [[ $HAS_STASH == 1 ]] && git stash pop
|
||||
git checkout $CURR && [[ $HAS_STASH == 1 ]] && git stash pop
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# - git add .
|
||||
# - git commit --amend
|
||||
# - ghpc
|
||||
# - git push -f
|
||||
#
|
||||
|
||||
MFINFO=$(mfinfo "$@") || exit 1
|
||||
@@ -17,6 +17,7 @@ IND=6
|
||||
while [ $IND -lt ${#INFO[@]} ]; do
|
||||
ARG=${INFO[$IND]}
|
||||
case "$ARG" in
|
||||
-f|--force ) FORCE=1 ;;
|
||||
-h|--help ) USAGE=1 ;;
|
||||
* ) USAGE=1 ; echo "unknown option: $ARG" ;;
|
||||
esac
|
||||
@@ -25,6 +26,6 @@ done
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
|
||||
|
||||
[[ $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; }
|
||||
[[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; }
|
||||
|
||||
git add . && git commit --amend && git push -f
|
||||
|
@@ -23,8 +23,5 @@ done
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
|
||||
|
||||
# If the branch isn't currently the PR target
|
||||
if [[ $TARG != $CURR ]]; then
|
||||
[[ $QUICK ]] || git fetch upstream
|
||||
git rebase upstream/$TARG && git rebase -i upstream/$TARG
|
||||
fi
|
||||
[[ $QUICK ]] || git fetch upstream
|
||||
git rebase upstream/$TARG && git rebase -i upstream/$TARG
|
||||
|
@@ -1,233 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mftest Select a test to apply and build
|
||||
# mftest -b [#] Build the auto-detected environment
|
||||
# mftest -u [#] Upload the auto-detected environment
|
||||
# mftest [name] [index] [-y] Set config options and optionally build a test
|
||||
#
|
||||
|
||||
MFINFO=$(mfinfo) || exit 1
|
||||
[[ -d Marlin/src ]] || { echo "Please 'cd' up to repo root." ; exit 1 ; }
|
||||
|
||||
TESTPATH=buildroot/share/tests
|
||||
STATE_FILE=$( echo ./.pio/.mftestrc )
|
||||
SED=$(which gsed || which sed)
|
||||
|
||||
shopt -s extglob nocasematch
|
||||
|
||||
# Matching patterns
|
||||
ISNUM='^[0-9]+$'
|
||||
ISCMD='^(restore|opt|exec|use|pins|env)_'
|
||||
ISEXEC='^exec_'
|
||||
ISCONT='\\ *$'
|
||||
|
||||
# Get the environment and test number from the command
|
||||
TESTENV=${1:-'-'}
|
||||
CHOICE=${2:-0}
|
||||
AUTOENV=0
|
||||
|
||||
# Allow shorthand for test name
|
||||
case $TESTENV in
|
||||
tree) pio run -d . -e include_tree ; exit 1 ;;
|
||||
due) TESTENV='DUE' ;;
|
||||
esp) TESTENV='esp32' ;;
|
||||
lin*) TESTENV='linux_native' ;;
|
||||
lpc?(8)) TESTENV='LPC1768' ;;
|
||||
lpc9) TESTENV='LPC1769' ;;
|
||||
m128) TESTENV='mega1280' ;;
|
||||
m256) TESTENV='mega2560' ;;
|
||||
mega) TESTENV='mega2560' ;;
|
||||
stm) TESTENV='STM32F103RE' ;;
|
||||
f1) TESTENV='STM32F103RE' ;;
|
||||
f4) TESTENV='STM32F4' ;;
|
||||
f7) TESTENV='STM32F7' ;;
|
||||
s6) TESTENV='FYSETC_S6' ;;
|
||||
teensy) TESTENV='teensy31' ;;
|
||||
t31) TESTENV='teensy31' ;;
|
||||
t32) TESTENV='teensy31' ;;
|
||||
t35) 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
|
||||
-r) [[ -f "$STATE_FILE" ]] || { echo "No previous (-r) build state found." ; exit 1 ; }
|
||||
read TESTENV <"$STATE_FILE"
|
||||
pio run -d . -e $TESTENV
|
||||
exit
|
||||
;;
|
||||
|
||||
-[bu]) MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' )
|
||||
[[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; }
|
||||
BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
|
||||
BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
|
||||
BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
|
||||
[[ -z $BNUM ]] && { echo "Error - Can't find $MB in boards list." ; exit 1 ; }
|
||||
readarray -t ENVS <<< $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | grep -E '#include.+//.+env:.+' | grep -oE 'env:[^ ]+' | $SED -E 's/env://' )
|
||||
[[ -z $ENVS ]] && { echo "Error - Can't find target(s) for $MB ($BNUM)." ; exit 1 ; }
|
||||
ECOUNT=${#ENVS[*]}
|
||||
|
||||
if [[ $ECOUNT == 1 ]]; then
|
||||
TARGET=$ENVS
|
||||
else
|
||||
if [[ $CHOICE == 0 ]]; then
|
||||
#
|
||||
# List env names and numbers. Get selection.
|
||||
#
|
||||
echo "Available targets for \"$BDESC\" | $MB ($BNUM):"
|
||||
|
||||
IND=0 ; for ENV in "${ENVS[@]}"; do let IND++ ; echo " $IND) $ENV" ; done
|
||||
|
||||
if [[ $ECOUNT > 1 ]]; then
|
||||
for (( ; ; ))
|
||||
do
|
||||
read -p "Select a target for '$MB' (1-$ECOUNT) : " CHOICE
|
||||
[[ -z "$CHOICE" ]] && { echo '(canceled)' ; exit 1 ; }
|
||||
[[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= ECOUNT)) && break
|
||||
echo ">>> Invalid environment choice '$CHOICE'."
|
||||
done
|
||||
echo
|
||||
fi
|
||||
else
|
||||
echo "Detected \"$BDESC\" | $MB ($BNUM)."
|
||||
[[ $CHOICE > $ECOUNT ]] && { echo "Environment selection out of range." ; exit 1 ; }
|
||||
fi
|
||||
TARGET="${ENVS[$CHOICE-1]}"
|
||||
echo "Selected $TARGET"
|
||||
fi
|
||||
|
||||
echo "$TARGET" >"$STATE_FILE"
|
||||
|
||||
if [[ $TESTENV == "-u" ]]; then
|
||||
echo "Build/Uploading environment $TARGET for board $MB ($BNUM)..." ; echo
|
||||
pio run -t upload -e $TARGET
|
||||
else
|
||||
echo "Building environment $TARGET for board $MB ($BNUM)..." ; echo
|
||||
pio run -e $TARGET
|
||||
fi
|
||||
exit
|
||||
;;
|
||||
|
||||
# The -y flag may come first
|
||||
-y) TESTENV=${2:-'-'} ; CHOICE=${3:-0} ;;
|
||||
|
||||
-[a-z]) echo "Unknown flag $TESTENV" ; exit 1 ;;
|
||||
-) ;;
|
||||
esac
|
||||
|
||||
#
|
||||
# List available tests and ask for selection
|
||||
#
|
||||
|
||||
if [[ $TESTENV == '-' ]]; then
|
||||
IND=0
|
||||
NAMES=()
|
||||
for FILE in $( ls -1 $TESTPATH/*-tests )
|
||||
do
|
||||
let IND++
|
||||
TNAME=${FILE/-tests/}
|
||||
TNAME=${TNAME/$TESTPATH\//}
|
||||
NAMES+=($TNAME)
|
||||
(( IND < 10 )) && echo -n " "
|
||||
echo " $IND) $TNAME"
|
||||
done
|
||||
|
||||
echo
|
||||
for (( ; ; ))
|
||||
do
|
||||
read -p "Select a test to apply (1-$IND) : " NAMEIND
|
||||
[[ -z "$NAMEIND" ]] && { echo '(canceled)' ; exit 1 ; }
|
||||
[[ $NAMEIND =~ $ISNUM ]] && ((NAMEIND >= 1 && NAMEIND <= IND)) && { TESTENV=${NAMES[$NAMEIND-1]} ; echo ; break ; }
|
||||
echo "Invalid selection."
|
||||
done
|
||||
fi
|
||||
|
||||
# Get the contents of the test file
|
||||
OUT=$( cat $TESTPATH/$TESTENV-tests 2>/dev/null ) || { echo "Can't find test '$TESTENV'." ; exit 1 ; }
|
||||
|
||||
# Count up the number of tests
|
||||
TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" )
|
||||
|
||||
# User entered a number?
|
||||
(( CHOICE && CHOICE > TESTCOUNT )) && { echo "Invalid test selection '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
|
||||
|
||||
if [[ $CHOICE == 0 ]]; then
|
||||
#
|
||||
# List test descriptions with numbers and get selection
|
||||
#
|
||||
echo "Available '$TESTENV' tests:" ; echo "$OUT" | {
|
||||
IND=0
|
||||
while IFS= read -r LINE
|
||||
do
|
||||
if [[ $LINE =~ $ISEXEC ]]; then
|
||||
DESC=$( "$SED" -E 's/^.+"(.*)".*$/\1/g' <<<"$LINE" )
|
||||
(( ++IND < 10 )) && echo -n " "
|
||||
echo " $IND) $DESC"
|
||||
fi
|
||||
done
|
||||
}
|
||||
CHOICE=1
|
||||
if [[ $TESTCOUNT > 1 ]]; then
|
||||
for (( ; ; ))
|
||||
do
|
||||
read -p "Select a '$TESTENV' test (1-$TESTCOUNT) : " CHOICE
|
||||
[[ -z "$CHOICE" ]] && { echo '(canceled)' ; exit 1 ; }
|
||||
[[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) && break
|
||||
echo ">>> Invalid test selection '$CHOICE'."
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Run the specified test lines
|
||||
#
|
||||
echo "$OUT" | {
|
||||
IND=0
|
||||
GOTX=0
|
||||
CMD=""
|
||||
while IFS= read -r LINE
|
||||
do
|
||||
if [[ $LINE =~ $ISCMD || $GOTX == 1 ]]; then
|
||||
((!IND)) && let IND++
|
||||
if [[ $LINE =~ $ISEXEC ]]; then
|
||||
((IND++ > CHOICE)) && break
|
||||
else
|
||||
((!HEADER)) && {
|
||||
HEADER=1
|
||||
echo -e "\n#\n# Test $TESTENV ($CHOICE) $DESC\n#"
|
||||
}
|
||||
((IND == CHOICE)) && {
|
||||
GOTX=1
|
||||
[[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | $SED -e 's/\\//g' )
|
||||
[[ $LINE =~ $ISCONT ]] || { echo $CMD ; eval "$CMD" ; CMD="" ; }
|
||||
}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Make clear it's a TEST
|
||||
opt_set CUSTOM_MACHINE_NAME "\"$TESTENV-tests ($CHOICE)\""
|
||||
|
||||
# Get a -y parameter the lazy way
|
||||
[[ "$2" == "-y" || "$3" == "-y" ]] && BUILD_YES='Y'
|
||||
|
||||
# Build the test too?
|
||||
if [[ $BUILD_YES != 'Y' ]]; then
|
||||
echo
|
||||
read -p "Build $TESTENV test #$CHOICE (y/N) ? " BUILD_YES
|
||||
fi
|
||||
|
||||
[[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && {
|
||||
pio run -d . -e $TESTENV
|
||||
echo "$TESTENV" >"$STATE_FILE"
|
||||
}
|
Reference in New Issue
Block a user