From d86910ce9482295c5dcb113862678f85fc266616 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Mon, 15 Feb 2021 12:48:11 +0100 Subject: [PATCH] Script to download & build Configurations (#20992) Co-authored-by: Scott Lahteine --- buildroot/bin/build_all_examples | 62 +++++++++++++++++++++++++++++ buildroot/bin/build_example | 35 ++++++++++++++++ buildroot/{share/git => bin}/mftest | 0 3 files changed, 97 insertions(+) create mode 100755 buildroot/bin/build_all_examples create mode 100755 buildroot/bin/build_example rename buildroot/{share/git => bin}/mftest (100%) diff --git a/buildroot/bin/build_all_examples b/buildroot/bin/build_all_examples new file mode 100755 index 0000000000..29256de69c --- /dev/null +++ b/buildroot/bin/build_all_examples @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +echo "This script will attempt to build Marlin for all known configurations." +echo "In case of failure, the current configuration remains in your repository." +echo "To revert to your current version, run 'git checkout -f'." + +self=`basename "$0"` +HERE=`dirname "$0"` + +# 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 ; } +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" + + exit +fi + +# Check if called in the right folder +if [ ! -e "Marlin/src" ]; then + echo "This script must be called from the root folder of a Marlin repository, please navigate to this folder and call:" + echo "buildroot/ci-check/$self $1" + exit +fi + +# Check if the current repository has unmerged changes +if [ -z "$2" ]; then + git diff --quiet || { echo "Your current repository is not clean. Either commit your change or stash them, and re-run this script"; exit ; } +else + echo "Resuming from $2" +fi + +TMPDIR=`mktemp -d` + +# Ok, let's do our stuff now +# First extract the current temporary folder +echo "Fetching configuration repository" +if [ ! -e "$TMPDIR/README.md" ]; then + git clone --single-branch --branch "$1" https://github.com/MarlinFirmware/Configurations.git "$TMPDIR" || { echo "Failed to clone the configuration repository"; exit ; } + rm -r $TMPDIR/.git +fi + +echo +echo "Start building now..." +echo "=====================" +shopt -s nullglob +for config in $TMPDIR/config/examples/*/; do + [ -d "${config}" ] || continue + base=`basename "$config"` + if [ ! -z "$2" ] && [ "$2" != "$base" ]; then + echo "Skipping $base..." + continue + fi + "$HERE/build_example" "internal" "$TMPDIR" "$base" || { echo "Failed to build $base"; exit ; } +done + +rm -r "$TMPDIR" diff --git a/buildroot/bin/build_example b/buildroot/bin/build_example new file mode 100755 index 0000000000..8f2d9d3c33 --- /dev/null +++ b/buildroot/bin/build_example @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +if [ "$1" != "internal" ]; then + echo "Don't call this script directly, use build_all_examples instead." + exit 1 +fi + +SED=$(which gsed || which sed) +HERE=`dirname "$0"` + +echo "Testing $3:" + +shopt -s nullglob +for sub in find $2/config/examples/$3 -type d; do + [[ -d $sub ]] || continue + base=`basename "$sub"` + + if [[ ! -f $sub/Configuration.h ]] && [[ ! -f $sub/Configuration_adv.h ]]; then + echo "No configuration files found in $sub" + continue + fi + + echo "Getting configuration files from $sub" + cp "$2/config/default"/*.h Marlin/ + cp "$sub"/Configuration.h Marlin/ 2>/dev/null + cp "$sub"/Configuration_adv.h Marlin/ 2>/dev/null + cp "$sub"/_Bootscreen.h Marlin/ 2>/dev/null + cp "$sub"/_Statusscreen.h Marlin/ 2>/dev/null + + echo "Building the firmware now..." + echo "$HERE/mftest" -a || exit 1 +done + +echo "Success" +exit 0 diff --git a/buildroot/share/git/mftest b/buildroot/bin/mftest similarity index 100% rename from buildroot/share/git/mftest rename to buildroot/bin/mftest