features-refresh.sh 2.8 KB

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