Andrea Parri | be99f61 | 2018-05-07 12:43:38 +0200 | [diff] [blame] | 1 | # |
| 2 | # Small script that refreshes the kernel feature support status in place. |
| 3 | # |
| 4 | |
| 5 | for F_FILE in Documentation/features/*/*/arch-support.txt; do |
| 6 | F=$(grep "^# Kconfig:" "$F_FILE" | cut -c26-) |
| 7 | |
| 8 | # |
| 9 | # Each feature F is identified by a pair (O, K), where 'O' can |
| 10 | # be either the empty string (for 'nop') or "not" (the logical |
| 11 | # negation operator '!'); other operators are not supported. |
| 12 | # |
| 13 | O="" |
| 14 | K=$F |
| 15 | if [[ "$F" == !* ]]; then |
| 16 | O="not" |
| 17 | K=$(echo $F | sed -e 's/^!//g') |
| 18 | fi |
| 19 | |
| 20 | # |
| 21 | # F := (O, K) is 'valid' iff there is a Kconfig file (for some |
| 22 | # arch) which contains K. |
| 23 | # |
| 24 | # Notice that this definition entails an 'asymmetry' between |
| 25 | # the case 'O = ""' and the case 'O = "not"'. E.g., F may be |
| 26 | # _invalid_ if: |
| 27 | # |
| 28 | # [case 'O = ""'] |
| 29 | # 1) no arch provides support for F, |
| 30 | # 2) K does not exist (e.g., it was renamed/mis-typed); |
| 31 | # |
| 32 | # [case 'O = "not"'] |
| 33 | # 3) all archs provide support for F, |
| 34 | # 4) as in (2). |
| 35 | # |
| 36 | # The rationale for adopting this definition (and, thus, for |
| 37 | # keeping the asymmetry) is: |
| 38 | # |
| 39 | # We want to be able to 'detect' (2) (or (4)). |
| 40 | # |
| 41 | # (1) and (3) may further warn the developers about the fact |
| 42 | # that K can be removed. |
| 43 | # |
| 44 | F_VALID="false" |
| 45 | for ARCH_DIR in arch/*/; do |
| 46 | K_FILES=$(find $ARCH_DIR -name "Kconfig*") |
| 47 | K_GREP=$(grep "$K" $K_FILES) |
| 48 | if [ ! -z "$K_GREP" ]; then |
| 49 | F_VALID="true" |
| 50 | break |
| 51 | fi |
| 52 | done |
| 53 | if [ "$F_VALID" = "false" ]; then |
| 54 | printf "WARNING: '%s' is not a valid Kconfig\n" "$F" |
| 55 | fi |
| 56 | |
| 57 | T_FILE="$F_FILE.tmp" |
| 58 | grep "^#" $F_FILE > $T_FILE |
| 59 | echo " -----------------------" >> $T_FILE |
| 60 | echo " | arch |status|" >> $T_FILE |
| 61 | echo " -----------------------" >> $T_FILE |
| 62 | for ARCH_DIR in arch/*/; do |
| 63 | ARCH=$(echo $ARCH_DIR | sed -e 's/arch//g' | sed -e 's/\///g') |
| 64 | K_FILES=$(find $ARCH_DIR -name "Kconfig*") |
| 65 | K_GREP=$(grep "$K" $K_FILES) |
| 66 | # |
| 67 | # Arch support status values for (O, K) are updated according |
| 68 | # to the following rules. |
| 69 | # |
| 70 | # - ("", K) is 'supported by a given arch', if there is a |
| 71 | # Kconfig file for that arch which contains K; |
| 72 | # |
| 73 | # - ("not", K) is 'supported by a given arch', if there is |
| 74 | # no Kconfig file for that arch which contains K; |
| 75 | # |
| 76 | # - otherwise: preserve the previous status value (if any), |
| 77 | # default to 'not yet supported'. |
| 78 | # |
| 79 | # Notice that, according these rules, invalid features may be |
| 80 | # updated/modified. |
| 81 | # |
| 82 | if [ "$O" = "" ] && [ ! -z "$K_GREP" ]; then |
| 83 | printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE |
| 84 | elif [ "$O" = "not" ] && [ -z "$K_GREP" ]; then |
| 85 | printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE |
| 86 | else |
| 87 | S=$(grep -v "^#" "$F_FILE" | grep " $ARCH:") |
| 88 | if [ ! -z "$S" ]; then |
| 89 | echo "$S" >> $T_FILE |
| 90 | else |
| 91 | printf " |%12s: | TODO |\n" "$ARCH" \ |
| 92 | >> $T_FILE |
| 93 | fi |
| 94 | fi |
| 95 | done |
| 96 | echo " -----------------------" >> $T_FILE |
| 97 | mv $T_FILE $F_FILE |
| 98 | done |