Browse Source

🔨 Add mftest --default flag

Scott Lahteine 3 years ago
parent
commit
fa0ad4b594
2 changed files with 31 additions and 14 deletions
  1. 11
    1
      buildroot/bin/mftest
  2. 20
    13
      buildroot/bin/use_example_configs

+ 11
- 1
buildroot/bin/mftest View File

@@ -30,6 +30,7 @@ OPTIONS
30 30
   -u --autoupload  PIO Upload using the MOTHERBOARD environment.
31 31
   -v --verbose     Extra output for debugging.
32 32
   -s --silent      Silence build output from PlatformIO.
33
+  -d --default     Restore to defaults before applying configs.
33 34
 
34 35
 env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41
35 36
 "
@@ -44,6 +45,7 @@ shopt -s extglob nocasematch
44 45
 
45 46
 # Matching patterns
46 47
 ISNUM='^[0-9]+$'
48
+ISRST='^(restore)_'
47 49
 ISCMD='^(restore|opt|exec|use|pins|env)_'
48 50
 ISEXEC='^exec_'
49 51
 ISCONT='\\ *$'
@@ -53,9 +55,10 @@ TESTENV='-'
53 55
 CHOICE=0
54 56
 DEBUG=0
55 57
 
56
-while getopts 'abhmrsuvyn:t:-:' OFLAG; do
58
+while getopts 'abdhmrsuvyn:t:-:' OFLAG; do
57 59
   case "${OFLAG}" in
58 60
     a) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;;
61
+    d) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;;
59 62
     h) EXIT_USAGE=1 ;;
60 63
     m) USE_MAKE=1 ; bugout "Using make with Docker..." ;;
61 64
     n) case "$OPTARG" in
@@ -88,6 +91,7 @@ while getopts 'abhmrsuvyn:t:-:' OFLAG; do
88 91
        silent) SILENT_FLAG="-s" ;;
89 92
          make) USE_MAKE=1 ; bugout "Using make with Docker..." ;;
90 93
 debug|verbose) DEBUG=1    ; bugout "Debug ON" ;;
94
+      default) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;;
91 95
         build) case "$OVAL" in
92 96
                  ''|y|yes) BUILD_YES='Y' ;;
93 97
                      n|no) BUILD_YES='N' ;;
@@ -283,6 +287,11 @@ if [[ $CHOICE == 0 ]]; then
283 287
 fi
284 288
 
285 289
 #
290
+# Restore to defaults if requested
291
+#
292
+((DL_DEFAULTS)) && use_example_configs
293
+
294
+#
286 295
 # Run the specified test lines
287 296
 #
288 297
 echo -ne "\033[0;33m"
@@ -303,6 +312,7 @@ echo "$OUT" | {
303 312
         }
304 313
         ((IND == CHOICE)) && {
305 314
           GOTX=1
315
+          [[ -n $DL_DEFAULTS && $LINE =~ $ISRST ]] && LINE="use_example_configs"
306 316
           [[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | $SED -e 's/\\//g' | $SED -E 's/ +/ /g' )
307 317
           [[ $LINE =~ $ISCONT ]] || { echo "$CMD" ; eval "$CMD" ; CMD="" ; }
308 318
         }

+ 20
- 13
buildroot/bin/use_example_configs View File

@@ -9,28 +9,35 @@
9 9
 # If a configpath has spaces (or quotes) escape them or enquote the path
10 10
 #
11 11
 
12
+which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot'
13
+which wget >/dev/null && TOOL='wget -q -O wgot'
14
+
12 15
 CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
13 16
 [[ $CURR == "bugfix-2.0.x" ]] && BRANCH=bugfix-2.0.x || BRANCH=bugfix-2.1.x
14 17
 
15
-IFS=: read -r PART1 PART2 <<< "$@"
16
-[[ -n $PART2 ]] && { REPO="$PART1" ; UDIR="$PART2" ; } \
17
-                || { REPO=$BRANCH  ; UDIR="$PART1" ; }
18
-EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples"
18
+REPO=$BRANCH
19 19
 
20
-which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot'
21
-which wget >/dev/null && TOOL='wget -q -O wgot'
20
+if [[ $# > 0 ]]; then
21
+  IFS=: read -r PART1 PART2 <<< "$@"
22
+  [[ -n $PART2 ]] && { UDIR="$PART2" ; REPO="$PART1" ; } \
23
+                  || { UDIR="$PART1" ; }
24
+  RDIR="${UDIR// /%20}"
25
+  echo "Fetching $UDIR configurations from $REPO..."
26
+  EXAMPLES="examples/$RDIR"
27
+else
28
+  EXAMPLES="default"
29
+fi
30
+
31
+CONFIGS="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/${EXAMPLES}"
22 32
 
23 33
 restore_configs
24 34
 
25 35
 cd Marlin
26 36
 
27
-RDIR="${UDIR// /%20}"
28
-echo "Fetching $UDIR configurations from $REPO..."
29
-
30
-$TOOL "$EXAMPLES/$RDIR/Configuration.h"     >/dev/null 2>&1 && mv wgot Configuration.h
31
-$TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
32
-$TOOL "$EXAMPLES/$RDIR/_Bootscreen.h"       >/dev/null 2>&1 && mv wgot _Bootscreen.h
33
-$TOOL "$EXAMPLES/$RDIR/_Statusscreen.h"     >/dev/null 2>&1 && mv wgot _Statusscreen.h
37
+$TOOL "$CONFIGS/Configuration.h"     >/dev/null 2>&1 && mv wgot Configuration.h
38
+$TOOL "$CONFIGS/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
39
+$TOOL "$CONFIGS/_Bootscreen.h"       >/dev/null 2>&1 && mv wgot _Bootscreen.h
40
+$TOOL "$CONFIGS/_Statusscreen.h"     >/dev/null 2>&1 && mv wgot _Statusscreen.h
34 41
 
35 42
 rm -f wgot
36 43
 cd - >/dev/null

Loading…
Cancel
Save