diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2008-02-28 23:11:50 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@uranus.ravnborg.org> | 2008-04-28 17:05:48 -0400 |
commit | 5a1aa8a1aff6191ecc55f21d8b5f0e47108ed91b (patch) | |
tree | 3e812a8027332c872f3ae3afb39212f4f9639361 /scripts/kconfig/menu.c | |
parent | 48981178869bf7d9770f11fc361996ad11217a75 (diff) |
kconfig: add named choice group
As choice dependency are now fully checked, it's quite easy to add support
for named choices. This lifts the restriction that a choice value can only
appear once, although it still has to be within the same group,
but multiple choices can be joined by giving them a name.
While at it I cleaned up a little the choice type logic to simplify it a
bit.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/menu.c')
-rw-r--r-- | scripts/kconfig/menu.c | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 606ceb9e746e..07ff8d105c9d 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -235,18 +235,22 @@ void menu_finalize(struct menu *parent) | |||
235 | sym = parent->sym; | 235 | sym = parent->sym; |
236 | if (parent->list) { | 236 | if (parent->list) { |
237 | if (sym && sym_is_choice(sym)) { | 237 | if (sym && sym_is_choice(sym)) { |
238 | /* find the first choice value and find out choice type */ | 238 | if (sym->type == S_UNKNOWN) { |
239 | for (menu = parent->list; menu; menu = menu->next) { | 239 | /* find the first choice value to find out choice type */ |
240 | if (menu->sym) { | 240 | current_entry = parent; |
241 | current_entry = parent; | 241 | for (menu = parent->list; menu; menu = menu->next) { |
242 | if (sym->type == S_UNKNOWN) | 242 | if (menu->sym && menu->sym->type != S_UNKNOWN) { |
243 | menu_set_type(menu->sym->type); | 243 | menu_set_type(menu->sym->type); |
244 | current_entry = menu; | 244 | break; |
245 | if (menu->sym->type == S_UNKNOWN) | 245 | } |
246 | menu_set_type(sym->type); | ||
247 | break; | ||
248 | } | 246 | } |
249 | } | 247 | } |
248 | /* set the type of the remaining choice values */ | ||
249 | for (menu = parent->list; menu; menu = menu->next) { | ||
250 | current_entry = menu; | ||
251 | if (menu->sym && menu->sym->type == S_UNKNOWN) | ||
252 | menu_set_type(sym->type); | ||
253 | } | ||
250 | parentdep = expr_alloc_symbol(sym); | 254 | parentdep = expr_alloc_symbol(sym); |
251 | } else if (parent->prompt) | 255 | } else if (parent->prompt) |
252 | parentdep = parent->prompt->visible.expr; | 256 | parentdep = parent->prompt->visible.expr; |
@@ -313,50 +317,36 @@ void menu_finalize(struct menu *parent) | |||
313 | } | 317 | } |
314 | } | 318 | } |
315 | for (menu = parent->list; menu; menu = menu->next) { | 319 | for (menu = parent->list; menu; menu = menu->next) { |
316 | if (sym && sym_is_choice(sym) && menu->sym) { | 320 | if (sym && sym_is_choice(sym) && |
321 | menu->sym && !sym_is_choice_value(menu->sym)) { | ||
322 | current_entry = menu; | ||
317 | menu->sym->flags |= SYMBOL_CHOICEVAL; | 323 | menu->sym->flags |= SYMBOL_CHOICEVAL; |
318 | if (!menu->prompt) | 324 | if (!menu->prompt) |
319 | menu_warn(menu, "choice value must have a prompt"); | 325 | menu_warn(menu, "choice value must have a prompt"); |
320 | for (prop = menu->sym->prop; prop; prop = prop->next) { | 326 | for (prop = menu->sym->prop; prop; prop = prop->next) { |
321 | if (prop->type == P_PROMPT && prop->menu != menu) { | ||
322 | prop_warn(prop, "choice values " | ||
323 | "currently only support a " | ||
324 | "single prompt"); | ||
325 | } | ||
326 | if (prop->type == P_DEFAULT) | 327 | if (prop->type == P_DEFAULT) |
327 | prop_warn(prop, "defaults for choice " | 328 | prop_warn(prop, "defaults for choice " |
328 | "values not supported"); | 329 | "values not supported"); |
330 | if (prop->menu == menu) | ||
331 | continue; | ||
332 | if (prop->type == P_PROMPT && | ||
333 | prop->menu->parent->sym != sym) | ||
334 | prop_warn(prop, "choice value used outside its choice group"); | ||
329 | } | 335 | } |
330 | current_entry = menu; | ||
331 | if (menu->sym->type == S_UNKNOWN) | ||
332 | menu_set_type(sym->type); | ||
333 | /* Non-tristate choice values of tristate choices must | 336 | /* Non-tristate choice values of tristate choices must |
334 | * depend on the choice being set to Y. The choice | 337 | * depend on the choice being set to Y. The choice |
335 | * values' dependencies were propagated to their | 338 | * values' dependencies were propagated to their |
336 | * properties above, so the change here must be re- | 339 | * properties above, so the change here must be re- |
337 | * propagated. */ | 340 | * propagated. |
341 | */ | ||
338 | if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) { | 342 | if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) { |
339 | basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes); | 343 | basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes); |
340 | basedep = expr_alloc_and(basedep, menu->dep); | 344 | menu->dep = expr_alloc_and(basedep, menu->dep); |
341 | basedep = expr_eliminate_dups(basedep); | ||
342 | menu->dep = basedep; | ||
343 | for (prop = menu->sym->prop; prop; prop = prop->next) { | 345 | for (prop = menu->sym->prop; prop; prop = prop->next) { |
344 | if (prop->menu != menu) | 346 | if (prop->menu != menu) |
345 | continue; | 347 | continue; |
346 | dep = expr_alloc_and(expr_copy(basedep), | 348 | prop->visible.expr = expr_alloc_and(expr_copy(basedep), |
347 | prop->visible.expr); | 349 | prop->visible.expr); |
348 | dep = expr_eliminate_dups(dep); | ||
349 | dep = expr_trans_bool(dep); | ||
350 | prop->visible.expr = dep; | ||
351 | if (prop->type == P_SELECT) { | ||
352 | struct symbol *es = prop_get_symbol(prop); | ||
353 | dep2 = expr_alloc_symbol(menu->sym); | ||
354 | dep = expr_alloc_and(dep2, | ||
355 | expr_copy(dep)); | ||
356 | dep = expr_alloc_or(es->rev_dep.expr, dep); | ||
357 | dep = expr_eliminate_dups(dep); | ||
358 | es->rev_dep.expr = dep; | ||
359 | } | ||
360 | } | 350 | } |
361 | } | 351 | } |
362 | menu_add_symbol(P_CHOICE, sym, NULL); | 352 | menu_add_symbol(P_CHOICE, sym, NULL); |