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