|
@@ -14,27 +14,11 @@
|
14
|
14
|
# build_all_examples [...] branch [resume-from]
|
15
|
15
|
#
|
16
|
16
|
|
17
|
|
-set -e
|
|
17
|
+. mfutil
|
18
|
18
|
|
19
|
19
|
GITREPO=https://github.com/MarlinFirmware/Configurations.git
|
20
|
20
|
STAT_FILE=./.pio/.buildall
|
21
|
21
|
|
22
|
|
-# Check dependencies
|
23
|
|
-which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
|
24
|
|
-which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
|
25
|
|
-
|
26
|
|
-SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
|
27
|
|
-[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
|
28
|
|
-
|
29
|
|
-SELF=`basename "$0"`
|
30
|
|
-HERE=`dirname "$0"`
|
31
|
|
-
|
32
|
|
-# Check if called in the right location
|
33
|
|
-[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
|
34
|
|
-
|
35
|
|
-perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
|
36
|
|
-bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; }
|
37
|
|
-
|
38
|
22
|
usage() { echo "
|
39
|
23
|
Usage: $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-r|--resume=<path>]
|
40
|
24
|
$SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-c|--continue]
|
|
@@ -58,7 +42,7 @@ while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
58
|
42
|
s) CONTSKIP=1 ; bugout "Continue, skipping" ;;
|
59
|
43
|
i) CREATE_INI=1 ; bugout "Generate an INI file" ;;
|
60
|
44
|
h) EXIT_USAGE=1 ; break ;;
|
61
|
|
- l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT configs" ;;
|
|
45
|
+ l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;;
|
62
|
46
|
d|v) DEBUG=1 ; bugout "Debug ON" ;;
|
63
|
47
|
n) DRYRUN=1 ; bugout "Dry Run" ;;
|
64
|
48
|
-) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
|
|
@@ -67,7 +51,7 @@ while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
67
|
51
|
resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;;
|
68
|
52
|
continue) CONTINUE=1 ; bugout "Continue" ;;
|
69
|
53
|
skip) CONTSKIP=2 ; bugout "Continue, skipping" ;;
|
70
|
|
- limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT configs" ;;
|
|
54
|
+ limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;;
|
71
|
55
|
ini) CREATE_INI=1 ; bugout "Generate an INI file" ;;
|
72
|
56
|
help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
|
73
|
57
|
debug) DEBUG=1 ; bugout "Debug ON" ;;
|
|
@@ -125,18 +109,17 @@ TMP=./.pio/build-$BRANCH
|
125
|
109
|
|
126
|
110
|
# Download Configurations into the temporary folder
|
127
|
111
|
if [[ ! -e "$TMP/README.md" ]]; then
|
128
|
|
- echo "Downloading Configurations from GitHub into $TMP"
|
|
112
|
+ echo "Fetching Configurations from GitHub to $TMP"
|
129
|
113
|
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
|
130
|
114
|
else
|
131
|
|
- echo "Using previously downloaded Configurations at $TMP"
|
|
115
|
+ echo "Using cached Configurations at $TMP"
|
132
|
116
|
fi
|
133
|
117
|
|
134
|
|
-echo -e "Start building now...\n====================="
|
|
118
|
+echo -e "Start build...\n====================="
|
135
|
119
|
shopt -s nullglob
|
136
|
120
|
IFS='
|
137
|
121
|
'
|
138
|
122
|
CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
|
139
|
|
-DOSKIP=0
|
140
|
123
|
for CONF in $CONF_TREE ; do
|
141
|
124
|
|
142
|
125
|
# Get a config's directory name
|
|
@@ -168,19 +151,19 @@ for CONF in $CONF_TREE ; do
|
168
|
151
|
[[ $CREATE_INI ]] && find ./.pio/build/ -name "config.ini" -exec cp "{}" "$CONF" \;
|
169
|
152
|
fi
|
170
|
153
|
|
171
|
|
- ((LIMIT--)) || { echo "Limit reached" ; break ; }
|
|
154
|
+ ((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
|
172
|
155
|
|
173
|
156
|
done
|
174
|
157
|
|
175
|
|
-# Delete the build state
|
176
|
|
-rm "$STAT_FILE"
|
|
158
|
+# Delete the build state if not paused early
|
|
159
|
+[[ $PAUSE ]] || rm "$STAT_FILE"
|
177
|
160
|
|
178
|
161
|
# Delete the temp folder if not preserving generated INI files
|
179
|
162
|
if [[ -e "$TMP/config/examples" ]]; then
|
180
|
163
|
if [[ $CREATE_INI ]]; then
|
181
|
164
|
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
182
|
165
|
$OPEN "$TMP"
|
183
|
|
- else
|
|
166
|
+ elif [[ ! $PAUSE ]]; then
|
184
|
167
|
rm -rf "$TMP"
|
185
|
168
|
fi
|
186
|
169
|
fi
|