diff options
author | Arnaud Lacombe <lacombar@gmail.com> | 2010-11-06 17:30:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-11-22 08:27:17 -0500 |
commit | 86e187ff9bce9fbed7bfed92ae34f491cf1af50f (patch) | |
tree | d857b2671a98e2eb1ddc80477b564e4d279ae464 /scripts | |
parent | e53beacd23d9cb47590da6a7a7f6d417b941a994 (diff) |
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>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/expr.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/lkc.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/menu.c | 11 | ||||
-rw-r--r-- | scripts/kconfig/zconf.gperf | 1 | ||||
-rw-r--r-- | scripts/kconfig/zconf.y | 21 |
5 files changed, 32 insertions, 3 deletions
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 184eb6a0b505..e57826ced380 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -164,6 +164,7 @@ struct menu { | |||
164 | struct menu *list; | 164 | struct menu *list; |
165 | struct symbol *sym; | 165 | struct symbol *sym; |
166 | struct property *prompt; | 166 | struct property *prompt; |
167 | struct expr *visibility; | ||
167 | struct expr *dep; | 168 | struct expr *dep; |
168 | unsigned int flags; | 169 | unsigned int flags; |
169 | char *help; | 170 | char *help; |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 753cdbd7b805..3f7240df0f3b 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -107,6 +107,7 @@ void menu_end_menu(void); | |||
107 | void menu_add_entry(struct symbol *sym); | 107 | void menu_add_entry(struct symbol *sym); |
108 | void menu_end_entry(void); | 108 | void menu_end_entry(void); |
109 | void menu_add_dep(struct expr *dep); | 109 | void menu_add_dep(struct expr *dep); |
110 | void menu_add_visibility(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_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 | 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); | 113 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); |
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 7e83aef42c6d..b9d9aa18e6d6 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -152,6 +152,12 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr | |||
152 | return menu_add_prop(type, prompt, NULL, dep); | 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 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) | 161 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) |
156 | { | 162 | { |
157 | menu_add_prop(type, NULL, expr, dep); | 163 | menu_add_prop(type, NULL, expr, dep); |
@@ -410,6 +416,11 @@ bool menu_is_visible(struct menu *menu) | |||
410 | if (!menu->prompt) | 416 | if (!menu->prompt) |
411 | return false; | 417 | return false; |
412 | 418 | ||
419 | if (menu->visibility) { | ||
420 | if (expr_calc_value(menu->visibility) == no) | ||
421 | return no; | ||
422 | } | ||
423 | |||
413 | sym = menu->sym; | 424 | sym = menu->sym; |
414 | if (sym) { | 425 | if (sym) { |
415 | sym_calc_value(sym); | 426 | sym_calc_value(sym); |
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf index d8bc74249622..c9e690eb7545 100644 --- a/scripts/kconfig/zconf.gperf +++ b/scripts/kconfig/zconf.gperf | |||
@@ -38,6 +38,7 @@ hex, T_TYPE, TF_COMMAND, S_HEX | |||
38 | string, T_TYPE, TF_COMMAND, S_STRING | 38 | string, T_TYPE, TF_COMMAND, S_STRING |
39 | select, T_SELECT, TF_COMMAND | 39 | select, T_SELECT, TF_COMMAND |
40 | range, T_RANGE, TF_COMMAND | 40 | range, T_RANGE, TF_COMMAND |
41 | visible, T_VISIBLE, TF_COMMAND | ||
41 | option, T_OPTION, TF_COMMAND | 42 | option, T_OPTION, TF_COMMAND |
42 | on, T_ON, TF_PARAM | 43 | on, T_ON, TF_PARAM |
43 | modules, T_OPT_MODULES, TF_OPTION | 44 | modules, T_OPT_MODULES, TF_OPTION |
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 2abd3c7ff15d..49fb4ab664c3 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y | |||
@@ -36,7 +36,7 @@ static struct menu *current_menu, *current_entry; | |||
36 | #define YYERROR_VERBOSE | 36 | #define YYERROR_VERBOSE |
37 | #endif | 37 | #endif |
38 | %} | 38 | %} |
39 | %expect 28 | 39 | %expect 30 |
40 | 40 | ||
41 | %union | 41 | %union |
42 | { | 42 | { |
@@ -68,6 +68,7 @@ static struct menu *current_menu, *current_entry; | |||
68 | %token <id>T_DEFAULT | 68 | %token <id>T_DEFAULT |
69 | %token <id>T_SELECT | 69 | %token <id>T_SELECT |
70 | %token <id>T_RANGE | 70 | %token <id>T_RANGE |
71 | %token <id>T_VISIBLE | ||
71 | %token <id>T_OPTION | 72 | %token <id>T_OPTION |
72 | %token <id>T_ON | 73 | %token <id>T_ON |
73 | %token <string> T_WORD | 74 | %token <string> T_WORD |
@@ -123,7 +124,7 @@ stmt_list: | |||
123 | ; | 124 | ; |
124 | 125 | ||
125 | option_name: | 126 | option_name: |
126 | T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | 127 | T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE |
127 | ; | 128 | ; |
128 | 129 | ||
129 | common_stmt: | 130 | common_stmt: |
@@ -359,7 +360,7 @@ menu: T_MENU prompt T_EOL | |||
359 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); | 360 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); |
360 | }; | 361 | }; |
361 | 362 | ||
362 | menu_entry: menu depends_list | 363 | menu_entry: menu visibility_list depends_list |
363 | { | 364 | { |
364 | $$ = menu_add_menu(); | 365 | $$ = menu_add_menu(); |
365 | }; | 366 | }; |
@@ -430,6 +431,19 @@ depends: T_DEPENDS T_ON expr T_EOL | |||
430 | printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); | 431 | printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); |
431 | }; | 432 | }; |
432 | 433 | ||
434 | /* visibility option */ | ||
435 | |||
436 | visibility_list: | ||
437 | /* empty */ | ||
438 | | visibility_list visible | ||
439 | | visibility_list T_EOL | ||
440 | ; | ||
441 | |||
442 | visible: T_VISIBLE if_expr | ||
443 | { | ||
444 | menu_add_visibility($2); | ||
445 | }; | ||
446 | |||
433 | /* prompt statement */ | 447 | /* prompt statement */ |
434 | 448 | ||
435 | prompt_stmt_opt: | 449 | prompt_stmt_opt: |
@@ -526,6 +540,7 @@ static const char *zconf_tokenname(int token) | |||
526 | case T_IF: return "if"; | 540 | case T_IF: return "if"; |
527 | case T_ENDIF: return "endif"; | 541 | case T_ENDIF: return "endif"; |
528 | case T_DEPENDS: return "depends"; | 542 | case T_DEPENDS: return "depends"; |
543 | case T_VISIBLE: return "visible"; | ||
529 | } | 544 | } |
530 | return "<token>"; | 545 | return "<token>"; |
531 | } | 546 | } |