0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-03-10 00:23:01 +00:00

🧑‍💻 More compatible Build Scripts

Followup to d36d9cb506
This commit is contained in:
Scott Lahteine 2024-09-16 15:36:39 -05:00
parent 72b09fe4cb
commit 73b6ba8fe3
3 changed files with 35 additions and 32 deletions

View file

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

View file

@ -32,8 +32,9 @@ build_example -b|--base=<path> - Configurations root folder (e.g., ./.pio/bu
} }
HERE=`dirname $0` HERE=`dirname $0`
PATH="$HERE:$PATH"
source "$HERE/mfutil" . mfutil
annc() { echo -e "\033[0;32m$1\033[0m" ; } annc() { echo -e "\033[0;32m$1\033[0m" ; }
@ -100,7 +101,7 @@ SUB="$SUB1/$CONFIG"
[[ -d "$SUB" ]] || { echo "-c|--config $CONFIG doesn't exist" ; exit 1 ; } [[ -d "$SUB" ]] || { echo "-c|--config $CONFIG doesn't exist" ; exit 1 ; }
# ...and contains Configuration.h or Configuration_adv.h # ...and contains Configuration.h or Configuration_adv.h
[[ -n $(compgen -G "$SUB/Configuration*.h") ]] || { echo "No configuration files found in $SUB" ; exit 1 ; } [[ -f "$SUB"/Configuration.h || -f "$SUB"/Configuration_adv.h ]] || { echo "No configuration files found in $SUB" ; exit 1 ; }
# Get the location for exports and archives # Get the location for exports and archives
if [[ -n $OUTBASE ]]; then if [[ -n $OUTBASE ]]; then
@ -173,7 +174,7 @@ fi
set +e set +e
echo "Building example $CONFIG ..." echo "Building example $CONFIG ..."
"$HERE/mftest" -s -a -n1 ; ERR=$? mftest -s -a -n1 ; ERR=$?
((ERR)) && echo "Failed" || echo "Success" ((ERR)) && echo "Failed" || echo "Success"
@ -191,6 +192,7 @@ fi
# Currently only BOARD_CREALITY_F401RE env:STM32F401RE_creality # Currently only BOARD_CREALITY_F401RE env:STM32F401RE_creality
if ((ARCHIVE)); then if ((ARCHIVE)); then
annc "Archiving" annc "Archiving"
rm -f "$ARCSUB"/*.bin.tar.gz "$ARCSUB"/*.hex.tar.gz
find "$BUILD" \( "${BNAME[@]}" \) -exec sh -c ' find "$BUILD" \( "${BNAME[@]}" \) -exec sh -c '
ARCSUB="$1" ARCSUB="$1"
shift 1 shift 1

View file

@ -167,8 +167,6 @@ if ((AUTO_BUILD)); then
MB=$(awk "$ACODE" Marlin/Configuration.h 2>/dev/null) MB=$(awk "$ACODE" Marlin/Configuration.h 2>/dev/null)
[[ -z $MB ]] && MB=$(awk "$ACODE" Marlin/Config.h 2>/dev/null) [[ -z $MB ]] && MB=$(awk "$ACODE" Marlin/Config.h 2>/dev/null)
[[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; } [[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; }
echo "Got $MB"
exit
BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h ) BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
BNUM=$( sed -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" ) BNUM=$( sed -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
BDESC=$( sed -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" ) BDESC=$( sed -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )