🧑💻 Fix and improve build_all_examples
This commit is contained in:
parent
929ce5e859
commit
8e6aa1b113
|
@ -1,15 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# build_all_examples base_branch [resume_point]
|
# Usage:
|
||||||
#
|
#
|
||||||
# build_all_examples [-b|--branch=<branch>] - Branch to fetch from Configurations repo
|
# build_all_examples [-b|--branch=<branch>]
|
||||||
# [-c|--continue] - Continue the paused build
|
# [-c|--continue]
|
||||||
# [-d|--debug] - Print extra debug output
|
# [-d|--debug]
|
||||||
# [-i|--ini] - Archive ini/json/yml files in the temp config folder
|
# [-i|--ini]
|
||||||
# [-l|--limit=#] - Limit the number of builds in this run
|
# [-l|--limit=#]
|
||||||
# [-n|--nobuild] - Don't actually build anything.
|
# [-n|--nobuild]
|
||||||
# [-r|--resume=<path>] - Start at some config in the filesystem order
|
# [-r|--resume=<path>]
|
||||||
# [-s|--skip] - Do the thing
|
# [-s|--skip]
|
||||||
#
|
#
|
||||||
# build_all_examples [...] branch [resume-from]
|
# build_all_examples [...] branch [resume-from]
|
||||||
#
|
#
|
||||||
|
@ -19,12 +19,20 @@
|
||||||
GITREPO=https://github.com/MarlinFirmware/Configurations.git
|
GITREPO=https://github.com/MarlinFirmware/Configurations.git
|
||||||
STAT_FILE=./.pio/.buildall
|
STAT_FILE=./.pio/.buildall
|
||||||
|
|
||||||
# Check dependencies
|
usage() { echo "
|
||||||
which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
|
Usage: $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-r|--resume=<path>]
|
||||||
which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
|
$SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-c|--continue]
|
||||||
|
$SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-s|--skip]
|
||||||
|
$SELF [-b|--branch=<branch>] [-d|--debug] [-n|--nobuild]
|
||||||
|
$SELF [...] branch [resume-point]
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
|
# Assume the most recent configs
|
||||||
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
|
BRANCH=import-2.0.x
|
||||||
|
unset FIRST_CONF
|
||||||
|
EXIT_USAGE=
|
||||||
|
LIMIT=1000
|
||||||
|
|
||||||
while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
||||||
case "${OFLAG}" in
|
case "${OFLAG}" in
|
||||||
|
@ -32,7 +40,7 @@ while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
||||||
r) FIRST_CONF="$OPTARG" ; bugout "Resume: $FIRST_CONF" ;;
|
r) FIRST_CONF="$OPTARG" ; bugout "Resume: $FIRST_CONF" ;;
|
||||||
c) CONTINUE=1 ; bugout "Continue" ;;
|
c) CONTINUE=1 ; bugout "Continue" ;;
|
||||||
s) CONTSKIP=1 ; bugout "Continue, skipping" ;;
|
s) CONTSKIP=1 ; bugout "Continue, skipping" ;;
|
||||||
i) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
|
i) CREATE_INI=1 ; bugout "Generate an INI file" ;;
|
||||||
h) EXIT_USAGE=1 ; break ;;
|
h) EXIT_USAGE=1 ; break ;;
|
||||||
l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;;
|
l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;;
|
||||||
d|v) DEBUG=1 ; bugout "Debug ON" ;;
|
d|v) DEBUG=1 ; bugout "Debug ON" ;;
|
||||||
|
@ -44,7 +52,7 @@ while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
||||||
continue) CONTINUE=1 ; bugout "Continue" ;;
|
continue) CONTINUE=1 ; bugout "Continue" ;;
|
||||||
skip) CONTSKIP=2 ; bugout "Continue, skipping" ;;
|
skip) CONTSKIP=2 ; bugout "Continue, skipping" ;;
|
||||||
limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;;
|
limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;;
|
||||||
ini) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
|
ini) CREATE_INI=1 ; bugout "Generate an INI file" ;;
|
||||||
help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
|
help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
|
||||||
debug) DEBUG=1 ; bugout "Debug ON" ;;
|
debug) DEBUG=1 ; bugout "Debug ON" ;;
|
||||||
nobuild) DRYRUN=1 ; bugout "Dry Run" ;;
|
nobuild) DRYRUN=1 ; bugout "Dry Run" ;;
|
||||||
|
@ -55,42 +63,35 @@ while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if called in the right location
|
# Extra arguments count as BRANCH, FIRST_CONF
|
||||||
[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
|
shift $((OPTIND - 1))
|
||||||
|
[[ $# > 0 ]] && { BRANCH=$1 ; shift 1 ; bugout "BRANCH=$BRANCH" ; }
|
||||||
|
[[ $# > 0 ]] && { FIRST_CONF=$1 ; shift 1 ; bugout "FIRST_CONF=$FIRST_CONF" ; }
|
||||||
|
[[ $# > 0 ]] && { EXIT_USAGE=2 ; echo "too many arguments" ; }
|
||||||
|
|
||||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; }
|
||||||
echo "Usage: $SELF base_branch [resume_point]
|
|
||||||
base_branch - Configuration branch to download and build
|
|
||||||
resume_point - Configuration path to start from"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "This script downloads all Configurations and builds Marlin with each one."
|
echo "This script downloads each Configuration and attempts to build it."
|
||||||
echo "On failure the last-built configs will be left in your working copy."
|
echo "On failure the last-built configs will be left in your working copy."
|
||||||
echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'."
|
echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'."
|
||||||
|
|
||||||
unset BRANCH
|
|
||||||
unset FIRST_CONF
|
|
||||||
if [[ -f "$STAT_FILE" ]]; then
|
if [[ -f "$STAT_FILE" ]]; then
|
||||||
IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE"
|
IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If -c is given start from the last attempted build
|
# If -c is given start from the last attempted build
|
||||||
if [[ $1 == '-c' ]]; then
|
if ((CONTINUE)); then
|
||||||
if [[ -z $BRANCH || -z $FIRST_CONF ]]; then
|
if [[ -z $BRANCH || -z $FIRST_CONF ]]; then
|
||||||
echo "Nothing to continue"
|
echo "Nothing to continue"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
elif [[ $1 == '-s' ]]; then
|
elif ((CONTSKIP)); then
|
||||||
if [[ -n $BRANCH && -n $FIRST_CONF ]]; then
|
if [[ -n $BRANCH && -n $FIRST_CONF ]]; then
|
||||||
SKIP_CONF=1
|
SKIP_CONF=1
|
||||||
else
|
else
|
||||||
echo "Nothing to skip"
|
echo "Nothing to skip"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
BRANCH=${1:-"import-2.0.x"}
|
|
||||||
FIRST_CONF=$2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the current repository has unmerged changes
|
# Check if the current repository has unmerged changes
|
||||||
|
@ -108,45 +109,46 @@ TMP=./.pio/build-$BRANCH
|
||||||
|
|
||||||
# Download Configurations into the temporary folder
|
# Download Configurations into the temporary folder
|
||||||
if [[ ! -e "$TMP/README.md" ]]; then
|
if [[ ! -e "$TMP/README.md" ]]; then
|
||||||
echo "Downloading Configurations from GitHub into $TMP"
|
echo "Fetching Configurations from GitHub to $TMP"
|
||||||
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
|
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
|
||||||
else
|
else
|
||||||
echo "Using previously downloaded Configurations at $TMP"
|
echo "Using cached Configurations at $TMP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "Start building now...\n====================="
|
echo -e "Start build...\n====================="
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
|
CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
|
||||||
DOSKIP=0
|
|
||||||
for CONF in $CONF_TREE ; do
|
for CONF in $CONF_TREE ; do
|
||||||
|
|
||||||
# Get a config's directory name
|
# Get a config's directory name
|
||||||
DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
|
DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
|
||||||
|
|
||||||
# If looking for a config, skip others
|
# If looking for a config, skip others
|
||||||
[[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
|
[[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
|
||||||
# Once found, stop looking
|
# Once found, stop looking
|
||||||
unset FIRST_CONF
|
unset FIRST_CONF
|
||||||
|
|
||||||
# If skipping, don't build the found one
|
# If skipping, don't build the found one
|
||||||
[[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; }
|
[[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; }
|
||||||
|
|
||||||
# ...if skipping, don't build this one
|
# ...if skipping, don't build this one
|
||||||
compgen -G "${CONF}Con*.h" > /dev/null || continue
|
compgen -G "${CONF}Con*.h" > /dev/null || continue
|
||||||
|
|
||||||
# Build or print build command for --nobuild
|
# Remember where we are in case of failure
|
||||||
|
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
|
||||||
|
|
||||||
|
# Build or pretend to build
|
||||||
if [[ $DRYRUN ]]; then
|
if [[ $DRYRUN ]]; then
|
||||||
echo -e "\033[0;32m[DRYRUN] build_example internal \"$TMP\" \"$DIR\"\033[0m"
|
echo "[DRYRUN] build_example internal \"$TMP\" \"$DIR\""
|
||||||
else
|
else
|
||||||
# Remember where we are in case of failure
|
# Build folder is unknown so delete all "config.ini" files
|
||||||
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
|
[[ $CREATE_INI ]] && find ./.pio/build/ -name "config.ini" -exec rm "{}" \;
|
||||||
# Build folder is unknown so delete all report files
|
((DEBUG)) && echo "\"$HERE/build_example\" \"internal\" \"$TMP\" \"$DIR\""
|
||||||
if [[ $COPY_INI ]]; then
|
"$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
|
||||||
IFIND='find ./.pio/build/ -name "config.ini" -o -name "schema.json" -o -name "schema.yml"'
|
# Build folder is unknown so copy any "config.ini"
|
||||||
$IFIND -exec rm "{}" \;
|
[[ $CREATE_INI ]] && find ./.pio/build/ -name "config.ini" -exec cp "{}" "$CONF" \;
|
||||||
fi
|
|
||||||
((DEBUG)) && echo "\"$HERE/build_example\" internal \"$TMP\" \"$DIR\""
|
|
||||||
"$HERE/build_example" internal "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
|
|
||||||
# Build folder is unknown so copy all report files
|
|
||||||
[[ $COPY_INI ]] && $IFIND -exec cp "{}" "$CONF" \;
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
|
((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
|
||||||
|
@ -158,7 +160,7 @@ done
|
||||||
|
|
||||||
# Delete the temp folder if not preserving generated INI files
|
# Delete the temp folder if not preserving generated INI files
|
||||||
if [[ -e "$TMP/config/examples" ]]; then
|
if [[ -e "$TMP/config/examples" ]]; then
|
||||||
if [[ $COPY_INI ]]; then
|
if [[ $CREATE_INI ]]; then
|
||||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||||
$OPEN "$TMP"
|
$OPEN "$TMP"
|
||||||
elif [[ ! $PAUSE ]]; then
|
elif [[ ! $PAUSE ]]; then
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
# Usage: build_example internal config-home config-folder
|
# Usage: build_example internal config-home config-folder
|
||||||
#
|
#
|
||||||
|
|
||||||
|
. mfutil
|
||||||
|
|
||||||
# Require 'internal' as the first argument
|
# Require 'internal' as the first argument
|
||||||
[[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
|
[[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
|
||||||
|
|
||||||
|
@ -22,8 +24,15 @@ cp "$SUB"/Configuration_adv.h Marlin/ 2>/dev/null
|
||||||
cp "$SUB"/_Bootscreen.h Marlin/ 2>/dev/null
|
cp "$SUB"/_Bootscreen.h Marlin/ 2>/dev/null
|
||||||
cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null
|
cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Strip #error lines from Configuration.h
|
||||||
|
IFS=$'\n'; set -f
|
||||||
|
$SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h
|
||||||
|
rm Marlin/Configuration.h~
|
||||||
|
unset IFS; set +f
|
||||||
|
|
||||||
echo "Building the firmware now..."
|
echo "Building the firmware now..."
|
||||||
HERE=`dirname "$0"`
|
|
||||||
$HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; }
|
$HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; }
|
||||||
|
|
||||||
echo "Success"
|
echo "Success"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# 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 -tname -n# [-y] Set config options and optionally build a test
|
||||||
#
|
#
|
||||||
|
|
||||||
[[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; }
|
[[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; }
|
||||||
|
|
22
buildroot/bin/mfutil
Executable file
22
buildroot/bin/mfutil
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# mfutil - check env and define helpers
|
||||||
|
#
|
||||||
|
|
||||||
|
# Check dependencies
|
||||||
|
which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
|
||||||
|
which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
|
||||||
|
|
||||||
|
SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
|
||||||
|
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
|
||||||
|
|
||||||
|
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||||
|
|
||||||
|
SELF=`basename "$0"`
|
||||||
|
HERE=`dirname "$0"`
|
||||||
|
|
||||||
|
# Check if called in the right location
|
||||||
|
[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
|
||||||
|
|
||||||
|
perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
|
||||||
|
bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; }
|
|
@ -3,7 +3,6 @@
|
||||||
# use_example_configs [repo:]configpath
|
# use_example_configs [repo:]configpath
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# use_example_configs
|
|
||||||
# use_example_configs Creality/CR-10/CrealityV1
|
# use_example_configs Creality/CR-10/CrealityV1
|
||||||
# use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1
|
# use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1
|
||||||
#
|
#
|
||||||
|
|
|
@ -16,7 +16,7 @@ BRANCH=${INFO[5]}
|
||||||
|
|
||||||
git push --set-upstream origin HEAD:$BRANCH
|
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"
|
URL="https://github.com/$FORK/$REPO/commits/$BRANCH"
|
||||||
|
|
||||||
if [ -z "$OPEN" ]; then
|
if [ -z "$OPEN" ]; then
|
||||||
|
|
|
@ -17,7 +17,7 @@ BRANCH=${INFO[5]}
|
||||||
|
|
||||||
opensite() {
|
opensite() {
|
||||||
URL="http://127.0.0.1:4000/"
|
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
|
if [ -z "$OPEN" ]; then
|
||||||
echo "Can't find a tool to open the URL:"
|
echo "Can't find a tool to open the URL:"
|
||||||
echo $URL
|
echo $URL
|
||||||
|
|
|
@ -23,7 +23,7 @@ OLDBRANCH=${INFO[5]}
|
||||||
# See if it's been pushed yet
|
# See if it's been pushed yet
|
||||||
if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi
|
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"
|
URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
|
||||||
|
|
||||||
if [ -z "$OPEN" ]; then
|
if [ -z "$OPEN" ]; then
|
||||||
|
|
|
@ -18,7 +18,7 @@ DRYRUN=0
|
||||||
TAG1=$1
|
TAG1=$1
|
||||||
TAG2=${2:-"HEAD"}
|
TAG2=${2:-"HEAD"}
|
||||||
|
|
||||||
DEST=2.1.x
|
DEST=2.0.x
|
||||||
|
|
||||||
# Validate that the required tags exist
|
# Validate that the required tags exist
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ git clean -d -f
|
||||||
|
|
||||||
opensite() {
|
opensite() {
|
||||||
URL="$1"
|
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
|
if [ -z "$OPEN" ]; then
|
||||||
echo "Can't find a tool to open the URL:"
|
echo "Can't find a tool to open the URL:"
|
||||||
echo $URL
|
echo $URL
|
||||||
|
|
Loading…
Reference in a new issue