Merge upstream changes from Marlin 2.1.2.5
This commit is contained in:
0
buildroot/bin/__init__.py
Normal file
0
buildroot/bin/__init__.py
Normal file
@@ -2,31 +2,48 @@
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# build_all_examples [-b|--branch=<branch>] - Branch to fetch from Configurations repo
|
||||
# build_all_examples [-b|--branch=<branch>] - Branch to fetch from Configurations repo (import-2.1.x)
|
||||
# [-B|--base] - Base path of configurations, overriding -b
|
||||
# [-c|--continue] - Continue the paused build
|
||||
# [-d|--debug] - Print extra debug output
|
||||
# [-i|--ini] - Archive ini/json/yml files in the temp config folder
|
||||
# [-l|--limit=#] - Limit the number of builds in this run
|
||||
# [-n|--nobuild] - Don't actually build anything.
|
||||
# [-p|--purge] - Purge the status file and start over
|
||||
# [-s|--skip] - Continue the paused build, skipping one
|
||||
# [-r|--resume=<path>] - Start at some config in the filesystem order
|
||||
# [-s|--skip] - Do the thing
|
||||
#
|
||||
# build_all_examples [...] branch [resume-from]
|
||||
# [-l|--limit=#] - Limit the number of builds in this run
|
||||
# [-d|--debug] - Print extra debug output (after)
|
||||
# [-n|--nobuild] - Don't actually build anything
|
||||
# [-f|--nofail] - Don't stop on a failed build
|
||||
# [-e|--export=N] - Set CONFIG_EXPORT and export into each config folder
|
||||
# [-a|--archive] - Copy the binary to the export location
|
||||
# [-o|--output] - Redirect export / archiving to another location
|
||||
# (By default export to origin config folders)
|
||||
# [-h|--help] - Print usage and exit
|
||||
#
|
||||
|
||||
HERE=`dirname $0`
|
||||
PATH="$HERE:$PATH"
|
||||
|
||||
. "$HERE/mfutil"
|
||||
. mfutil
|
||||
|
||||
GITREPO=https://github.com/MarlinFirmware/Configurations.git
|
||||
STAT_FILE=./.pio/.buildall
|
||||
|
||||
usage() { echo "
|
||||
Usage: $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-r|--resume=<path>]
|
||||
$SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-c|--continue]
|
||||
$SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-s|--skip]
|
||||
$SELF [-b|--branch=<branch>] [-d|--debug] [-n|--nobuild]
|
||||
$SELF [...] branch [resume-point]
|
||||
usage() { echo "Usage:
|
||||
|
||||
build_all_examples [-b|--branch=<branch>] - Branch to fetch from Configurations repo (import-2.1.x)
|
||||
[-B|--base] - Base path of configurations, overriding -b
|
||||
[-c|--continue] - Continue the paused build
|
||||
[-p|--purge] - Purge the status file and start over
|
||||
[-s|--skip] - Continue the paused build, skipping one
|
||||
[-r|--resume=<path>] - Start at some config in the filesystem order
|
||||
[-e|--export=N] - Set CONFIG_EXPORT and export to the export location
|
||||
[-a|--archive] - Copy the binary to the export location
|
||||
[-o|--output] - Redirect export / archiving to another location
|
||||
(By default export to origin config folders)
|
||||
[-d|--debug] - Print extra debug output (after)
|
||||
[-l|--limit=#] - Limit the number of builds in this run
|
||||
[-n|--nobuild] - Don't actually build anything
|
||||
[-f|--nofail] - Don't stop on a failed build
|
||||
[-h|--help] - Print usage and exit
|
||||
"
|
||||
}
|
||||
|
||||
@@ -36,50 +53,60 @@ unset FIRST_CONF
|
||||
EXIT_USAGE=
|
||||
LIMIT=1000
|
||||
|
||||
while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
||||
while getopts 'aB:b:ce:fdhl:no:pr:sv-:' OFLAG; do
|
||||
case "${OFLAG}" in
|
||||
b) BRANCH=$OPTARG ; bugout "Branch: $BRANCH" ;;
|
||||
r) FIRST_CONF="$OPTARG" ; bugout "Resume: $FIRST_CONF" ;;
|
||||
c) CONTINUE=1 ; bugout "Continue" ;;
|
||||
s) CONTSKIP=1 ; bugout "Continue, skipping" ;;
|
||||
i) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
|
||||
a) ARCHIVE=1 ; bugout "Archiving" ;;
|
||||
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" ;;
|
||||
c) CONTINUE=1 ; bugout "Continue" ;;
|
||||
s) CONTSKIP=1 ; bugout "Continue, skipping" ;;
|
||||
e) CEXPORT=$OPTARG ; bugout "Export $CEXPORT" ;;
|
||||
o) OUTBASE="${OPTARG%/}" ; bugout "Archive to $OUTBASE" ;;
|
||||
h) EXIT_USAGE=1 ; break ;;
|
||||
l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;;
|
||||
d|v) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
n) DRYRUN=1 ; bugout "Dry Run" ;;
|
||||
-) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
|
||||
l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;;
|
||||
d|v) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
n) DRYRUN=1 ; bugout "Dry Run" ;;
|
||||
p) PURGE=1 ; bugout "Purge stat file" ;;
|
||||
-) ONAM="${OPTARG%%=*}" ; OVAL="${OPTARG#*=}"
|
||||
case "$ONAM" in
|
||||
branch) BRANCH=$OVAL ; bugout "Branch: $BRANCH" ;;
|
||||
resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;;
|
||||
continue) CONTINUE=1 ; bugout "Continue" ;;
|
||||
skip) CONTSKIP=2 ; bugout "Continue, skipping" ;;
|
||||
limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;;
|
||||
ini) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
|
||||
archive) ARCHIVE=1 ; bugout "Archiving" ;;
|
||||
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" ;;
|
||||
continue) CONTINUE=1 ; bugout "Continue" ;;
|
||||
skip) CONTSKIP=1 ; bugout "Continue, skipping" ;;
|
||||
export) CEXPORT=$OVAL ; bugout "Export $EXPORT" ;;
|
||||
output) OUTBASE="${OVAL%/}" ; bugout "Archive to $OUTBASE" ;;
|
||||
limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;;
|
||||
help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
|
||||
debug) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
nobuild) DRYRUN=1 ; bugout "Dry Run" ;;
|
||||
debug) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
nobuild) DRYRUN=1 ; bugout "Dry Run" ;;
|
||||
purge) PURGE=1 ; bugout "Purge stat file" ;;
|
||||
*) EXIT_USAGE=2 ; echo "$SELF: unrecognized option \`--$ONAM'" ; break ;;
|
||||
esac
|
||||
;;
|
||||
*) EXIT_USAGE=2 ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Extra arguments count as BRANCH, FIRST_CONF
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# > 0 ]] && { BRANCH=$1 ; shift 1 ; bugout "BRANCH=$BRANCH" ; }
|
||||
[[ $# > 0 ]] && { FIRST_CONF=$1 ; shift 1 ; bugout "FIRST_CONF=$FIRST_CONF" ; }
|
||||
[[ $# > 0 ]] && { EXIT_USAGE=2 ; echo "too many arguments" ; }
|
||||
|
||||
# Check for mixed continue, skip, resume arguments. Only one should be used.
|
||||
((CONTINUE + CONTSKIP + ISRES + PURGE > 1)) && { echo "Don't mix -c, -p, -s, and -r options" ; echo ; EXIT_USAGE=2 ; }
|
||||
|
||||
# Exit with helpful usage information
|
||||
((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; }
|
||||
|
||||
echo "This script downloads each Configuration and attempts to build it."
|
||||
echo "On failure the last-built configs will be left in your working copy."
|
||||
echo
|
||||
echo "This script downloads all example configs and attempts to build them."
|
||||
echo "On failure the last-built configs are left in your working copy."
|
||||
echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'."
|
||||
echo
|
||||
|
||||
if [[ -f "$STAT_FILE" ]]; then
|
||||
IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE"
|
||||
fi
|
||||
[[ -n $PURGE ]] && rm -f "$STAT_FILE"
|
||||
[[ -z $FIRST_CONF && -f "$STAT_FILE" ]] && IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE"
|
||||
|
||||
# If -c is given start from the last attempted build
|
||||
if ((CONTINUE)); then
|
||||
@@ -97,77 +124,90 @@ elif ((CONTSKIP)); then
|
||||
fi
|
||||
|
||||
# Check if the current repository has unmerged changes
|
||||
if [[ $SKIP_CONF ]]; then
|
||||
if ((SKIP_CONF)); then
|
||||
echo "Skipping $FIRST_CONF"
|
||||
elif [[ $FIRST_CONF ]]; then
|
||||
elif [[ -n $FIRST_CONF ]]; then
|
||||
echo "Resuming from $FIRST_CONF"
|
||||
else
|
||||
git diff --quiet || { echo "The working copy is modified. Commit or stash changes before proceeding."; exit ; }
|
||||
fi
|
||||
|
||||
# Create a temporary folder inside .pio
|
||||
TMP=./.pio/build-$BRANCH
|
||||
[[ -d "$TMP" ]] || mkdir -p $TMP
|
||||
|
||||
# Download Configurations into the temporary folder
|
||||
if [[ ! -e "$TMP/README.md" ]]; then
|
||||
echo "Fetching Configurations from GitHub to $TMP"
|
||||
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; 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
|
||||
echo "Using cached Configurations at $TMP"
|
||||
# Make a Configurations temporary folder if needed
|
||||
CBASE=./.pio/build-$BRANCH
|
||||
[[ -d "$CBASE" ]] || mkdir -p "$CBASE"
|
||||
# Download the specified Configurations branch if needed
|
||||
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
|
||||
|
||||
echo -e "Start build...\n====================="
|
||||
# Build
|
||||
echo -e "=====================\nProceed with builds...\n====================="
|
||||
shopt -s nullglob
|
||||
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
|
||||
|
||||
export PAUSE=1
|
||||
|
||||
# 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 $'\0' CONF; do
|
||||
|
||||
# Remove the file name and slash from the end of the path
|
||||
CONF=${CONF%/*}
|
||||
|
||||
# Get a config's directory name
|
||||
DIR=$( echo $CONF | "$SED" "s|$TMP/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 ; }
|
||||
|
||||
# ...if skipping, don't build this one
|
||||
compgen -G "${CONF}Con*.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" "$CBASE" "-c" "$DIR")
|
||||
|
||||
# Exporting? Add -e argument
|
||||
((CEXPORT)) && CARGS+=("-e" "$CEXPORT")
|
||||
|
||||
# Continue on fail? Add -f argument
|
||||
((NOFAIL)) && CARGS+=("-f")
|
||||
|
||||
# Archive the build? Add -a argument
|
||||
((ARCHIVE)) && CARGS+=("-a")
|
||||
|
||||
# Redirecting the export/archive output? Add -o argument
|
||||
[[ -n $OUTBASE ]] && CARGS+=("-o" "$OUTBASE")
|
||||
|
||||
# Build or print build command for --nobuild
|
||||
if [[ $DRYRUN ]]; then
|
||||
echo -e "\033[0;32m[DRYRUN] build_example internal \"$TMP\" \"$DIR\"\033[0m"
|
||||
if ((DRYRUN)); then
|
||||
echo -e "\033[0;32m[DRYRUN] build_example ${CARGS[@]}\033[0m"
|
||||
else
|
||||
# Remember where we are in case of failure
|
||||
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
|
||||
# Build folder is unknown so delete all report files
|
||||
if [[ $COPY_INI ]]; then
|
||||
IFIND='find ./.pio/build/ -name "config.ini" -o -name "schema.json" -o -name "schema.yml"'
|
||||
$IFIND -exec rm "{}" \;
|
||||
fi
|
||||
((DEBUG)) && echo "\"$HERE/build_example\" internal \"$TMP\" \"$DIR\""
|
||||
"$HERE/build_example" internal "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
|
||||
# Build folder is unknown so copy all report files
|
||||
[[ $COPY_INI ]] && $IFIND -exec cp "{}" "$CONF" \;
|
||||
((DEBUG)) && echo "build_example ${CARGS[@]}"
|
||||
# Invoke build_example
|
||||
build_example "${CARGS[@]}" || { echo "Failed to build $DIR" ; exit ; }
|
||||
fi
|
||||
|
||||
((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
|
||||
echo
|
||||
((--LIMIT)) || { echo "Specified limit reached" ; break ; }
|
||||
echo
|
||||
|
||||
export PAUSE=0
|
||||
|
||||
done
|
||||
|
||||
# Delete the build state if not paused early
|
||||
[[ $PAUSE ]] || rm "$STAT_FILE"
|
||||
echo "Exiting"
|
||||
|
||||
# Delete the temp folder if not preserving generated INI files
|
||||
if [[ -e "$TMP/config/examples" ]]; then
|
||||
if [[ $COPY_INI ]]; then
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
$OPEN "$TMP"
|
||||
elif [[ ! $PAUSE ]]; then
|
||||
rm -rf "$TMP"
|
||||
fi
|
||||
fi
|
||||
# Delete the build state if not paused early
|
||||
((PAUSE)) || rm -f "$STAT_FILE"
|
||||
|
@@ -1,43 +1,229 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# build_example
|
||||
# Usage:
|
||||
#
|
||||
# Usage: build_example internal config-home config-folder
|
||||
# build_example -b|--base=<path> - Configurations root folder (e.g., ./.pio/build-BRANCH)
|
||||
# -c|--config=<rel> - Sub-path of the configs to build (within config/examples)
|
||||
# [-e|--export=N] - Use CONFIG_EXPORT N to export the config to the export location
|
||||
# [-a|--archive] - Archive the build (to the export location)
|
||||
# [-o|--output] - Redirect export / archiving to another location
|
||||
# (By default export to origin config folder)
|
||||
# [-f|--nofail] - Don't stop on a failed build
|
||||
# [-w|--nowarn] - Suppress warnings with extra config options
|
||||
# [-r|--reveal] - Reveal the config/export folder after the build
|
||||
# [-h|--help] - Print usage and exit
|
||||
# [--allow] - Allow this script to run standalone
|
||||
#
|
||||
|
||||
usage() { echo "Usage:
|
||||
|
||||
build_example -b|--base=<path> - Configurations root folder (e.g., ./.pio/build-BRANCH)
|
||||
-c|--config=<rel> - Sub-path of the configs to build (within config/examples)
|
||||
[-e|--export=N] - Use CONFIG_EXPORT N to export the config to the export location
|
||||
[-a|--archive] - Archive the build (to the export location)
|
||||
[-o|--output] - Redirect export / archiving to another location
|
||||
(By default export to origin config folder)
|
||||
[-f|--nofail] - Don't stop on a failed build
|
||||
[-w|--nowarn] - Suppress warnings with extra config options
|
||||
[-r|--reveal] - Reveal the config/export folder after the build
|
||||
[-h|--help] - Print usage and exit
|
||||
[--allow] - Allow this script to run standalone
|
||||
"
|
||||
}
|
||||
|
||||
HERE=`dirname $0`
|
||||
PATH="$HERE:$PATH"
|
||||
|
||||
. "$HERE/mfutil"
|
||||
. mfutil
|
||||
|
||||
# Require 'internal' as the first argument
|
||||
[[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
|
||||
annc() { echo -e "\033[0;32m$1\033[0m" ; }
|
||||
alrt() { echo -e "\033[0;31m$1\033[0m" ; }
|
||||
|
||||
echo "Testing $3:"
|
||||
# Get arguments
|
||||
BUILD=./.pio/build
|
||||
CLEANER=
|
||||
ALLOW=
|
||||
ARCHIVE=
|
||||
BASE=
|
||||
CONFIG=
|
||||
REVEAL=
|
||||
EXPNUM=
|
||||
NOFAIL=
|
||||
OUTBASE=
|
||||
while getopts 'ab:c:e:fhio:r-:' OFLAG; do
|
||||
case "${OFLAG}" in
|
||||
a) ARCHIVE=1 ;;
|
||||
b) BASE="${OPTARG%/}" ;;
|
||||
c) CONFIG="${OPTARG%/}" ;;
|
||||
e) EXPNUM="$OPTARG" ;;
|
||||
o) OUTBASE="${OPTARG%/}" ;;
|
||||
h) EXIT_USAGE=1 ; break ;;
|
||||
f) NOFAIL=1 ;;
|
||||
r) REVEAL=1 ;;
|
||||
-) ONAM="${OPTARG%%=*}" ; OVAL="${OPTARG#*=}"
|
||||
case "$ONAM" in
|
||||
archive) ARCHIVE=1 ;;
|
||||
allow) ALLOW=1 ;;
|
||||
base) BASE="${OVAL%/}" ;;
|
||||
config) CONFIG="${OVAL%/}" ;;
|
||||
export) EXPNUM="$OVAL" ;;
|
||||
output) OUTBASE="${OVAL%/}" ;;
|
||||
help) EXIT_USAGE=1 ; break ;;
|
||||
nofail) NOFAIL=1 ;;
|
||||
reveal) REVEAL=1 ;;
|
||||
*) EXIT_USAGE=2 ; echo "$SELF: unrecognized option \`--$ONAM'" ; break ;;
|
||||
esac
|
||||
;;
|
||||
*) EXIT_USAGE=2 ; break ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
SUB=$2/config/examples/$3
|
||||
[[ -d "$SUB" ]] || { echo "$SUB is not a good path" ; exit 1 ; }
|
||||
# Must be called from another script (or with --allow)
|
||||
[[ $ALLOW || $SHLVL -gt 2 ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
|
||||
|
||||
compgen -G "${SUB}Con*.h" > /dev/null || { echo "No configuration files found in $SUB" ; exit 1 ; }
|
||||
# Exit with helpful usage information
|
||||
((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; }
|
||||
|
||||
# -b|--base and -c|--config are required
|
||||
[[ -z $BASE ]] && { echo "-b|--base is required" ; exit 1 ; }
|
||||
[[ -z $CONFIG ]] && { echo "-c|--config is required" ; exit 1 ; }
|
||||
|
||||
# Expand ~ to $HOME in provided arguments
|
||||
BASE=${BASE/#\~/$HOME}
|
||||
CONFIG=${CONFIG/#\~/$HOME}
|
||||
|
||||
# Make sure the examples exist
|
||||
SUB1="$BASE/config/examples"
|
||||
[[ -d "$SUB1" ]] || { echo "-b|--base $BASE doesn't contain config/examples" ; exit 1 ; }
|
||||
|
||||
# Make sure the specific config folder exists
|
||||
SUB="$SUB1/$CONFIG"
|
||||
[[ -d "$SUB" ]] || { echo "-c|--config $CONFIG doesn't exist" ; exit 1 ; }
|
||||
|
||||
# ...and contains Configuration.h or Configuration_adv.h
|
||||
[[ -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
|
||||
if [[ -n $OUTBASE ]]; then
|
||||
ARCSUB="${OUTBASE/#\~/$HOME}/$CONFIG"
|
||||
mkdir -p "$ARCSUB"
|
||||
else
|
||||
ARCSUB="$SUB"
|
||||
fi
|
||||
|
||||
# Delete any config files from previous builds
|
||||
rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h
|
||||
|
||||
# Copy configurations into the Marlin folder
|
||||
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
|
||||
cp "$BASE"/config/default/*.h Marlin/
|
||||
cp "$SUB"/*.h Marlin/
|
||||
|
||||
rm -f Marlin/Config.h Marlin/Config-export.h
|
||||
|
||||
set -e
|
||||
|
||||
# Strip #error lines from Configuration.h
|
||||
IFS=$'\n'; set -f
|
||||
$SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h
|
||||
rm Marlin/Configuration.h~
|
||||
unset IFS; set +f
|
||||
# Strip #error lines from Configuration.h using
|
||||
awk 'NR < 20 || NR > 30 || !/#error/' Marlin/Configuration.h > Marlin/Configuration.h~
|
||||
mv Marlin/Configuration.h~ Marlin/Configuration.h
|
||||
|
||||
# Hide several warnings when not exporting
|
||||
[[ -z $EXPNUM ]] && CLEANER=1
|
||||
|
||||
# Suppress fatal warnings
|
||||
echo -e "\n#define NO_CONTROLLER_CUSTOM_WIRING_WARNING" >> Marlin/Configuration.h
|
||||
if ((CLEANER)); then
|
||||
opt_add NO_CONTROLLER_CUSTOM_WIRING_WARNING
|
||||
opt_add NO_AUTO_ASSIGN_WARNING
|
||||
opt_add NO_CREALITY_DRIVER_WARNING
|
||||
opt_add DIAG_JUMPERS_REMOVED
|
||||
opt_add DIAG_PINS_REMOVED
|
||||
opt_add NO_MK3_FAN_PINS_WARNING
|
||||
opt_add NO_USER_FEEDBACK_WARNING
|
||||
opt_add NO_Z_SAFE_HOMING_WARNING
|
||||
opt_add NO_LCD_CONTRAST_WARNING
|
||||
opt_add NO_MICROPROBE_WARNING
|
||||
opt_add NO_CONFIGURATION_EMBEDDING_WARNING
|
||||
opt_add NO_HOMING_CURRENT_WARNING
|
||||
fi
|
||||
|
||||
echo "Building the firmware now..."
|
||||
"$HERE/mftest" -s -a -n1 || { echo "Failed"; exit 1; }
|
||||
# Possible exported file names (in the build folder)
|
||||
ENAME=("-name" "marlin_config.json" \
|
||||
"-o" "-name" "config.ini" \
|
||||
"-o" "-name" "schema.json" \
|
||||
"-o" "-name" "schema.yml")
|
||||
|
||||
echo "Success"
|
||||
# Possible built firmware names (in the build folder)
|
||||
BNAME=("-name" 'firmware*.hex' \
|
||||
"-o" "-name" "firmware*.bin" \
|
||||
"-o" "-name" "project*.bin" \
|
||||
"-o" "-name" "Robin*.bin" \
|
||||
"-o" "-name" "main_*.bin")
|
||||
|
||||
mkdir -p "$BUILD"
|
||||
|
||||
# If EXPNUM is set then apply to the config before build
|
||||
if [[ $EXPNUM ]]; then
|
||||
opt_set CONFIG_EXPORT $EXPNUM
|
||||
# Clean up old exports
|
||||
find "$BUILD" \( "${ENAME[@]}" \) -exec rm "{}" \;
|
||||
fi
|
||||
|
||||
((ARCHIVE)) && find "$BUILD" \( "${BNAME[@]}" \) -exec rm "{}" \;
|
||||
|
||||
set +e
|
||||
|
||||
echo "Building example $CONFIG ..."
|
||||
mftest -s -a -n1 ; ERR=$?
|
||||
|
||||
((ERR)) && alrt "Failed ($ERR)" || annc "Success"
|
||||
|
||||
set -e
|
||||
|
||||
if [[ $ERR -gt 0 ]]; then
|
||||
|
||||
# Error? For --nofail simply log. Otherwise return the error.
|
||||
if [[ -n $NOFAIL ]]; then
|
||||
date +"%F %T [FAIL] $CONFIG" >>./.pio/error-log.txt
|
||||
else
|
||||
exit $ERR
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# Copy exports back to the configs
|
||||
if [[ -n $EXPNUM ]]; then
|
||||
annc "Exporting $EXPNUM"
|
||||
[[ -f Marlin/Config-export.h ]] && { cp Marlin/Config-export.h "$ARCSUB"/Config.h ; }
|
||||
find "$BUILD" \( "${ENAME[@]}" \) -exec cp "{}" "$ARCSUB" \;
|
||||
fi
|
||||
|
||||
# Copy potential firmware files into the config folder
|
||||
# TODO: Consider firmware that needs an STM32F4_UPDATE folder.
|
||||
# Currently only BOARD_CREALITY_F401RE env:STM32F401RE_creality
|
||||
if ((ARCHIVE)); then
|
||||
annc "Archiving"
|
||||
rm -f "$ARCSUB"/*.bin.tar.gz "$ARCSUB"/*.hex.tar.gz
|
||||
find "$BUILD" \( "${BNAME[@]}" \) -exec sh -c '
|
||||
ARCSUB="$1"
|
||||
CONFIG="$2"
|
||||
shift 2
|
||||
for FILE in "$@"; do
|
||||
cd "${FILE%/*}"
|
||||
NAME=${FILE##*/}
|
||||
SHRT=${NAME%.*}
|
||||
SHASUM=$(sha256sum "$NAME" | cut -d" " -f1)
|
||||
tar -czf "$ARCSUB/$SHRT.tar.gz" "$NAME"
|
||||
echo "$CONFIG\n$SHASUM" > "$ARCSUB/$NAME.sha256.txt"
|
||||
rm "$NAME"
|
||||
cd - >/dev/null
|
||||
done
|
||||
' sh "$ARCSUB" "$CONFIG" {} +
|
||||
fi
|
||||
|
||||
# Reveal the configs after the build, if requested
|
||||
((REVEAL)) && { annc "Revealing $ARCSUB" ; open "$ARCSUB" ; }
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@@ -3,12 +3,10 @@
|
||||
# exit on first failure
|
||||
set -e
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
FN="platformio.ini"
|
||||
|
||||
if [[ $1 == "-n" ]]; then
|
||||
"${SED}" -i "s/default_src_filter/org_src_filter/" $FN
|
||||
"${SED}" -i "/org_src_filter/ s/^/default_src_filter = +<src\/*>\n/" $FN
|
||||
awk '/default_src_filter/ { sub("default_src_filter", "org_src_filter"); print "default_src_filter = +<src/*>"; } 1' $FN > $FN~ && mv $FN~ $FN
|
||||
else
|
||||
git checkout $FN 2>/dev/null
|
||||
fi
|
||||
|
96
buildroot/bin/config.py
Executable file
96
buildroot/bin/config.py
Executable file
@@ -0,0 +1,96 @@
|
||||
'''
|
||||
config.py - Helper functions for config manipulation
|
||||
'''
|
||||
import re
|
||||
|
||||
FILES = ('Marlin/Configuration.h', 'Marlin/Configuration_adv.h')
|
||||
|
||||
def set(file_path, define_name, value):
|
||||
'''
|
||||
Replaces a define in a file with a new value.
|
||||
Returns True if the define was found and replaced, False otherwise.
|
||||
'''
|
||||
# Read the contents of the file
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.readlines()
|
||||
|
||||
modified = False
|
||||
for i in range(len(content)):
|
||||
# Regex to match the desired pattern
|
||||
match = re.match(r'^(\s*)(/*)(\s*)(#define\s+{})\s+(.*)$'.format(re.escape(define_name)), content[i])
|
||||
if match:
|
||||
new_line = f"{match[1]}{match[3]}{match[4]} {value} // {match[5]}\n"
|
||||
content[i] = new_line
|
||||
modified = True
|
||||
|
||||
# Write the modified content back to the file only if changes were made
|
||||
if modified:
|
||||
with open(file_path, 'w') as f:
|
||||
f.writelines(content)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def add(file_path, define_name, value=""):
|
||||
'''
|
||||
Insert a define on the first blank line in a file.
|
||||
Returns True if the define was found and replaced, False otherwise.
|
||||
'''
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.readlines()
|
||||
|
||||
# Prepend a space to the value if it's not empty
|
||||
if value != "":
|
||||
value = " " + value
|
||||
|
||||
# Find the first blank line to insert the new define
|
||||
for i in range(len(content)):
|
||||
if content[i].strip() == '':
|
||||
# Insert the define at the first blank line
|
||||
content.insert(i, f"#define {define_name}{value}\n")
|
||||
break
|
||||
else:
|
||||
# If no blank line is found, append to the end
|
||||
content.append(f"#define {define_name}{value}\n")
|
||||
|
||||
with open(file_path, 'w') as f:
|
||||
f.writelines(content)
|
||||
|
||||
def enable(file_path, define_name, enable=True):
|
||||
'''
|
||||
Uncomment or comment the named defines in the given file path.
|
||||
Returns True if the define was found, False otherwise.
|
||||
'''
|
||||
# Read the contents of the file
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.readlines()
|
||||
|
||||
# Prepare the regex
|
||||
regex = re.compile(r'^(\s*)(/*)(\s*)(#define\s+{}\b.*?)( *//.*)?$'.format(re.escape(define_name)))
|
||||
|
||||
# Find the define in the file and uncomment or comment it
|
||||
found = False
|
||||
modified = False
|
||||
for i in range(len(content)):
|
||||
match = regex.match(content[i])
|
||||
if not match: continue
|
||||
found = True
|
||||
if enable:
|
||||
if match[2]:
|
||||
modified = True
|
||||
comment = '' if match[5] is None else ' ' + match[5]
|
||||
content[i] = f"{match[1]}{match[3]}{match[4]}{comment}\n"
|
||||
else:
|
||||
if not match[2]:
|
||||
modified = True
|
||||
comment = '' if match[5] is None else match[5]
|
||||
if comment.startswith(' '): comment = comment[2:]
|
||||
content[i] = f"{match[1]}//{match[3]}{match[4]}{comment}\n"
|
||||
break
|
||||
|
||||
# Write the modified content back to the file only if changes were made
|
||||
if modified:
|
||||
with open(file_path, 'w') as f:
|
||||
f.writelines(content)
|
||||
|
||||
return found
|
@@ -19,6 +19,7 @@ VERSION="$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null || true)"
|
||||
STRING_DISTRIBUTION_DATE="${STRING_DISTRIBUTION_DATE:-$(date '+%Y-%m-%d %H:%M')}"
|
||||
SHORT_BUILD_VERSION="${SHORT_BUILD_VERSION:-${BRANCH}}"
|
||||
DETAILED_BUILD_VERSION="${DETAILED_BUILD_VERSION:-${BRANCH}-${VERSION}}"
|
||||
PROTOCOL_VERSION="1.0"
|
||||
|
||||
# Gets some misc options from their defaults
|
||||
DEFAULT_MACHINE_UUID="${DEFAULT_MACHINE_UUID:-$(awk -F'"' \
|
||||
@@ -65,68 +66,52 @@ cat > "${WRITE_FILE}" <<EOF
|
||||
*/
|
||||
|
||||
/**
|
||||
* Marlin release version identifier
|
||||
*/
|
||||
#ifndef SHORT_BUILD_VERSION
|
||||
#define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
|
||||
#endif
|
||||
* Marlin release version identifier
|
||||
*/
|
||||
#define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
|
||||
|
||||
/**
|
||||
* Verbose version identifier which should contain a reference to the location
|
||||
* from where the binary was downloaded or the source code was compiled.
|
||||
*/
|
||||
#ifndef DETAILED_BUILD_VERSION
|
||||
#define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
|
||||
#endif
|
||||
* Verbose version identifier which should contain a reference to the location
|
||||
* from where the binary was downloaded or the source code was compiled.
|
||||
*/
|
||||
#define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
|
||||
|
||||
/**
|
||||
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
#ifndef STRING_DISTRIBUTION_DATE
|
||||
#define STRING_DISTRIBUTION_DATE "${STRING_DISTRIBUTION_DATE}"
|
||||
#endif
|
||||
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
#define STRING_DISTRIBUTION_DATE "${STRING_DISTRIBUTION_DATE}"
|
||||
|
||||
/**
|
||||
* The protocol for communication to the host. Protocol indicates communication
|
||||
* standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc.
|
||||
* (Other behaviors are given by the firmware version and capabilities report.)
|
||||
*/
|
||||
#ifndef PROTOCOL_VERSION
|
||||
#define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
|
||||
#endif
|
||||
* The protocol for communication to the host. Protocol indicates communication
|
||||
* standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc.
|
||||
* (Other behaviors are given by the firmware version and capabilities report.)
|
||||
*/
|
||||
#define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
|
||||
|
||||
/**
|
||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||
*/
|
||||
#ifndef MACHINE_NAME
|
||||
#define MACHINE_NAME "${MACHINE_NAME}"
|
||||
#endif
|
||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||
*/
|
||||
#define MACHINE_NAME "${MACHINE_NAME}"
|
||||
|
||||
/**
|
||||
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
|
||||
* Code which is installed on the device. In most cases —unless the manufacturer
|
||||
* has a distinct Github fork— the Source Code URL should just be the main
|
||||
* Marlin repository.
|
||||
*/
|
||||
#ifndef SOURCE_CODE_URL
|
||||
#define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
|
||||
#endif
|
||||
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
|
||||
* Code which is installed on the device. In most cases —unless the manufacturer
|
||||
* has a distinct Github fork— the Source Code URL should just be the main
|
||||
* Marlin repository.
|
||||
*/
|
||||
#define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
|
||||
|
||||
/**
|
||||
* Default generic printer UUID.
|
||||
*/
|
||||
#ifndef DEFAULT_MACHINE_UUID
|
||||
#define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
|
||||
#endif
|
||||
* Default generic printer UUID.
|
||||
*/
|
||||
#define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
|
||||
|
||||
/**
|
||||
* The WEBSITE_URL is the location where users can get more information such as
|
||||
* documentation about a specific Marlin release.
|
||||
*/
|
||||
#ifndef WEBSITE_URL
|
||||
#define WEBSITE_URL "${WEBSITE_URL}"
|
||||
#endif
|
||||
* The WEBSITE_URL is the location where users can get more information such as
|
||||
* documentation about a specific Marlin release.
|
||||
*/
|
||||
#define WEBSITE_URL "${WEBSITE_URL}"
|
||||
|
||||
EOF
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
[[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; }
|
||||
|
||||
which pio || { echo "Make sure 'pio' is in your execution PATH." ; exit 1 ; }
|
||||
which pio >/dev/null || { echo "Make sure 'pio' is in your execution PATH." ; exit 1 ; }
|
||||
|
||||
perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
|
||||
errout() { echo -e "\033[0;31m$1\033[0m" ; }
|
||||
@@ -41,7 +41,6 @@ env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6
|
||||
TESTPATH=buildroot/tests
|
||||
|
||||
STATE_FILE="./.pio/.mftestrc"
|
||||
SED=$(which gsed sed | head -n1)
|
||||
|
||||
shopt -s extglob nocasematch
|
||||
|
||||
@@ -74,7 +73,7 @@ while getopts 'abdhmrsuvyn:t:-:' OFLAG; do
|
||||
u) AUTO_BUILD=2 ; bugout "Auto-Upload target..." ;;
|
||||
v) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
y) BUILD_YES='Y' ; bugout "Build will initiate..." ;;
|
||||
-) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
|
||||
-) ONAM="${OPTARG%%=*}" ; OVAL="${OPTARG#*=}"
|
||||
case "$ONAM" in
|
||||
help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
|
||||
autobuild) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;;
|
||||
@@ -107,6 +106,7 @@ debug|verbose) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
*) EXIT_USAGE=2 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; }
|
||||
|
||||
@@ -158,13 +158,19 @@ if ((AUTO_BUILD)); then
|
||||
*) SYS='uni' ;;
|
||||
esac
|
||||
echo ; echo -n "Auto " ; ((AUTO_BUILD == 2)) && echo "Upload..." || echo "Build..."
|
||||
MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//;s/\r//' )
|
||||
|
||||
#
|
||||
# Get the MOTHERBOARD define value from the .h file and strip off the "BOARD_" prefix
|
||||
#
|
||||
ACODE='/^[[:space:]]*#define[[:space:]]MOTHERBOARD[[:space:]]/ { sub(/^BOARD_/, "", $3); print $3 }'
|
||||
MB=$(awk "$ACODE" Marlin/Configuration.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 ; }
|
||||
BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
|
||||
BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
|
||||
BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
|
||||
BNUM=$( sed -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
|
||||
BDESC=$( sed -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
|
||||
[[ -z $BNUM ]] && { echo "Error - Can't find BOARD_$MB in core/boards.h." ; exit 1 ; }
|
||||
ENVS=( $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | grep -E "#include.+//.+(env|$SYS):[^ ]+" | grep -oE "(env|$SYS):[^ ]+" | $SED -E "s/(env|$SYS)://" ) )
|
||||
ENVS=( $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | grep -E "#include.+//.+(env|$SYS):[^ ]+" | grep -oE "(env|$SYS):[^ ]+" | sed -E "s/(env|$SYS)://" ) )
|
||||
[[ -z $ENVS ]] && { errout "Error - Can't find target(s) for $MB ($BNUM)." ; exit 1 ; }
|
||||
ECOUNT=${#ENVS[*]}
|
||||
|
||||
@@ -192,6 +198,9 @@ if ((AUTO_BUILD)); then
|
||||
[[ $CHOICE > $ECOUNT ]] && { echo "Environment selection out of range." ; exit 1 ; }
|
||||
fi
|
||||
TARGET="${ENVS[$CHOICE-1]}"
|
||||
if [[ $MB == 'SIMULATED' && $TARGET == 'linux_native' ]]; then
|
||||
TARGET="simulator_linux_release" # Skip the linux_native environment
|
||||
fi
|
||||
echo "Selected $TARGET"
|
||||
fi
|
||||
|
||||
@@ -270,7 +279,7 @@ if [[ $CHOICE == 0 ]]; then
|
||||
while IFS= read -r LINE
|
||||
do
|
||||
if [[ $LINE =~ $ISEXEC ]]; then
|
||||
DESC=$( "$SED" -E 's/^exec_test \$1 \$2 "([^"]+)".*$/\1/g' <<<"$LINE" )
|
||||
DESC=$( sed -E 's/^exec_test \$1 \$2 "([^"]+)".*$/\1/g' <<<"$LINE" )
|
||||
(( ++IND < 10 )) && echo -n " "
|
||||
echo " $IND) $DESC"
|
||||
fi
|
||||
@@ -315,7 +324,7 @@ echo "$OUT" | {
|
||||
((IND == CHOICE)) && {
|
||||
GOTX=1
|
||||
[[ -n $DL_DEFAULTS && $LINE =~ $ISRST ]] && LINE="use_example_configs"
|
||||
[[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | $SED -e 's/\\//g' | $SED -E 's/ +/ /g' )
|
||||
[[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | sed -e 's/\\//g' | sed -E 's/ +/ /g' )
|
||||
[[ $LINE =~ $ISCONT ]] || { echo "$CMD" ; eval "$CMD" ; CMD="" ; }
|
||||
}
|
||||
fi
|
||||
|
@@ -4,11 +4,9 @@
|
||||
#
|
||||
|
||||
# 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=$(which gsed sed | head -n1)
|
||||
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
|
||||
which curl &>/dev/null || { echo "curl not found! Please install it."; exit 1 ; }
|
||||
which git &>/dev/null || { echo "git not found! Please install it."; exit 1 ; }
|
||||
which sed &>/dev/null || { echo "sed not found! Please install it."; exit 1 ; }
|
||||
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
|
||||
|
@@ -1,3 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env python
|
||||
|
||||
eval "echo '#define ${@}' | cat - Marlin/Configuration.h > temp && mv temp Marlin/Configuration.h"
|
||||
import sys, config
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
for name in args:
|
||||
config.add(config.FILES[0], name)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -1,15 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env python
|
||||
|
||||
# exit on first failure
|
||||
set -e
|
||||
import sys, os,config
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
|
||||
for opt in "$@" ; do
|
||||
DID=0 ; FOUND=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
"${SED}" -i "/^\(\s*\)\(#define\s\+${opt}\b\s\?\)\(\s\s\)\?/{s//\1\/\/\2/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1
|
||||
((DID||FOUND)) || { grep -E "^\s*//\s*#define\s+${opt}\b" Marlin/$FN.h >/dev/null && FOUND=1 ; }
|
||||
done
|
||||
((DID||FOUND)) || (echo "ERROR: $(basename $0) Can't find ${opt}" >&2 && exit 9)
|
||||
done
|
||||
for name in args:
|
||||
changed = False
|
||||
|
||||
for file in config.FILES:
|
||||
if os.path.exists(file):
|
||||
if config.enable(file, name, False):
|
||||
changed = True
|
||||
|
||||
if not changed:
|
||||
print(f"ERROR: Can't find {name}")
|
||||
exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -1,15 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env python
|
||||
|
||||
# exit on first failure
|
||||
set -e
|
||||
import sys, os,config
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
|
||||
for opt in "$@" ; do
|
||||
DID=0 ; FOUND=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
"${SED}" -i "/^\(\s*\)\/\/\(\s*\)\(#define\s\+${opt}\b\)\( \?\)/{s//\1\2\3\4\4\4/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1
|
||||
((DID||FOUND)) || { grep -E "^\s*#define\s+${opt}\b" Marlin/$FN.h >/dev/null && FOUND=1 ; }
|
||||
done
|
||||
((DID||FOUND)) || (echo "ERROR: $(basename $0) Can't find ${opt}" >&2 && exit 9)
|
||||
done
|
||||
for name in args:
|
||||
changed = False
|
||||
|
||||
for file in config.FILES:
|
||||
if os.path.exists(file):
|
||||
if config.enable(file, name):
|
||||
changed = True
|
||||
|
||||
if not changed:
|
||||
print(f"ERROR: Can't find {name}")
|
||||
exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -23,8 +23,8 @@ esac
|
||||
|
||||
while [[ $# > 0 ]]; do
|
||||
DID=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
FOUND=$( grep -HEn "^\s*${COMM}#define\s+[A-Z0-9_]*${1}" "Marlin/$FN.h" 2>/dev/null )
|
||||
for FN in Marlin/Configuration.h Marlin/Configuration_adv.h; do
|
||||
FOUND=$( grep -HEn "^\s*${COMM}#define\s+[A-Z0-9_]*${1}" $FN 2>/dev/null )
|
||||
[[ -n "$FOUND" ]] && { echo "$FOUND" ; DID=1 ; }
|
||||
done
|
||||
((DID)) || { echo "ERROR: ${MYNAME} - No ${TYPE}match for ${1}" ; exit 9; }
|
||||
|
@@ -1,17 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env python
|
||||
|
||||
# exit on first failure
|
||||
set -e
|
||||
import sys, os, config
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if len(args) % 2 != 0:
|
||||
print("ERROR: Please provide pairs of <name> <value>")
|
||||
return
|
||||
|
||||
while [[ $# > 1 ]]; do
|
||||
DID=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
"${SED}" -i "/^\(\s*\)\/*\s*\(#define\s\+${1}\b\) *\(.*\)$/{s//\1\2 ${2} \/\/ \3/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1
|
||||
done
|
||||
((DID)) ||
|
||||
eval "echo '#define ${1} ${2}' >>Marlin/Configuration.h" ||
|
||||
(echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9)
|
||||
shift 2
|
||||
done
|
||||
for i in range(0, len(args), 2):
|
||||
name = args[i]
|
||||
value = args[i + 1]
|
||||
changed = False
|
||||
|
||||
for file in config.FILES:
|
||||
if os.path.exists(file):
|
||||
if config.set(file, name, value):
|
||||
changed = True
|
||||
|
||||
if not changed:
|
||||
config.add(config.FILES[0], name, value)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
IFS='/' read -r -a PINPATH <<< "$1"
|
||||
DIR=${PINPATH[0]}
|
||||
NAM=${PINPATH[1]}
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
|
||||
shift
|
||||
while [[ $# > 1 ]]; do
|
||||
PIN=$1 ; VAL=$2
|
||||
FOUT="${DIR}/pins_${NAM}.h"
|
||||
eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*[[:blank:]]*\(#define \+${PIN}\b\).*$/{s//\2 ${VAL}/;h};\${x;/./{x;q0};x;q9}' Marlin/src/pins/${FOUT}" ||
|
||||
(echo "ERROR: pins_set Can't find ${PIN} in ${FOUT}" >&2 && exit 9)
|
||||
shift 2
|
||||
done
|
@@ -7,5 +7,6 @@ if [[ $1 == '-d' || $1 == '--default' ]]; then
|
||||
else
|
||||
git checkout Marlin/Configuration.h 2>/dev/null
|
||||
git checkout Marlin/Configuration_adv.h 2>/dev/null
|
||||
git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
|
||||
git checkout Marlin/config.ini 2>/dev/null
|
||||
git checkout Marlin/src/pins/*/pins_*.h 2>/dev/null
|
||||
fi
|
||||
|
@@ -7,7 +7,7 @@ TMPDIR=`mktemp -d`
|
||||
HERE=`dirname "$0"`
|
||||
|
||||
# Reformat a single file to tmp/
|
||||
if uncrustify -l CPP -c "$HERE/../share/extras/uncrustify.cfg" -f "$1" >$TMPDIR/uncrustify.out ; then
|
||||
if uncrustify -l CPP -c "$HERE/../share/uncrustify/uncrustify.cfg" -f "$1" >$TMPDIR/uncrustify.out ; then
|
||||
cp "$TMPDIR/uncrustify.out" "$1" ; # Replace the original file
|
||||
else
|
||||
echo "Something went wrong with uncrustify."
|
||||
|
Reference in New Issue
Block a user