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

+ 20
- 13
buildroot/bin/use_example_configs View File

9
 # If a configpath has spaces (or quotes) escape them or enquote the path
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
 CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
15
 CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
13
 [[ $CURR == "bugfix-2.0.x" ]] && BRANCH=bugfix-2.0.x || BRANCH=bugfix-2.1.x
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
 restore_configs
33
 restore_configs
24
 
34
 
25
 cd Marlin
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
 rm -f wgot
42
 rm -f wgot
36
 cd - >/dev/null
43
 cd - >/dev/null

Loading…
Cancel
Save