diff options
author | Petr Vorel <petr.vorel@gmail.com> | 2018-01-25 04:46:35 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-25 07:53:00 -0500 |
commit | 1ccb27143360bd2390a9a970e50709f858b53761 (patch) | |
tree | cf5e766bdaca1c1976ad004a87e0d163f19b15da /scripts/kconfig/expr.c | |
parent | 312ee68752faaa553499775d2c191ff7a883826f (diff) |
kconfig: make "Selected by:" and "Implied by:" readable
Reverse dependency expressions can get rather unwieldy, especially if
a symbol is selected by more than a handful of other symbols. I.e. it's
possible to have near endless expressions like:
A && B && !C || D || F && (G || H) || [...]
Chop these expressions into actually readable chunks:
- A && B && !C
- D
- F && (G || H)
- [...]
I.e. transform the top level OR tokens into newlines and prepend each
line with a minus. This makes the "Selected by:" and "Implied by:" blurb
much easier to read. This is done only if there is more than one top
level OR. "Depends on:" and "Range :" were deliberately left as they are.
Based on idea from Paul Bolle.
Suggested-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig/expr.c')
-rw-r--r-- | scripts/kconfig/expr.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index fd8a416ceab7..04fa71e058b7 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
@@ -1176,7 +1176,7 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) | |||
1176 | return expr_get_leftmost_symbol(ret); | 1176 | return expr_get_leftmost_symbol(ret); |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) | 1179 | static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep) |
1180 | { | 1180 | { |
1181 | if (!e) { | 1181 | if (!e) { |
1182 | fn(data, NULL, "y"); | 1182 | fn(data, NULL, "y"); |
@@ -1231,9 +1231,14 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * | |||
1231 | fn(data, e->right.sym, e->right.sym->name); | 1231 | fn(data, e->right.sym, e->right.sym->name); |
1232 | break; | 1232 | break; |
1233 | case E_OR: | 1233 | case E_OR: |
1234 | expr_print(e->left.expr, fn, data, E_OR); | 1234 | if (revdep && e->left.expr->type != E_OR) |
1235 | fn(data, NULL, " || "); | 1235 | fn(data, NULL, "\n - "); |
1236 | expr_print(e->right.expr, fn, data, E_OR); | 1236 | __expr_print(e->left.expr, fn, data, E_OR, revdep); |
1237 | if (revdep) | ||
1238 | fn(data, NULL, "\n - "); | ||
1239 | else | ||
1240 | fn(data, NULL, " || "); | ||
1241 | __expr_print(e->right.expr, fn, data, E_OR, revdep); | ||
1237 | break; | 1242 | break; |
1238 | case E_AND: | 1243 | case E_AND: |
1239 | expr_print(e->left.expr, fn, data, E_AND); | 1244 | expr_print(e->left.expr, fn, data, E_AND); |
@@ -1266,6 +1271,11 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * | |||
1266 | fn(data, NULL, ")"); | 1271 | fn(data, NULL, ")"); |
1267 | } | 1272 | } |
1268 | 1273 | ||
1274 | void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) | ||
1275 | { | ||
1276 | __expr_print(e, fn, data, prevtoken, false); | ||
1277 | } | ||
1278 | |||
1269 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) | 1279 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) |
1270 | { | 1280 | { |
1271 | xfwrite(str, strlen(str), 1, data); | 1281 | xfwrite(str, strlen(str), 1, data); |
@@ -1310,3 +1320,13 @@ void expr_gstr_print(struct expr *e, struct gstr *gs) | |||
1310 | { | 1320 | { |
1311 | expr_print(e, expr_print_gstr_helper, gs, E_NONE); | 1321 | expr_print(e, expr_print_gstr_helper, gs, E_NONE); |
1312 | } | 1322 | } |
1323 | |||
1324 | /* | ||
1325 | * Transform the top level "||" tokens into newlines and prepend each | ||
1326 | * line with a minus. This makes expressions much easier to read. | ||
1327 | * Suitable for reverse dependency expressions. | ||
1328 | */ | ||
1329 | void expr_gstr_print_revdep(struct expr *e, struct gstr *gs) | ||
1330 | { | ||
1331 | __expr_print(e, expr_print_gstr_helper, gs, E_NONE, true); | ||
1332 | } | ||