Преглед изворни кода

🧑‍💻 Keep state for build_all_examples --limit

Scott Lahteine пре 2 година
родитељ
комит
8cf4c0515d
3 измењених фајлова са 34 додато и 29 уклоњено
  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 Прегледај датотеку

@@ -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

+ 2
- 2
buildroot/bin/build_example Прегледај датотеку

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

+ 22
- 0
buildroot/bin/mfutil Прегледај датотеку

@@ -0,0 +1,22 @@
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…
Откажи
Сачувај