kconfig: add an option to determine a menu's visibility

This option is aimed to add the possibility to control a menu's visibility
without adding dependency to the expression to all the submenu.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by Arnaud Lacombe and committed by Mauro Carvalho Chehab 86e187ff e53beacd

+32 -3
+1
scripts/kconfig/expr.h
··· 164 164 struct menu *list; 165 165 struct symbol *sym; 166 166 struct property *prompt; 167 + struct expr *visibility; 167 168 struct expr *dep; 168 169 unsigned int flags; 169 170 char *help;
+1
scripts/kconfig/lkc.h
··· 107 107 void menu_add_entry(struct symbol *sym); 108 108 void menu_end_entry(void); 109 109 void menu_add_dep(struct expr *dep); 110 + void menu_add_visibility(struct expr *dep); 110 111 struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); 111 112 struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); 112 113 void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
+11
scripts/kconfig/menu.c
··· 152 152 return menu_add_prop(type, prompt, NULL, dep); 153 153 } 154 154 155 + void menu_add_visibility(struct expr *expr) 156 + { 157 + current_entry->visibility = expr_alloc_and(current_entry->visibility, 158 + expr); 159 + } 160 + 155 161 void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) 156 162 { 157 163 menu_add_prop(type, NULL, expr, dep); ··· 415 409 416 410 if (!menu->prompt) 417 411 return false; 412 + 413 + if (menu->visibility) { 414 + if (expr_calc_value(menu->visibility) == no) 415 + return no; 416 + } 418 417 419 418 sym = menu->sym; 420 419 if (sym) {
+1
scripts/kconfig/zconf.gperf
··· 38 38 string, T_TYPE, TF_COMMAND, S_STRING 39 39 select, T_SELECT, TF_COMMAND 40 40 range, T_RANGE, TF_COMMAND 41 + visible, T_VISIBLE, TF_COMMAND 41 42 option, T_OPTION, TF_COMMAND 42 43 on, T_ON, TF_PARAM 43 44 modules, T_OPT_MODULES, TF_OPTION
+18 -3
scripts/kconfig/zconf.y
··· 36 36 #define YYERROR_VERBOSE 37 37 #endif 38 38 %} 39 - %expect 28 39 + %expect 30 40 40 41 41 %union 42 42 { ··· 68 68 %token <id>T_DEFAULT 69 69 %token <id>T_SELECT 70 70 %token <id>T_RANGE 71 + %token <id>T_VISIBLE 71 72 %token <id>T_OPTION 72 73 %token <id>T_ON 73 74 %token <string> T_WORD ··· 124 123 ; 125 124 126 125 option_name: 127 - T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT 126 + T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE 128 127 ; 129 128 130 129 common_stmt: ··· 360 359 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); 361 360 }; 362 361 363 - menu_entry: menu depends_list 362 + menu_entry: menu visibility_list depends_list 364 363 { 365 364 $$ = menu_add_menu(); 366 365 }; ··· 429 428 { 430 429 menu_add_dep($3); 431 430 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); 431 + }; 432 + 433 + /* visibility option */ 434 + 435 + visibility_list: 436 + /* empty */ 437 + | visibility_list visible 438 + | visibility_list T_EOL 439 + ; 440 + 441 + visible: T_VISIBLE if_expr 442 + { 443 + menu_add_visibility($2); 432 444 }; 433 445 434 446 /* prompt statement */ ··· 540 526 case T_IF: return "if"; 541 527 case T_ENDIF: return "endif"; 542 528 case T_DEPENDS: return "depends"; 529 + case T_VISIBLE: return "visible"; 543 530 } 544 531 return "<token>"; 545 532 }