|
|
|
@@ -20,8 +20,9 @@
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
HERE=`dirname $0`
|
|
|
|
|
PATH="$HERE:$PATH"
|
|
|
|
|
|
|
|
|
|
. "$HERE/mfutil"
|
|
|
|
|
. mfutil
|
|
|
|
|
|
|
|
|
|
GITREPO=https://github.com/MarlinFirmware/Configurations.git
|
|
|
|
|
STAT_FILE=./.pio/.buildall
|
|
|
|
@@ -55,7 +56,7 @@ LIMIT=1000
|
|
|
|
|
while getopts 'aB:b:ce:fdhl:no:pr:sv-:' OFLAG; do
|
|
|
|
|
case "${OFLAG}" in
|
|
|
|
|
a) ARCHIVE=1 ; bugout "Archiving" ;;
|
|
|
|
|
B) OPATH=${OPTARG%/} ; bugout "Base: $OPATH" ;;
|
|
|
|
|
B) CBASE=${OPTARG%/} ; bugout "Base: $CBASE" ;;
|
|
|
|
|
b) BRANCH=$OPTARG ; bugout "Branch: $BRANCH" ;;
|
|
|
|
|
f) NOFAIL=1 ; bugout "Continue on Fail" ;;
|
|
|
|
|
r) ISRES=1 ; FIRST_CONF=$OPTARG ; bugout "Resume: $FIRST_CONF" ;;
|
|
|
|
@@ -71,7 +72,7 @@ while getopts 'aB:b:ce:fdhl:no:pr:sv-:' OFLAG; do
|
|
|
|
|
-) ONAM="${OPTARG%%=*}" ; OVAL="${OPTARG#*=}"
|
|
|
|
|
case "$ONAM" in
|
|
|
|
|
archive) ARCHIVE=1 ; bugout "Archiving" ;;
|
|
|
|
|
base) OPATH=${OVAL%/} ; bugout "Base: $OPATH" ;;
|
|
|
|
|
base) CBASE=${OVAL%/} ; bugout "Base: $CBASE" ;;
|
|
|
|
|
branch) BRANCH=$OVAL ; bugout "Branch: $BRANCH" ;;
|
|
|
|
|
nofail) NOFAIL=1 ; bugout "Continue on Fail" ;;
|
|
|
|
|
resume) ISRES=1 ; FIRST_CONF=$OVAL ; bugout "Resume: $FIRST_CONF" ;;
|
|
|
|
@@ -131,45 +132,47 @@ else
|
|
|
|
|
git diff --quiet || { echo "The working copy is modified. Commit or stash changes before proceeding."; exit ; }
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Create a temporary folder inside .pio
|
|
|
|
|
if [[ -n $OPATH ]]; then
|
|
|
|
|
[[ -d "$OPATH" ]] || { echo "Given base -B $OPATH not found." ; exit ; }
|
|
|
|
|
# Check for the given base path
|
|
|
|
|
if [[ -n $CBASE ]]; then
|
|
|
|
|
CBASE="${CBASE/#\~/$HOME}"
|
|
|
|
|
[[ -d "$CBASE" ]] || { echo "Given base -B $CBASE not found." ; exit ; }
|
|
|
|
|
else
|
|
|
|
|
# Make a Configurations temporary folder if needed
|
|
|
|
|
OPATH=./.pio/build-$BRANCH
|
|
|
|
|
[[ -d "$OPATH" ]] || mkdir -p "$OPATH"
|
|
|
|
|
CBASE=./.pio/build-$BRANCH
|
|
|
|
|
[[ -d "$CBASE" ]] || mkdir -p "$CBASE"
|
|
|
|
|
# Download the specified Configurations branch if needed
|
|
|
|
|
if [[ ! -e "$OPATH/README.md" ]]; then
|
|
|
|
|
echo "Fetching Configurations from GitHub to $OPATH"
|
|
|
|
|
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$OPATH" || { echo "Failed to clone the configuration repository"; exit ; }
|
|
|
|
|
if [[ ! -e "$CBASE/README.md" ]]; then
|
|
|
|
|
echo "Fetching Configurations from GitHub to $CBASE"
|
|
|
|
|
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$CBASE" || { echo "Failed to clone the configuration repository"; exit ; }
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Build
|
|
|
|
|
echo -e "=====================\nProceed with builds...\n====================="
|
|
|
|
|
shopt -s nullglob
|
|
|
|
|
shopt -s globstar
|
|
|
|
|
IFS='
|
|
|
|
|
'
|
|
|
|
|
CONF_TREE=$( ls -d "$OPATH"/config/examples/**/ | grep -vE ".+\.(\w+)$" )
|
|
|
|
|
for CONF in $CONF_TREE ; do
|
|
|
|
|
|
|
|
|
|
# Get a list of all folders that contain a file matching "Configuration*.h"
|
|
|
|
|
find -ds "$CBASE"/config/examples -type d -name 'Configuration.h' -o -name 'Configuration_adv.h' -print0 | while IFS= read -r -d '' CONF; do
|
|
|
|
|
|
|
|
|
|
# Remove the file name and slash from the end of the path
|
|
|
|
|
CONF=${CONF%/*}
|
|
|
|
|
|
|
|
|
|
# Get a config's directory name
|
|
|
|
|
DIR=${CONF#$OPATH/config/examples/}
|
|
|
|
|
DIR=${CONF#$CBASE/config/examples/}
|
|
|
|
|
|
|
|
|
|
# If looking for a config, skip others
|
|
|
|
|
[[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
|
|
|
|
|
[[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && { ((DEBUG)) && echo "[SKIP] $DIR" ; continue ; }
|
|
|
|
|
# Once found, stop looking
|
|
|
|
|
unset FIRST_CONF
|
|
|
|
|
|
|
|
|
|
# If skipping, don't build the found one
|
|
|
|
|
[[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; }
|
|
|
|
|
|
|
|
|
|
# At least one config file is required here
|
|
|
|
|
compgen -G "${CONF}Configuration*.h" > /dev/null || continue
|
|
|
|
|
# Either Configuration.h or Configuration_adv.h must exist
|
|
|
|
|
[[ -f "$CONF"/Configuration.h || -f "$CONF"/Configuration_adv.h ]] || { echo "[NONE] $DIR" ; continue ; }
|
|
|
|
|
|
|
|
|
|
# Command arguments for 'build_example'
|
|
|
|
|
CARGS=("-b" "$OPATH" "-c" "$DIR")
|
|
|
|
|
CARGS=("-b" "$CBASE" "-c" "$DIR")
|
|
|
|
|
|
|
|
|
|
# Exporting? Add -e argument
|
|
|
|
|
((CEXPORT)) && CARGS+=("-e" "$CEXPORT")
|
|
|
|
@@ -189,16 +192,16 @@ for CONF in $CONF_TREE ; do
|
|
|
|
|
else
|
|
|
|
|
# Remember where we are in case of failure
|
|
|
|
|
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
|
|
|
|
|
((DEBUG)) && echo "\"$HERE/build_example\" ${CARGS[@]}"
|
|
|
|
|
((DEBUG)) && echo "build_example ${CARGS[@]}"
|
|
|
|
|
# Invoke build_example
|
|
|
|
|
"$HERE"/build_example "${CARGS[@]}" || { echo "Failed to build $DIR" ; exit ; }
|
|
|
|
|
build_example "${CARGS[@]}" || { echo "Failed to build $DIR" ; exit ; }
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
|
|
|
|
|
|
|
|
|
|
echo ; echo
|
|
|
|
|
echo
|
|
|
|
|
((--LIMIT)) || { echo "Specified limit reached" ; PAUSE=1 ; break ; }
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Delete the build state if not paused early
|
|
|
|
|
[[ $PAUSE ]] || rm "$STAT_FILE"
|
|
|
|
|
[[ $PAUSE ]] || rm -f "$STAT_FILE"
|
|
|
|
|