Merge tag '2.1.2'
This commit is contained in:
@ -16,7 +16,7 @@ BRANCH=${INFO[5]}
|
||||
|
||||
git push --set-upstream origin HEAD:$BRANCH
|
||||
|
||||
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
URL="https://github.com/$FORK/$REPO/commits/$BRANCH"
|
||||
|
||||
if [ -z "$OPEN" ]; then
|
||||
|
173
buildroot/share/git/mfconfig
Executable file
173
buildroot/share/git/mfconfig
Executable file
@ -0,0 +1,173 @@
|
||||
#!/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.1.x"}
|
||||
EXPORT=${3:-"bugfix-2.1.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.1.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.
|
||||
#
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
|
||||
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
|
||||
|
||||
# Strip all #error lines
|
||||
IFS=$'\n'; set -f
|
||||
for fn in $( find $TEMP/config -type f -name "Configuration.h" ); do
|
||||
$SED -i~ -e "20,30{/#error/d}" "$fn"
|
||||
rm "$fn~"
|
||||
done
|
||||
unset IFS; set +f
|
||||
|
||||
# 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 configs to default state..."
|
||||
|
||||
find "$CEXA" -name $BC -print0 \
|
||||
| while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
|
||||
find "$CEXA" -name $AC -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 configs..." >/dev/null
|
||||
|
||||
# Update the %VERSION% in the README.md file
|
||||
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 "{}" \;
|
||||
|
||||
addpathlabels() {
|
||||
find config -name "Conf*.h" -print0 | while read -d $'\0' fn ; do
|
||||
fldr=$(dirname "$fn")
|
||||
blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn")
|
||||
$SED -i~ "${blank_line}i\\\n#define CONFIG_EXAMPLES_DIR \"$fldr\"\\ " "$fn"
|
||||
rm -f "$fn~"
|
||||
done
|
||||
}
|
||||
|
||||
echo "- Adding path labels to all configs..."
|
||||
addpathlabels
|
||||
|
||||
git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null
|
||||
|
||||
echo "- Copying extras from Marlin..."
|
||||
cp -R "$TEMP/config" .
|
||||
|
||||
# Apply labels again!
|
||||
addpathlabels
|
||||
|
||||
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
|
@ -17,7 +17,7 @@ BRANCH=${INFO[5]}
|
||||
|
||||
opensite() {
|
||||
URL="http://127.0.0.1:4000/"
|
||||
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
if [ -z "$OPEN" ]; then
|
||||
echo "Can't find a tool to open the URL:"
|
||||
echo $URL
|
||||
|
@ -1,19 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mffp [1|2|3] [commit-id]
|
||||
# mffp [1|2] [ref]
|
||||
#
|
||||
# Push the given commit (or HEAD) upstream immediately.
|
||||
# By default: `git push upstream HEAD:bugfix-1.1.x`
|
||||
# By default: `git push upstream HEAD:bugfix-2.1.x`
|
||||
#
|
||||
|
||||
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [commit-id]" 1>&2 ; exit 1; }
|
||||
usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 ; }
|
||||
|
||||
if [[ $1 == '1' || $1 == '2' || $1 == '3' ]]; then
|
||||
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; }
|
||||
|
||||
if [[ $1 == '1' || $1 == '2' ]]; then
|
||||
MFINFO=$(mfinfo "$1") || exit 1
|
||||
REF=${2:-HEAD}
|
||||
else
|
||||
elif [[ $# == 1 ]]; then
|
||||
MFINFO=$(mfinfo) || exit 1
|
||||
REF=${1:-HEAD}
|
||||
else
|
||||
usage ; exit 1
|
||||
fi
|
||||
|
||||
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||
|
@ -2,15 +2,19 @@
|
||||
#
|
||||
# mfinfo
|
||||
#
|
||||
# Provide the following info about the working directory:
|
||||
# Print the following info about the working copy:
|
||||
#
|
||||
# - Remote (upstream) Org name (MarlinFirmware)
|
||||
# - Remote (origin) Org name (your Github username)
|
||||
# - Repo Name (Marlin, MarlinDocumentation)
|
||||
# - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, etc.)
|
||||
# - PR Target branch (e.g., bugfix-2.1.x)
|
||||
# - Branch Arg (the branch argument or current branch)
|
||||
# - Current Branch
|
||||
#
|
||||
# Example output
|
||||
# > mfinfo -q ongoing
|
||||
# MarlinFirmware john.doe Marlin bugfix-2.1.x ongoing bugfix-2.1.x -q
|
||||
#
|
||||
|
||||
CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
|
||||
[[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
|
||||
@ -26,36 +30,37 @@ FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
||||
|
||||
# Defaults if no arguments given
|
||||
BRANCH=$CURR
|
||||
INDEX=1
|
||||
MORE=""
|
||||
INDEX=2
|
||||
|
||||
# Loop through arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
# Get an arg and maybe a val to go with it
|
||||
opt="$1" ; shift ; val="$1"
|
||||
|
||||
# Split up an arg containing =
|
||||
IFS='=' read -a PARTS <<<"$opt"
|
||||
[[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
|
||||
|
||||
GOODVAL=1
|
||||
if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
|
||||
GOODVAL=0
|
||||
val=""
|
||||
fi
|
||||
|
||||
case "$opt" in
|
||||
-*|--*) MORE="$MORE$opt " ; [[ $EQUALS == 1 ]] && MORE="$MORE=$val" ;;
|
||||
1|2|3) INDEX=$opt ;;
|
||||
-*|--*) MORE=" $MORE$opt" ; ((EQUALS)) && MORE="$MORE=$val" ;;
|
||||
1|2) INDEX=$opt ;;
|
||||
*) BRANCH="$opt" ;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
case "$REPO" in
|
||||
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 ;;
|
||||
Marlin ) TARG=bugfix-2.1.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;;
|
||||
Configurations ) TARG=import-2.1.x ;;
|
||||
MarlinDocumentation ) TARG=master ;;
|
||||
AutoBuildMarlin ) TARG=master ;;
|
||||
esac
|
||||
|
||||
[[ $BRANCH =~ ^[123]$ ]] && USAGE=1
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1 ; }
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1 ; }
|
||||
|
||||
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR $MORE"
|
||||
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR$MORE"
|
||||
|
@ -5,9 +5,7 @@
|
||||
# Create a new branch from the default target with the given name
|
||||
#
|
||||
|
||||
usage() {
|
||||
echo "usage: `basename $0` [1|2|3] [name]" 1>&2
|
||||
}
|
||||
usage() { echo "usage: `basename $0` [1|2] [name]" 1>&2 ; }
|
||||
|
||||
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
|
||||
|
||||
@ -19,12 +17,12 @@ BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S")
|
||||
# BRANCH can be given as the last argument
|
||||
case "$#" in
|
||||
1 ) case "$1" in
|
||||
1|2|3) ;;
|
||||
1|2) ;;
|
||||
*) BRANCH=$1 ;;
|
||||
esac
|
||||
;;
|
||||
2 ) case "$1" in
|
||||
1|2|3) BRANCH=$2 ;;
|
||||
1|2) BRANCH=$2 ;;
|
||||
*) usage ; exit 1 ;;
|
||||
esac
|
||||
;;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mfpr [1|2|3]
|
||||
# mfpr [1|2]
|
||||
#
|
||||
# Make a PR against bugfix-1.1.x or bugfix-2.0.x
|
||||
# Make a PR targeted to MarlinFirmware/[repo]
|
||||
#
|
||||
|
||||
[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1; }
|
||||
[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1; }
|
||||
|
||||
MFINFO=$(mfinfo "$@") || exit 1
|
||||
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||
@ -23,7 +23,7 @@ OLDBRANCH=${INFO[5]}
|
||||
# See if it's been pushed yet
|
||||
if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi
|
||||
|
||||
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
|
||||
|
||||
if [ -z "$OPEN" ]; then
|
||||
|
80
buildroot/share/git/mfprep
Executable file
80
buildroot/share/git/mfprep
Executable file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mfprep tag1 [tag2]
|
||||
#
|
||||
# Find commits in bugfix-2.1.x that are not yet in 2.1.x.
|
||||
#
|
||||
# Specify a version tag to start from, and optional version tag to end at.
|
||||
# For bugfix-2.1.x the tag will be prefixed by dev- to distinguish it from the version tag,
|
||||
# so at every release be sure to create a dev- tag and publish it to origin.
|
||||
#
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
SELF=`basename "$0"`
|
||||
DRYRUN=0
|
||||
|
||||
[[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; }
|
||||
|
||||
TAG1=$1
|
||||
TAG2=${2:-"HEAD"}
|
||||
|
||||
DEST=2.1.x
|
||||
|
||||
# Validate that the required tags exist
|
||||
|
||||
MTAG=`git tag | grep -e "^dev-$TAG1\$"`
|
||||
[[ -n "$MTAG" ]] || { echo "Can't find tag dev-$TAG1" ; exit 1 ; }
|
||||
MTAG=`git tag | grep -e "^$TAG1\$"`
|
||||
[[ -n "$MTAG" ]] || { echo "Can't find tag $TAG1" ; exit 1 ; }
|
||||
|
||||
# Generate log of recent commits for bugfix-2.1.x and DEST
|
||||
|
||||
TMPDIR=`mktemp -d`
|
||||
LOGB="$TMPDIR/log-bf.txt"
|
||||
LOG2="$TMPDIR/log-2x.txt"
|
||||
TMPF="$TMPDIR/tmp.txt"
|
||||
SCRF="$TMPDIR/update-$DEST.sh"
|
||||
|
||||
git checkout bugfix-2.1.x
|
||||
git log --pretty="[%h] %s" dev-$TAG1..$TAG2 | grep -v '\[cron\]' | $SED '1!G;h;$!d' >"$LOGB"
|
||||
|
||||
git checkout $DEST
|
||||
git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "Can't find tag dev-$TAG1" ; exit 1 ; }
|
||||
|
||||
# Go through commit text from DEST removing all matches from the bugfix log
|
||||
|
||||
cat "$LOG2" | while read line; do
|
||||
if [[ $line =~ \(((#[0-9]{5}),* *)((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?\)$ ]]; then
|
||||
PATT=""
|
||||
for i in ${!BASH_REMATCH[@]}; do
|
||||
if ((i > 0 && (i % 2 == 0))); then
|
||||
if [[ -n "${BASH_REMATCH[i]}" ]]; then
|
||||
[[ -n "$PATT" ]] && PATT="$PATT|"
|
||||
PATT="$PATT${BASH_REMATCH[i]}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
#echo "... $PATT"
|
||||
[[ -n "$PATT" ]] && { grep -vE "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
|
||||
else
|
||||
PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" )
|
||||
[[ -n "$PATT" ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
|
||||
fi
|
||||
done
|
||||
|
||||
# Convert remaining commits into git commands
|
||||
|
||||
echo -e "#!/usr/bin/env bash\nset -e\ngit checkout ${DEST}\n" >"$TMPF"
|
||||
cat "$LOGB" | while read line; do
|
||||
if [[ $line =~ ^\[([0-9a-f]{10})\]\ *(.*)$ ]]; then
|
||||
CID=${BASH_REMATCH[1]}
|
||||
REST=${BASH_REMATCH[2]}
|
||||
echo "git cherry-pick $CID ;# $REST" >>"$TMPF"
|
||||
else
|
||||
echo ";# $line" >>"$TMPF"
|
||||
fi
|
||||
done
|
||||
mv "$TMPF" "$SCRF"
|
||||
chmod +x "$SCRF"
|
||||
|
||||
((DRYRUN)) && rm -r "$TMPDIR" || open "$TMPDIR"
|
@ -45,7 +45,7 @@ git clean -d -f
|
||||
|
||||
opensite() {
|
||||
URL="$1"
|
||||
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
if [ -z "$OPEN" ]; then
|
||||
echo "Can't find a tool to open the URL:"
|
||||
echo $URL
|
||||
|
@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mfqp [1|2|3]
|
||||
# mfqp [1|2]
|
||||
#
|
||||
# - git add .
|
||||
# - git commit --amend
|
||||
# - ghpc
|
||||
# - git push -f
|
||||
#
|
||||
|
||||
MFINFO=$(mfinfo "$@") || exit 1
|
||||
@ -17,14 +17,15 @@ 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
|
||||
let IND+=1
|
||||
done
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# mfrb
|
||||
#
|
||||
# Do "git rebase -i" against the "target" branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, or master)
|
||||
# Do "git rebase -i" against the repo's "target" branch
|
||||
#
|
||||
|
||||
MFINFO=$(mfinfo "$@") || exit 1
|
||||
@ -21,7 +21,7 @@ while [ $IND -lt ${#INFO[@]} ]; do
|
||||
let IND+=1
|
||||
done
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; }
|
||||
|
||||
[[ $QUICK ]] || git fetch upstream
|
||||
git rebase upstream/$TARG && git rebase -i upstream/$TARG
|
||||
|
@ -1,236 +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/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' ;;
|
||||
t40) TESTENV='teensy41' ;;
|
||||
t41) TESTENV='teensy41' ;;
|
||||
|
||||
-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 t40|t41"
|
||||
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