kconfig: Document 'if' flattening logic
[carl9170fw.git] / config / menu.c
index 7634d567e77949d2f7a71d05a5de8d9e96403500..af66065733bb636be638d72c9fe4492692462d28 100644 (file)
@@ -323,6 +323,13 @@ void menu_finalize(struct menu *parent)
                                if (menu->sym && menu->sym->type == S_UNKNOWN)
                                        menu_set_type(sym->type);
                        }
+
+                       /*
+                        * Use the choice itself as the parent dependency of
+                        * the contained items. This turns the mode of the
+                        * choice into an upper bound on the visibility of the
+                        * choice value symbols.
+                        */
                        parentdep = expr_alloc_symbol(sym);
                } else if (parent->prompt)
                        parentdep = parent->prompt->visible.expr;
@@ -525,6 +532,35 @@ void menu_finalize(struct menu *parent)
                        *ep = expr_alloc_one(E_LIST, NULL);
                        (*ep)->right.sym = menu->sym;
                }
+
+               /*
+                * This code serves two purposes:
+                *
+                * (1) Flattening 'if' blocks, which do not specify a submenu
+                *     and only add dependencies.
+                *
+                *     (Automatic submenu creation might still create a submenu
+                *     from an 'if' before this code runs.)
+                *
+                * (2) "Undoing" any automatic submenus created earlier below
+                *     promptless symbols.
+                *
+                * Before:
+                *
+                *      A
+                *      if ... (or promptless symbol)
+                *       +-B
+                *       +-C
+                *      D
+                *
+                * After:
+                *
+                *      A
+                *      if ... (or promptless symbol)
+                *      B
+                *      C
+                *      D
+                */
                if (menu->list && (!menu->prompt || !menu->prompt->text)) {
                        for (last_menu = menu->list; ; last_menu = last_menu->next) {
                                last_menu->parent = parent;