diff options
Diffstat (limited to 'payloads/libpayload/util/kconfig/zconf.y')
-rw-r--r-- | payloads/libpayload/util/kconfig/zconf.y | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/payloads/libpayload/util/kconfig/zconf.y b/payloads/libpayload/util/kconfig/zconf.y index ab8c1377f0..9f211e81d7 100644 --- a/payloads/libpayload/util/kconfig/zconf.y +++ b/payloads/libpayload/util/kconfig/zconf.y @@ -64,13 +64,13 @@ static struct menu *current_menu, *current_entry; %token <id>T_IF %token <id>T_ENDIF %token <id>T_DEPENDS -%token <id>T_REQUIRES %token <id>T_OPTIONAL %token <id>T_PROMPT %token <id>T_TYPE %token <id>T_DEFAULT %token <id>T_SELECT %token <id>T_RANGE +%token <id>T_OPTION %token <id>T_ON %token <string> T_WORD %token <string> T_WORD_QUOTE @@ -91,6 +91,7 @@ static struct menu *current_menu, *current_entry; %type <id> end %type <id> option_name %type <menu> if_entry menu_entry choice_entry +%type <string> symbol_option_arg %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -173,6 +174,7 @@ menuconfig_stmt: menuconfig_entry_start config_option_list config_option_list: /* empty */ | config_option_list config_option + | config_option_list symbol_option | config_option_list depends | config_option_list help | config_option_list option_error @@ -215,6 +217,26 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; +symbol_option: T_OPTION symbol_option_list T_EOL +; + +symbol_option_list: + /* empty */ + | symbol_option_list T_WORD symbol_option_arg +{ + struct kconf_id *id = kconf_id_lookup($2, strlen($2)); + if (id && id->flags & TF_OPTION) + menu_add_option(id->token, $3); + else + zconfprint("warning: ignoring unknown option %s", $2); + free($2); +}; + +symbol_option_arg: + /* empty */ { $$ = NULL; } + | T_EQUAL prompt { $$ = $2; } +; + /* choice entry */ choice: T_CHOICE T_EOL @@ -379,7 +401,7 @@ help_start: T_HELP T_EOL help: help_start T_HELPTEXT { - current_entry->sym->help = $2; + current_entry->help = $2; }; /* depends option */ @@ -395,16 +417,6 @@ depends: T_DEPENDS T_ON expr T_EOL { menu_add_dep($3); printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); -} - | T_DEPENDS expr T_EOL -{ - menu_add_dep($2); - printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); -} - | T_REQUIRES expr T_EOL -{ - menu_add_dep($2); - printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); }; /* prompt statement */ @@ -458,8 +470,10 @@ void conf_parse(const char *name) sym_init(); menu_init(); - modules_sym = sym_lookup("MODULES", 0); - rootmenu.prompt = menu_add_prompt(P_MENU, "Libpayload Configuration", NULL); + modules_sym = sym_lookup(NULL, 0); + modules_sym->type = S_BOOLEAN; + modules_sym->flags |= SYMBOL_AUTO; + rootmenu.prompt = menu_add_prompt(P_MENU, "libpayload Configuration", NULL); #if YYDEBUG if (getenv("ZCONF_DEBUG")) @@ -468,12 +482,20 @@ void conf_parse(const char *name) zconfparse(); if (zconfnerrs) exit(1); + if (!modules_sym->prop) { + struct property *prop; + + prop = prop_alloc(P_DEFAULT, modules_sym); + prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0)); + } menu_finalize(&rootmenu); for_all_symbols(i, sym) { - sym_check_deps(sym); + if (sym_check_deps(sym)) + zconfnerrs++; } - - sym_change_count = 1; + if (zconfnerrs) + exit(1); + sym_set_change_count(1); } const char *zconf_tokenname(int token) @@ -616,11 +638,11 @@ void print_symbol(FILE *out, struct menu *menu) break; } } - if (sym->help) { - int len = strlen(sym->help); - while (sym->help[--len] == '\n') - sym->help[len] = 0; - fprintf(out, " help\n%s\n", sym->help); + if (menu->help) { + int len = strlen(menu->help); + while (menu->help[--len] == '\n') + menu->help[len] = 0; + fprintf(out, " help\n%s\n", menu->help); } fputc('\n', out); } |