diff options
author | Andrea Parri <andrea.parri@amarulasolutions.com> | 2018-05-07 06:43:38 -0400 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2018-05-08 11:27:12 -0400 |
commit | be99f610a11002e877cee2418466d8505b813937 (patch) | |
tree | 24cf3b757120a64c9aaa6ca1fb8b009470f6a296 /Documentation/features | |
parent | f6dbf65b6558e9587570cb5b8345b967175285b5 (diff) |
Documentation/features: Add script that refreshes the arch support status files in place
Provides the script:
Documentation/features/scripts/features-refresh.sh
which operates on the arch-support.txt files and refreshes them in place.
This way [1],
"[...] we soft- decouple the refreshing of the entries from the
introduction of the features, while still making it all easy to
keep sync and to extend."
[1] http://lkml.kernel.org/r/20180328122211.GA25420@andrea
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation/features')
-rwxr-xr-x | Documentation/features/scripts/features-refresh.sh | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/Documentation/features/scripts/features-refresh.sh b/Documentation/features/scripts/features-refresh.sh new file mode 100755 index 000000000000..9e72d38a0720 --- /dev/null +++ b/Documentation/features/scripts/features-refresh.sh | |||
@@ -0,0 +1,98 @@ | |||
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 | ||