2
2
#
3
3
# build_all_examples base_branch [resume_point]
4
4
#
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
5
18
6
19
GITREPO=https://github.com/MarlinFirmware/Configurations.git
7
20
STAT_FILE=./.pio/.buildall
@@ -13,8 +26,34 @@ which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ;
13
26
SED=$( command -v gsed 2> /dev/null || command -v sed 2> /dev/null)
14
27
[[ -z " $SED " ]] && { echo " No sed found, please install sed" ; exit 1 ; }
15
28
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
18
57
19
58
# Check if called in the right location
20
59
[[ -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
92
131
[[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; }
93
132
# ...if skipping, don't build this one
94
133
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
+
97
154
done
98
155
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
0 commit comments