Fix/improve configs build script (#21086)

This commit is contained in:
X-Ryl669 2021-02-17 01:41:00 +01:00 committed by GitHub
parent f2b9becd7e
commit 7b23f41fd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 69 deletions

View file

@ -252,6 +252,8 @@
#include "mega/pins_WANHAO_ONEPLUS.h" // ATmega2560 env:mega2560 #include "mega/pins_WANHAO_ONEPLUS.h" // ATmega2560 env:mega2560
#elif MB(OVERLORD) #elif MB(OVERLORD)
#include "mega/pins_OVERLORD.h" // ATmega2560 env:mega2560 #include "mega/pins_OVERLORD.h" // ATmega2560 env:mega2560
#elif MB(HJC2560C_REV1)
#include "mega/pins_HJC2560C_REV1.h" // ATmega2560 env:mega2560
#elif MB(HJC2560C_REV2) #elif MB(HJC2560C_REV2)
#include "mega/pins_HJC2560C_REV2.h" // ATmega2560 env:mega2560 #include "mega/pins_HJC2560C_REV2.h" // ATmega2560 env:mega2560
#elif MB(LEAPFROG_XEED2015) #elif MB(LEAPFROG_XEED2015)

View file

@ -1,62 +1,81 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# build_all_examples base_branch [resume_point]
#
echo "This script will attempt to build Marlin for all known configurations." GITREPO=https://github.com/MarlinFirmware/Configurations.git
echo "In case of failure, the current configuration remains in your repository." STAT_FILE=./.pio/.buildall
echo "To revert to your current version, run 'git checkout -f'."
self=`basename "$0"`
HERE=`dirname "$0"`
# Check dependencies # Check dependencies
which curl 1>/dev/null 2>&1 || { echo "curl not found, please install it"; exit ; } 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 ; } which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
if [ -z "$1" ]; then
echo ""
echo "ERROR: "
echo " Expected parameter: $self base_branch [resume_point]"
echo " with:"
echo " base_branch The branch in the Configuration repository to use"
echo " resume_point If not empty, resume building from this board"
SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
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 ; }
if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "Usage: $SELF base_branch [resume_point]
base_branch - Configuration branch to download and build
resume_point - Configuration path to start from"
exit exit
fi fi
# Check if called in the right folder echo "This script downloads all Configurations and builds Marlin with each one."
if [ ! -e "Marlin/src" ]; then echo "On failure the last-built configs will be left in your working copy."
echo "This script must be called from the root folder of a Marlin repository, please navigate to this folder and call:" echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'."
echo "buildroot/ci-check/$self $1"
exit # If -c is given start from the last attempted build
if [[ $1 == '-c' ]]; then
if [[ -f "$STAT_FILE" ]]; then
read BRANCH FIRST_CONF <"$STAT_FILE"
else
echo "Nothing to continue"
exit
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
if [ -z "$2" ]; then if [[ -z "$FIRST_CONF" ]]; then
git diff --quiet || { echo "Your current repository is not clean. Either commit your change or stash them, and re-run this script"; exit ; } git diff --quiet || { echo "The working copy is modified. Commit or stash changes before proceeding."; exit ; }
else else
echo "Resuming from $2" echo "Resuming from $FIRST_CONF"
fi fi
TMPDIR=`mktemp -d` # Create a temporary folder inside .pio
TMP=./.pio/build-$BRANCH
[[ -d "$TMP" ]] || mkdir -p $TMP
# Ok, let's do our stuff now # Download Configurations into the temporary folder
# First extract the current temporary folder if [[ ! -e "$TMP/README.md" ]]; then
echo "Fetching configuration repository" echo "Downloading Configurations from GitHub into $TMP"
if [ ! -e "$TMPDIR/README.md" ]; then git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
git clone --single-branch --branch "$1" https://github.com/MarlinFirmware/Configurations.git "$TMPDIR" || { echo "Failed to clone the configuration repository"; exit ; } else
rm -r $TMPDIR/.git echo "Using previously downloaded Configurations at $TMP"
fi fi
echo echo -e "Start building now...\n====================="
echo "Start building now..."
echo "====================="
shopt -s nullglob shopt -s nullglob
for config in $TMPDIR/config/examples/*/; do IFS='
[ -d "${config}" ] || continue '
base=`basename "$config"` CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
if [ ! -z "$2" ] && [ "$2" != "$base" ]; then for CONF in $CONF_TREE ; do
echo "Skipping $base..." DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
continue [[ ! -z $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
fi unset FIRST_CONF
"$HERE/build_example" "internal" "$TMPDIR" "$base" || { echo "Failed to build $base"; exit ; } compgen -G "${CONF}Con*.h" > /dev/null || continue
echo -e "$BRANCH\n$DIR" >"$STAT_FILE"
"$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
done done
rm -r "$TMPDIR" # Delete the temp folder and build state
[[ -e "$TMP/config/examples" ]] && rm -rf "$TMP"
rm "$STAT_FILE"

View file

@ -1,35 +1,29 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# build_example
#
# Usage: build_example internal config-home config-folder
#
if [ "$1" != "internal" ]; then # Require 'internal' as the first argument
echo "Don't call this script directly, use build_all_examples instead." [[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
exit 1
fi
SED=$(which gsed || which sed)
HERE=`dirname "$0"`
echo "Testing $3:" echo "Testing $3:"
shopt -s nullglob SUB=$2/config/examples/$3
for sub in find $2/config/examples/$3 -type d; do [[ -d "$SUB" ]] || { echo "$SUB is not a good path" ; exit 1 ; }
[[ -d $sub ]] || continue
base=`basename "$sub"`
if [[ ! -f $sub/Configuration.h ]] && [[ ! -f $sub/Configuration_adv.h ]]; then compgen -G "${SUB}Con*.h" > /dev/null || { echo "No configuration files found in $SUB" ; exit 1 ; }
echo "No configuration files found in $sub"
continue
fi
echo "Getting configuration files from $sub" echo "Getting configuration files from $SUB"
cp "$2/config/default"/*.h Marlin/ cp "$2/config/default"/*.h Marlin/
cp "$sub"/Configuration.h Marlin/ 2>/dev/null cp "$SUB"/Configuration.h Marlin/ 2>/dev/null
cp "$sub"/Configuration_adv.h Marlin/ 2>/dev/null 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
echo "Building the firmware now..." echo "Building the firmware now..."
echo "$HERE/mftest" -a || exit 1 HERE=`dirname "$0"`
done $HERE/mftest -a || { echo "Failed"; exit 1; }
echo "Success" echo "Success"
exit 0

View file

@ -6,7 +6,6 @@
# mftest [name] [index] [-y] Set config options and optionally build a test # mftest [name] [index] [-y] Set config options and optionally build a test
# #
MFINFO=$(mfinfo) || exit 1
[[ -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 ; }
perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; } perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
@ -37,7 +36,7 @@ env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 tee
TESTPATH=buildroot/tests TESTPATH=buildroot/tests
STATE_FILE=$( echo ./.pio/.mftestrc ) STATE_FILE="./.pio/.mftestrc"
SED=$(which gsed || which sed) SED=$(which gsed || which sed)
shopt -s extglob nocasematch shopt -s extglob nocasematch