summaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2017-10-08 19:42:18 +0200
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-01-22 00:49:28 +0900
commit05cccce580456d9b1a4548d9aba758856cac6455 (patch)
tree266028d2b2f70de0a824088fec4e145ae5c5e2c4 /scripts/kconfig
parent7cf33f88e2941051309e094e2fafd80f364735f2 (diff)
downloadtalos-op-linux-05cccce580456d9b1a4548d9aba758856cac6455.tar.gz
talos-op-linux-05cccce580456d9b1a4548d9aba758856cac6455.zip
kconfig: Document automatic submenu creation code
It's tricky to figure out what it does (and how) without staring at the code for a long time. Document it to make it more transparent. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/menu.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 41c79bef3d07..d061a4d4e203 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -418,25 +418,63 @@ void menu_finalize(struct menu *parent)
for (menu = parent->list; menu; menu = menu->next)
menu_finalize(menu);
} else if (sym) {
+ /*
+ * Automatic submenu creation. If sym is a symbol and A, B, C,
+ * ... are consecutive items (symbols, menus, ifs, etc.) that
+ * all depend on sym, then the following menu structure is
+ * created:
+ *
+ * sym
+ * +-A
+ * +-B
+ * +-C
+ * ...
+ *
+ * This also works recursively, giving the following structure
+ * if A is a symbol and B depends on A:
+ *
+ * sym
+ * +-A
+ * | +-B
+ * +-C
+ * ...
+ */
+
basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
basedep = expr_eliminate_dups(expr_transform(basedep));
+
+ /* Examine consecutive elements after sym */
last_menu = NULL;
for (menu = parent->next; menu; menu = menu->next) {
dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
if (!expr_contains_symbol(dep, sym))
+ /* No dependency, quit */
break;
if (expr_depends_symbol(dep, sym))
+ /* Absolute dependency, put in submenu */
goto next;
+
+ /*
+ * Also consider it a dependency on sym if our
+ * dependencies contain sym and are a "superset" of
+ * sym's dependencies, e.g. '(sym || Q) && R' when sym
+ * depends on R.
+ *
+ * Note that 'R' might be from an enclosing menu or if,
+ * making this a more common case than it might seem.
+ */
dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
dep = expr_eliminate_dups(expr_transform(dep));
dep2 = expr_copy(basedep);
expr_eliminate_eq(&dep, &dep2);
expr_free(dep);
if (!expr_is_yes(dep2)) {
+ /* Not superset, quit */
expr_free(dep2);
break;
}
+ /* Superset, put in submenu */
expr_free(dep2);
next:
menu_finalize(menu);
OpenPOWER on IntegriCloud