Marlin_Firmware/buildroot/bin/build_all_examples

63 lines
2.0 KiB
Plaintext
Raw Normal View History

#!/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"