Browse Source

🧑‍💻 Keep state for build_all_examples --limit

Scott Lahteine 2 years ago
parent
commit
8cf4c0515d
3 changed files with 34 additions and 29 deletions
  1. 10
    27
      buildroot/bin/build_all_examples
  2. 2
    2
      buildroot/bin/build_example
  3. 22
    0
      buildroot/bin/mfutil

+ 10
- 27
buildroot/bin/build_all_examples View File

14
 # build_all_examples [...] branch [resume-from]
14
 # build_all_examples [...] branch [resume-from]
15
 #
15
 #
16
 
16
 
17
-set -e
17
+. mfutil
18
 
18
 
19
 GITREPO=https://github.com/MarlinFirmware/Configurations.git
19
 GITREPO=https://github.com/MarlinFirmware/Configurations.git
20
 STAT_FILE=./.pio/.buildall
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
 usage() { echo "
22
 usage() { echo "
39
 Usage: $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-r|--resume=<path>]
23
 Usage: $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-r|--resume=<path>]
40
        $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-c|--continue]
24
        $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-c|--continue]
58
     s) CONTSKIP=1           ; bugout "Continue, skipping" ;;
42
     s) CONTSKIP=1           ; bugout "Continue, skipping" ;;
59
     i) CREATE_INI=1         ; bugout "Generate an INI file" ;;
43
     i) CREATE_INI=1         ; bugout "Generate an INI file" ;;
60
     h) EXIT_USAGE=1 ; break ;;
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
   d|v) DEBUG=1              ; bugout "Debug ON" ;;
46
   d|v) DEBUG=1              ; bugout "Debug ON" ;;
63
     n) DRYRUN=1             ; bugout "Dry Run" ;;
47
     n) DRYRUN=1             ; bugout "Dry Run" ;;
64
     -) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
48
     -) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
67
        resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;;
51
        resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;;
68
      continue) CONTINUE=1   ; bugout "Continue" ;;
52
      continue) CONTINUE=1   ; bugout "Continue" ;;
69
          skip) CONTSKIP=2   ; bugout "Continue, skipping" ;;
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
           ini) CREATE_INI=1 ; bugout "Generate an INI file" ;;
55
           ini) CREATE_INI=1 ; bugout "Generate an INI file" ;;
72
          help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
56
          help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
73
         debug) DEBUG=1      ; bugout "Debug ON" ;;
57
         debug) DEBUG=1      ; bugout "Debug ON" ;;
125
 
109
 
126
 # Download Configurations into the temporary folder
110
 # Download Configurations into the temporary folder
127
 if [[ ! -e "$TMP/README.md" ]]; then
111
 if [[ ! -e "$TMP/README.md" ]]; then
128
-  echo "Downloading Configurations from GitHub into $TMP"
112
+  echo "Fetching Configurations from GitHub to $TMP"
129
   git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
113
   git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
130
 else
114
 else
131
-  echo "Using previously downloaded Configurations at $TMP"
115
+  echo "Using cached Configurations at $TMP"
132
 fi
116
 fi
133
 
117
 
134
-echo -e "Start building now...\n====================="
118
+echo -e "Start build...\n====================="
135
 shopt -s nullglob
119
 shopt -s nullglob
136
 IFS='
120
 IFS='
137
 '
121
 '
138
 CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
122
 CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
139
-DOSKIP=0
140
 for CONF in $CONF_TREE ; do
123
 for CONF in $CONF_TREE ; do
141
 
124
 
142
   # Get a config's directory name
125
   # Get a config's directory name
168
     [[ $CREATE_INI ]] && find ./.pio/build/ -name "config.ini" -exec cp "{}" "$CONF" \;
151
     [[ $CREATE_INI ]] && find ./.pio/build/ -name "config.ini" -exec cp "{}" "$CONF" \;
169
   fi
152
   fi
170
 
153
 
171
-  ((LIMIT--)) || { echo "Limit reached" ; break ; }
154
+  ((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
172
 
155
 
173
 done
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
 # Delete the temp folder if not preserving generated INI files
161
 # Delete the temp folder if not preserving generated INI files
179
 if [[ -e "$TMP/config/examples" ]]; then
162
 if [[ -e "$TMP/config/examples" ]]; then
180
   if [[ $CREATE_INI ]]; then
163
   if [[ $CREATE_INI ]]; then
181
     OPEN=$( which gnome-open xdg-open open | head -n1 )
164
     OPEN=$( which gnome-open xdg-open open | head -n1 )
182
     $OPEN "$TMP"
165
     $OPEN "$TMP"
183
-  else
166
+  elif [[ ! $PAUSE ]]; then
184
     rm -rf "$TMP"
167
     rm -rf "$TMP"
185
   fi
168
   fi
186
 fi
169
 fi

+ 2
- 2
buildroot/bin/build_example View File

5
 # Usage: build_example internal config-home config-folder
5
 # Usage: build_example internal config-home config-folder
6
 #
6
 #
7
 
7
 
8
+. mfutil
9
+
8
 # Require 'internal' as the first argument
10
 # Require 'internal' as the first argument
9
 [[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
11
 [[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
10
 
12
 
25
 set -e
27
 set -e
26
 
28
 
27
 # Strip #error lines from Configuration.h
29
 # Strip #error lines from Configuration.h
28
-SED=$(which gsed sed | head -n1)
29
 IFS=$'\n'; set -f
30
 IFS=$'\n'; set -f
30
 $SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h
31
 $SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h
31
 rm Marlin/Configuration.h~
32
 rm Marlin/Configuration.h~
32
 unset IFS; set +f
33
 unset IFS; set +f
33
 
34
 
34
 echo "Building the firmware now..."
35
 echo "Building the firmware now..."
35
-HERE=`dirname "$0"`
36
 $HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; }
36
 $HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; }
37
 
37
 
38
 echo "Success"
38
 echo "Success"

+ 22
- 0
buildroot/bin/mfutil View File

1
+#!/usr/bin/env bash
2
+#
3
+# mfutil - check env and define helpers
4
+#
5
+
6
+# Check dependencies
7
+which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
8
+which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
9
+
10
+SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
11
+[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
12
+
13
+OPEN=$( which gnome-open xdg-open open | head -n1 )
14
+
15
+SELF=`basename "$0"`
16
+HERE=`dirname "$0"`
17
+
18
+# Check if called in the right location
19
+[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
20
+
21
+perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
22
+bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; }

Loading…
Cancel
Save