Skip to content

Commit 8ea13e2

Browse files
committed
kconfig: implement the `mainmenu' directive
If specified, the directive must be placed at the top of the Kconfig file. We need to change the grammar to make the mainmenu directive set the `rootmenu' prompt. This reflect how menu_add_prompt() works internally, ie. set the prompt of the `current_entry', pointing originally to `rootmenu'. Signed-off-by: Arnaud Lacombe <lacombar@gmail.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Reviewed-by: Michal Marek <mmarek@suse.cz>
1 parent ef21160 commit 8ea13e2

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎Documentation/kbuild/kconfig-language.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ mainmenu:
322322
"mainmenu" <prompt>
323323

324324
This sets the config program's title bar if the config program chooses
325-
to use it.
325+
to use it. It should be placed at the top of the configuration, before any
326+
other statement.
326327

327328

328329
Kconfig hints

‎scripts/kconfig/zconf.y‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static struct menu *current_menu, *current_entry;
3636
#define YYERROR_VERBOSE
3737
#endif
3838
%}
39-
%expect 26
39+
%expect 28
4040

4141
%union
4242
{
@@ -104,14 +104,15 @@ static struct menu *current_menu, *current_entry;
104104
%}
105105

106106
%%
107-
input: stmt_list;
107+
input: nl start | start;
108+
109+
start: mainmenu_stmt stmt_list | stmt_list;
108110

109111
stmt_list:
110112
/* empty */
111113
| stmt_list common_stmt
112114
| stmt_list choice_stmt
113115
| stmt_list menu_stmt
114-
| stmt_list T_MAINMENU prompt nl
115116
| stmt_list end { zconf_error("unexpected end statement"); }
116117
| stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
117118
| stmt_list option_name error T_EOL
@@ -342,6 +343,13 @@ if_block:
342343
| if_block choice_stmt
343344
;
344345

346+
/* mainmenu entry */
347+
348+
mainmenu_stmt: T_MAINMENU prompt nl
349+
{
350+
menu_add_prompt(P_MENU, $2, NULL);
351+
};
352+
345353
/* menu entry */
346354

347355
menu: T_MENU prompt T_EOL

0 commit comments

Comments
 (0)