aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/menu.c')
-rw-r--r--scripts/kconfig/menu.c84
1 files changed, 82 insertions, 2 deletions
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 07ff8d105c9d..059a2465c574 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -9,6 +9,9 @@
9#define LKC_DIRECT_LINK 9#define LKC_DIRECT_LINK
10#include "lkc.h" 10#include "lkc.h"
11 11
12static const char nohelp_text[] = N_(
13 "There is no help available for this kernel option.\n");
14
12struct menu rootmenu; 15struct menu rootmenu;
13static struct menu **last_entry_ptr; 16static struct menu **last_entry_ptr;
14 17
@@ -74,7 +77,7 @@ void menu_end_menu(void)
74 current_menu = current_menu->parent; 77 current_menu = current_menu->parent;
75} 78}
76 79
77struct expr *menu_check_dep(struct expr *e) 80static struct expr *menu_check_dep(struct expr *e)
78{ 81{
79 if (!e) 82 if (!e)
80 return e; 83 return e;
@@ -184,7 +187,7 @@ static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
184 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); 187 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
185} 188}
186 189
187void sym_check_prop(struct symbol *sym) 190static void sym_check_prop(struct symbol *sym)
188{ 191{
189 struct property *prop; 192 struct property *prop;
190 struct symbol *sym2; 193 struct symbol *sym2;
@@ -451,3 +454,80 @@ const char *menu_get_help(struct menu *menu)
451 else 454 else
452 return ""; 455 return "";
453} 456}
457
458static void get_prompt_str(struct gstr *r, struct property *prop)
459{
460 int i, j;
461 struct menu *submenu[8], *menu;
462
463 str_printf(r, _("Prompt: %s\n"), _(prop->text));
464 str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
465 prop->menu->lineno);
466 if (!expr_is_yes(prop->visible.expr)) {
467 str_append(r, _(" Depends on: "));
468 expr_gstr_print(prop->visible.expr, r);
469 str_append(r, "\n");
470 }
471 menu = prop->menu->parent;
472 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
473 submenu[i++] = menu;
474 if (i > 0) {
475 str_printf(r, _(" Location:\n"));
476 for (j = 4; --i >= 0; j += 2) {
477 menu = submenu[i];
478 str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
479 if (menu->sym) {
480 str_printf(r, " (%s [=%s])", menu->sym->name ?
481 menu->sym->name : _("<choice>"),
482 sym_get_string_value(menu->sym));
483 }
484 str_append(r, "\n");
485 }
486 }
487}
488
489void get_symbol_str(struct gstr *r, struct symbol *sym)
490{
491 bool hit;
492 struct property *prop;
493
494 if (sym && sym->name)
495 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
496 sym_get_string_value(sym));
497 for_all_prompts(sym, prop)
498 get_prompt_str(r, prop);
499 hit = false;
500 for_all_properties(sym, prop, P_SELECT) {
501 if (!hit) {
502 str_append(r, " Selects: ");
503 hit = true;
504 } else
505 str_printf(r, " && ");
506 expr_gstr_print(prop->expr, r);
507 }
508 if (hit)
509 str_append(r, "\n");
510 if (sym->rev_dep.expr) {
511 str_append(r, _(" Selected by: "));
512 expr_gstr_print(sym->rev_dep.expr, r);
513 str_append(r, "\n");
514 }
515 str_append(r, "\n\n");
516}
517
518void menu_get_ext_help(struct menu *menu, struct gstr *help)
519{
520 struct symbol *sym = menu->sym;
521
522 if (menu_has_help(menu)) {
523 if (sym->name) {
524 str_printf(help, "CONFIG_%s:\n\n", sym->name);
525 str_append(help, _(menu_get_help(menu)));
526 str_append(help, "\n");
527 }
528 } else {
529 str_append(help, nohelp_text);
530 }
531 if (sym)
532 get_symbol_str(help, sym);
533}