Skip to content

Commit c801cc4

Browse files
committed
🔨 Update build/CI scripts
1 parent bc91b1c commit c801cc4

File tree

3 files changed

+82
-9
lines changed

3 files changed

+82
-9
lines changed

buildroot/bin/build_all_examples

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
#
33
# build_all_examples base_branch [resume_point]
44
#
5+
# build_all_examples [-b|--branch=<branch>] - Branch to fetch from Configurations repo
6+
# [-c|--continue] - Continue the paused build
7+
# [-d|--debug] - Print extra debug output
8+
# [-i|--ini] - Archive ini/json/yml files in the temp config folder
9+
# [-l|--limit=#] - Limit the number of builds in this run
10+
# [-n|--nobuild] - Don't actually build anything.
11+
# [-r|--resume=<path>] - Start at some config in the filesystem order
12+
# [-s|--skip] - Do the thing
13+
#
14+
# build_all_examples [...] branch [resume-from]
15+
#
16+
17+
. mfutil
518

619
GITREPO=https://github.com/MarlinFirmware/Configurations.git
720
STAT_FILE=./.pio/.buildall
@@ -13,8 +26,34 @@ which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ;
1326
SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
1427
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
1528

16-
SELF=`basename "$0"`
17-
HERE=`dirname "$0"`
29+
while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
30+
case "${OFLAG}" in
31+
b) BRANCH=$OPTARG ; bugout "Branch: $BRANCH" ;;
32+
r) FIRST_CONF="$OPTARG" ; bugout "Resume: $FIRST_CONF" ;;
33+
c) CONTINUE=1 ; bugout "Continue" ;;
34+
s) CONTSKIP=1 ; bugout "Continue, skipping" ;;
35+
i) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
36+
h) EXIT_USAGE=1 ; break ;;
37+
l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;;
38+
d|v) DEBUG=1 ; bugout "Debug ON" ;;
39+
n) DRYRUN=1 ; bugout "Dry Run" ;;
40+
-) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
41+
case "$ONAM" in
42+
branch) BRANCH=$OVAL ; bugout "Branch: $BRANCH" ;;
43+
resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;;
44+
continue) CONTINUE=1 ; bugout "Continue" ;;
45+
skip) CONTSKIP=2 ; bugout "Continue, skipping" ;;
46+
limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;;
47+
ini) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
48+
help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
49+
debug) DEBUG=1 ; bugout "Debug ON" ;;
50+
nobuild) DRYRUN=1 ; bugout "Dry Run" ;;
51+
*) EXIT_USAGE=2 ; echo "$SELF: unrecognized option \`--$ONAM'" ; break ;;
52+
esac
53+
;;
54+
*) EXIT_USAGE=2 ; break ;;
55+
esac
56+
done
1857

1958
# Check if called in the right location
2059
[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
@@ -92,10 +131,37 @@ for CONF in $CONF_TREE ; do
92131
[[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; }
93132
# ...if skipping, don't build this one
94133
compgen -G "${CONF}Con*.h" > /dev/null || continue
95-
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
96-
"$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
134+
135+
# Build or print build command for --nobuild
136+
if [[ $DRYRUN ]]; then
137+
echo -e "\033[0;32m[DRYRUN] build_example internal \"$TMP\" \"$DIR\"\033[0m"
138+
else
139+
# Remember where we are in case of failure
140+
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
141+
# Build folder is unknown so delete all report files
142+
if [[ $COPY_INI ]]; then
143+
IFIND='find ./.pio/build/ -name "config.ini" -o -name "schema.json" -o -name "schema.yml"'
144+
$IFIND -exec rm "{}" \;
145+
fi
146+
((DEBUG)) && echo "\"$HERE/build_example\" internal \"$TMP\" \"$DIR\""
147+
"$HERE/build_example" internal "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
148+
# Build folder is unknown so copy all report files
149+
[[ $COPY_INI ]] && $IFIND -exec cp "{}" "$CONF" \;
150+
fi
151+
152+
((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
153+
97154
done
98155

99-
# Delete the temp folder and build state
100-
[[ -e "$TMP/config/examples" ]] && rm -rf "$TMP"
101-
rm "$STAT_FILE"
156+
# Delete the build state if not paused early
157+
[[ $PAUSE ]] || rm "$STAT_FILE"
158+
159+
# Delete the temp folder if not preserving generated INI files
160+
if [[ -e "$TMP/config/examples" ]]; then
161+
if [[ $COPY_INI ]]; then
162+
OPEN=$( which gnome-open xdg-open open | head -n1 )
163+
$OPEN "$TMP"
164+
elif [[ ! $PAUSE ]]; then
165+
rm -rf "$TMP"
166+
fi
167+
fi

buildroot/bin/restore_configs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env bash
22

3-
git checkout Marlin/Configuration*.h 2>/dev/null
4-
git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
53
rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h marlin_config.json .pio/build/mc.zip
4+
5+
if [[ $1 == '-d' || $1 == '--default' ]]; then
6+
use_example_configs
7+
else
8+
git checkout Marlin/Configuration.h 2>/dev/null
9+
git checkout Marlin/Configuration_adv.h 2>/dev/null
10+
git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
11+
fi

buildroot/bin/use_example_configs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# use_example_configs [repo:]configpath
44
#
55
# Examples:
6+
# use_example_configs
67
# use_example_configs Creality/CR-10/CrealityV1
78
# use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1
89
#

0 commit comments

Comments
 (0)