2021-02-15 11:48:11 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-02-17 00:41:00 +00:00
|
|
|
#
|
|
|
|
# build_all_examples base_branch [resume_point]
|
|
|
|
#
|
2021-02-15 11:48:11 +00:00
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
GITREPO=https://github.com/MarlinFirmware/Configurations.git
|
|
|
|
STAT_FILE=./.pio/.buildall
|
2021-02-15 11:48:11 +00:00
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
# 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 ; }
|
|
|
|
|
|
|
|
SELF=`basename "$0"`
|
2021-02-15 11:48:11 +00:00
|
|
|
HERE=`dirname "$0"`
|
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
# 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 ; }
|
2021-02-15 11:48:11 +00:00
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
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"
|
2021-02-15 11:48:11 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
echo "This script downloads all Configurations and builds Marlin with each one."
|
|
|
|
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'."
|
|
|
|
|
|
|
|
# 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
|
2021-02-15 11:48:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if the current repository has unmerged changes
|
2021-02-17 00:41:00 +00:00
|
|
|
if [[ -z "$FIRST_CONF" ]]; then
|
|
|
|
git diff --quiet || { echo "The working copy is modified. Commit or stash changes before proceeding."; exit ; }
|
2021-02-15 11:48:11 +00:00
|
|
|
else
|
2021-02-17 00:41:00 +00:00
|
|
|
echo "Resuming from $FIRST_CONF"
|
2021-02-15 11:48:11 +00:00
|
|
|
fi
|
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
# Create a temporary folder inside .pio
|
|
|
|
TMP=./.pio/build-$BRANCH
|
|
|
|
[[ -d "$TMP" ]] || mkdir -p $TMP
|
2021-02-15 11:48:11 +00:00
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
# Download Configurations into the temporary folder
|
|
|
|
if [[ ! -e "$TMP/README.md" ]]; then
|
|
|
|
echo "Downloading Configurations from GitHub into $TMP"
|
|
|
|
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
|
|
|
|
else
|
|
|
|
echo "Using previously downloaded Configurations at $TMP"
|
2021-02-15 11:48:11 +00:00
|
|
|
fi
|
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
echo -e "Start building now...\n====================="
|
2021-02-15 11:48:11 +00:00
|
|
|
shopt -s nullglob
|
2021-02-17 00:41:00 +00:00
|
|
|
IFS='
|
|
|
|
'
|
|
|
|
CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
|
|
|
|
for CONF in $CONF_TREE ; do
|
|
|
|
DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
|
|
|
|
[[ ! -z $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
|
|
|
|
unset FIRST_CONF
|
|
|
|
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 ; }
|
2021-02-15 11:48:11 +00:00
|
|
|
done
|
|
|
|
|
2021-02-17 00:41:00 +00:00
|
|
|
# Delete the temp folder and build state
|
|
|
|
[[ -e "$TMP/config/examples" ]] && rm -rf "$TMP"
|
|
|
|
rm "$STAT_FILE"
|