From 3591eb5d5da00d6a0ba55cad9f910782fda91df4 Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Sat, 30 Nov 2024 22:22:52 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Improve=20build=20script=20compa?= =?UTF-8?q?tibility=20(#27549)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/bin/build_all_examples | 50 ++++++++++---------- buildroot/bin/build_example | 7 +-- buildroot/bin/mftest | 21 ++++---- buildroot/share/PlatformIO/scripts/schema.py | 6 +-- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/buildroot/bin/build_all_examples b/buildroot/bin/build_all_examples index 0c4a0ee394..c2b0007b0c 100755 --- a/buildroot/bin/build_all_examples +++ b/buildroot/bin/build_all_examples @@ -2,21 +2,21 @@ # # Usage: # -# build_all_examples [-b|--branch=] - Branch to fetch from Configurations repo (import-2.1.x) +# build_all_examples [-a|--archive] - Copy the binary to the export location # [-B|--base] - Base path of configurations, overriding -b +# [-b|--branch=] - Branch to fetch from Configurations repo (import-2.1.x) # [-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=] - Start at some config in the filesystem order +# [-d|-v|--debug] - Print extra debug output (after) +# [-e|--export=N] - Set CONFIG_EXPORT and export to the export location +# [-f|--nofail] - Don't stop on a failed build +# [-h|--help] - Print usage and exit # [-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 +# [-p|--purge] - Purge the status file and start over +# [-r|--resume=] - Start at some config in the filesystem order +# [-s|--skip] - Continue the paused build, skipping one # HERE=`dirname $0` @@ -29,21 +29,21 @@ STAT_FILE=./.pio/.buildall usage() { echo "Usage: -build_all_examples [-b|--branch=] - Branch to fetch from Configurations repo (import-2.1.x) +build_all_examples [-a|--archive] - Copy the binary to the export location [-B|--base] - Base path of configurations, overriding -b + [-b|--branch=] - Branch to fetch from Configurations repo (import-2.1.x) [-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=] - Start at some config in the filesystem order + [-d|-v|--debug] - Print extra debug output (after) [-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 + [-l|--limit=#] - Limit the number of builds in this run + [-n|--nobuild] - Don't actually build anything + [-o|--output] - Redirect export / archiving to another location + (By default export to origin config folders) + [-p|--purge] - Purge the status file and start over + [-r|--resume=] - Start at some config in the filesystem order + [-s|--skip] - Continue the paused build, skipping one " } @@ -53,22 +53,22 @@ unset FIRST_CONF EXIT_USAGE= LIMIT=1000 -while getopts 'aB:b:ce:fdhl:no:pr:sv-:' OFLAG; do +while getopts 'aB:b:cde:fhl:no:pr:sv-:' OFLAG; do case "${OFLAG}" in 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" ;; + d|v) DEBUG=1 ; bugout "Debug ON" ;; e) CEXPORT=$OPTARG ; bugout "Export $CEXPORT" ;; - o) OUTBASE="${OPTARG%/}" ; bugout "Archive to $OUTBASE" ;; + f) NOFAIL=1 ; bugout "Continue on Fail" ;; 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" ;; + o) OUTBASE="${OPTARG%/}" ; bugout "Archive to $OUTBASE" ;; p) PURGE=1 ; bugout "Purge stat file" ;; + r) ISRES=1 ; FIRST_CONF=$OPTARG ; bugout "Resume: $FIRST_CONF" ;; + s) CONTSKIP=1 ; bugout "Continue, skipping" ;; -) ONAM="${OPTARG%%=*}" ; OVAL="${OPTARG#*=}" case "$ONAM" in archive) ARCHIVE=1 ; bugout "Archiving" ;; diff --git a/buildroot/bin/build_example b/buildroot/bin/build_example index 5de2229868..566919abd6 100755 --- a/buildroot/bin/build_example +++ b/buildroot/bin/build_example @@ -53,16 +53,17 @@ EXPNUM= NOFAIL= OUTBASE= BUILDINDEX=1 -while getopts 'ab:c:e:fhin:o:r-:' OFLAG; do + +while getopts 'ab:c:e:fhn:o:r-:' OFLAG; do case "${OFLAG}" in a) ARCHIVE=1 ;; b) BASE="${OPTARG%/}" ;; c) CONFIG="${OPTARG%/}" ;; e) EXPNUM="$OPTARG" ;; + f) NOFAIL=1 ;; + h) EXIT_USAGE=1 ; break ;; n) BUILDINDEX="$OPTARG" ;; o) OUTBASE="${OPTARG%/}" ;; - h) EXIT_USAGE=1 ; break ;; - f) NOFAIL=1 ;; r) REVEAL=1 ;; -) ONAM="${OPTARG%%=*}" ; OVAL="${OPTARG#*=}" case "$ONAM" in diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index b6f78e4f42..57aa95400c 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -16,23 +16,24 @@ bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; } usage() { echo " -Usage: mftest [-t|--env=] [-n|--num=] [-m|--make] [-y|--build=] - mftest [-a|--autobuild] +Usage: mftest [-a|--autobuild] mftest [-r|--rebuild] mftest [-s|--silent] + mftest [-t|--env=] [-n|--num=] [-m|--make] [-y|--build=] mftest [-u|--autoupload] [-n|--num=] OPTIONS - -t --env The environment to apply / run, or the menu index number. - -n --num The index of the test to run. (In file order.) - -m --make Use the make / Docker method for the build. - -y --build Skip 'Do you want to build this test?' and assume YES. - -h --help Print this help. -a --autobuild PIO Build using the MOTHERBOARD environment. + -d --default Restore to defaults before applying configs. + -h --help Print this help. + -m --make Use the make / Docker method for the build. + -n --num The index of the test to run. (In file order.) + -r --rebuild Rebuild previous PIO Build. + -s --silent Silence build output from PlatformIO. + -t --env The environment to apply / run, or the menu index number. -u --autoupload PIO Upload using the MOTHERBOARD environment. -v --verbose Extra output for debugging. - -s --silent Silence build output from PlatformIO. - -d --default Restore to defaults before applying configs. + -y --build Skip 'Do you want to build this test?' and assume YES. env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 " @@ -56,7 +57,7 @@ TESTENV='-' CHOICE=0 DEBUG=0 -while getopts 'abdhmrsuvyn:t:-:' OFLAG; do +while getopts 'adhmn:rst:uvy-:' OFLAG; do case "${OFLAG}" in a) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;; d) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;; diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 29c6bf4310..d5179d43b5 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -126,7 +126,7 @@ class Parse: sid = 0 # Loop through files and parse them line by line for fn, fk in filekey.items(): - with Path("Marlin", fn).open() as fileobj: + with Path("Marlin", fn).open(encoding='utf-8') as fileobj: section = 'none' # Current Settings section line_number = 0 # Counter for the line number of the file conditions = [] # Create a condition stack for the current file @@ -428,12 +428,12 @@ def extract(): return extract_files({ 'Configuration.h':'basic', 'Configuration_adv.h':'advanced' }) def dump_json(schema:dict, jpath:Path): - with jpath.open('w') as jfile: + with jpath.open('w', encoding='utf-8') as jfile: json.dump(schema, jfile, ensure_ascii=False, indent=2) def dump_yaml(schema:dict, ypath:Path): import yaml - with ypath.open('w') as yfile: + with ypath.open('w', encoding='utf-8') as yfile: yaml.dump(schema, yfile, default_flow_style=False, width=120, indent=2) def main():