Selaa lähdekoodia

Fix mftest -b and -u. Add --help.

Scott Lahteine 4 vuotta sitten
vanhempi
commit
71ec89a112
1 muutettua tiedostoa jossa 29 lisäystä ja 17 poistoa
  1. 29
    17
      buildroot/share/git/mftest

+ 29
- 17
buildroot/share/git/mftest Näytä tiedosto

1
 #!/usr/bin/env bash
1
 #!/usr/bin/env bash
2
 #
2
 #
3
 #  mftest                             Select a test to apply and build
3
 #  mftest                             Select a test to apply and build
4
-#  mftest -b                          Build the auto-detected environment
5
-#  mftest -u                          Upload the auto-detected environment
4
+#  mftest -b [#]                      Build the auto-detected environment
5
+#  mftest -u [#]                      Upload the auto-detected environment
6
 #  mftest [name] [index] [-y]         Set config options and optionally build a test
6
 #  mftest [name] [index] [-y]         Set config options and optionally build a test
7
 #
7
 #
8
 
8
 
38
     m256) TESTENV='megaatmega2560' ;;
38
     m256) TESTENV='megaatmega2560' ;;
39
     mega) TESTENV='megaatmega2560' ;;
39
     mega) TESTENV='megaatmega2560' ;;
40
      stm) TESTENV='STM32F103RE' ;;
40
      stm) TESTENV='STM32F103RE' ;;
41
-     f1)  TESTENV='STM32F103RE' ;;
42
-     f4)  TESTENV='STM32F4' ;;
43
-     f7)  TESTENV='STM32F7' ;;
44
-     s6)  TESTENV='FYSETC_S6' ;;
41
+      f1) TESTENV='STM32F103RE' ;;
42
+      f4) TESTENV='STM32F4' ;;
43
+      f7) TESTENV='STM32F7' ;;
44
+      s6) TESTENV='FYSETC_S6' ;;
45
   teensy) TESTENV='teensy31' ;;
45
   teensy) TESTENV='teensy31' ;;
46
      t31) TESTENV='teensy31' ;;
46
      t31) TESTENV='teensy31' ;;
47
      t32) TESTENV='teensy31' ;;
47
      t32) TESTENV='teensy31' ;;
48
      t35) TESTENV='teensy35' ;;
48
      t35) TESTENV='teensy35' ;;
49
      t36) TESTENV='teensy35' ;;
49
      t36) TESTENV='teensy35' ;;
50
+
51
+-h|--help)  echo -e "$(basename $0) : Marlin Firmware test, build, and upload\n"
52
+            echo "Usage: $(basename $0) ................. Select env and test to apply / run"
53
+            echo "       $(basename $0) [-y] env ........ Select a test for env to apply / run"
54
+            echo "       $(basename $0) [-y] env test ... Apply / run the specified env test"
55
+            echo "       $(basename $0) -b [variant] .... Auto-build the specified variant"
56
+            echo "       $(basename $0) -u [variant] .... Auto-build and upload the specified variant"
57
+            echo
58
+            echo "env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36"
59
+            exit
60
+            ;;
61
+
50
           # Build with the last-built env
62
           # Build with the last-built env
51
       -r) [[ -f "$STATE_FILE" ]] || { echo "No previous (-r) build state found." ; exit 1 ; }
63
       -r) [[ -f "$STATE_FILE" ]] || { echo "No previous (-r) build state found." ; exit 1 ; }
52
           read TESTENV <"$STATE_FILE"
64
           read TESTENV <"$STATE_FILE"
54
           exit
66
           exit
55
           ;;
67
           ;;
56
 
68
 
57
-   -[bu]) MB=$( grep "define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' )
58
-          [[ -z $MB ]] && { echo "Error - Unable to read MOTHERBOARD setting." ; exit 1 ; }
59
-          BLINE=$( grep "define BOARD_$MB" Marlin/src/core/boards.h )
69
+   -[bu]) MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' )
70
+          [[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; }
71
+          BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
60
           BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
72
           BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
61
           BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
73
           BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
62
-          [[ -z $BNUM ]] && { echo "Error - Unable to $MB in boards list." ; exit 1 ; }
63
-          readarray -t ENVS <<< $( grep -A1 "MB($MB)" Marlin/src/pins/pins.h | $SED -n '2 p' | grep -oE 'env:[^ ]+' | $SED -E 's/env://' )
64
-          [[ -z $ENVS ]] && { echo "Error - Unable to find target(s) for $MB ($BNUM)." ; exit 1 ; }
74
+          [[ -z $BNUM ]] && { echo "Error - Can't find $MB in boards list." ; exit 1 ; }
75
+          readarray -t ENVS <<< $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | $SED -n '2 p' | grep -oE 'env:[^ ]+' | $SED -E 's/env://' )
76
+          [[ -z $ENVS ]] && { echo "Error - Can't find target(s) for $MB ($BNUM)." ; exit 1 ; }
65
           ECOUNT=${#ENVS[*]}
77
           ECOUNT=${#ENVS[*]}
66
 
78
 
67
           if [[ $ECOUNT == 1 ]]; then
79
           if [[ $ECOUNT == 1 ]]; then
68
             TARGET=$ENVS
80
             TARGET=$ENVS
69
           else
81
           else
70
-            #
71
-            # List env names and numbers. Get selection.
72
-            #
73
             if [[ $CHOICE == 0 ]]; then
82
             if [[ $CHOICE == 0 ]]; then
83
+              #
84
+              # List env names and numbers. Get selection.
85
+              #
74
               echo "Available targets for \"$BDESC\" | $MB ($BNUM):"
86
               echo "Available targets for \"$BDESC\" | $MB ($BNUM):"
75
 
87
 
76
-              IND=0 ; for ENV in "${ENVS[@]}"; do echo " $IND) $ENV" ; done
88
+              IND=0 ; for ENV in "${ENVS[@]}"; do let IND++ ; echo " $IND) $ENV" ; done
77
 
89
 
78
               if [[ $ECOUNT > 1 ]]; then
90
               if [[ $ECOUNT > 1 ]]; then
79
                 for (( ; ; ))
91
                 for (( ; ; ))
87
               fi
99
               fi
88
             else
100
             else
89
               echo "Detected \"$BDESC\" | $MB ($BNUM)."
101
               echo "Detected \"$BDESC\" | $MB ($BNUM)."
90
-              [[ $CHOICE > $ECOUNT ]] && { echo "Environment selection is out of range." ; exit 1 ; }
102
+              [[ $CHOICE > $ECOUNT ]] && { echo "Environment selection out of range." ; exit 1 ; }
91
             fi
103
             fi
92
             TARGET="${ENVS[$CHOICE-1]}"
104
             TARGET="${ENVS[$CHOICE-1]}"
93
             echo "Selected $TARGET"
105
             echo "Selected $TARGET"

Loading…
Peruuta
Tallenna