* [PATCH] kconfig: Document automatic submenu creation code
@ 2017-10-08 17:42 Ulf Magnusson
2018-01-11 15:29 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: Ulf Magnusson @ 2017-10-08 17:42 UTC (permalink / raw)
To: yann.morin.1998, linux-kbuild
Cc: sam, zippel, nicolas.pitre, michal.lkml, dirk, yamada.masahiro,
lacombar, JBeulich, linux-kernel, Ulf Magnusson
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>
---
| 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
--git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index e935793..d5fa572 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -347,25 +347,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, A, B, C, ..., are
+ * consecutive symbols and A, B, C, ... all depend on sym, the
+ * following menu structure will be created:
+ *
+ * sym
+ * +-A
+ * +-B
+ * +-C
+ * ...
+ *
+ * This also works recursively, giving the following structure
+ * if 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);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kconfig: Document automatic submenu creation code
2017-10-08 17:42 [PATCH] kconfig: Document automatic submenu creation code Ulf Magnusson
@ 2018-01-11 15:29 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2018-01-11 15:29 UTC (permalink / raw)
To: Ulf Magnusson
Cc: Yann E. MORIN, Linux Kbuild mailing list, Sam Ravnborg, zippel,
Nicolas Pitre, Michal Marek, dirk, Arnaud Lacombe, Jan Beulich,
Linux Kernel Mailing List
2017-10-09 2:42 GMT+09:00 Ulf Magnusson <ulfalizer@gmail.com>:
> 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>
> ---
> scripts/kconfig/menu.c | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
Applied to linux-kbuild/kconfig. Thanks!
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-11 15:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-08 17:42 [PATCH] kconfig: Document automatic submenu creation code Ulf Magnusson
2018-01-11 15:29 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).