aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/confdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r--scripts/kconfig/confdata.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 583f6405f01d..f81f263b64f2 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -457,6 +457,82 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
457 } 457 }
458} 458}
459 459
460/*
461 * Write out a minimal config.
462 * All values that has default values are skipped as this is redundant.
463 */
464int conf_write_defconfig(const char *filename)
465{
466 struct symbol *sym;
467 struct menu *menu;
468 FILE *out;
469
470 out = fopen(filename, "w");
471 if (!out)
472 return 1;
473
474 sym_clear_all_valid();
475
476 /* Traverse all menus to find all relevant symbols */
477 menu = rootmenu.list;
478
479 while (menu != NULL)
480 {
481 sym = menu->sym;
482 if (sym == NULL) {
483 if (!menu_is_visible(menu))
484 goto next_menu;
485 } else if (!sym_is_choice(sym)) {
486 sym_calc_value(sym);
487 if (!(sym->flags & SYMBOL_WRITE))
488 goto next_menu;
489 sym->flags &= ~SYMBOL_WRITE;
490 /* If we cannot change the symbol - skip */
491 if (!sym_is_changable(sym))
492 goto next_menu;
493 /* If symbol equals to default value - skip */
494 if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
495 goto next_menu;
496
497 /*
498 * If symbol is a choice value and equals to the
499 * default for a choice - skip.
500 * But only if value equal to "y".
501 */
502 if (sym_is_choice_value(sym)) {
503 struct symbol *cs;
504 struct symbol *ds;
505
506 cs = prop_get_symbol(sym_get_choice_prop(sym));
507 ds = sym_choice_default(cs);
508 if (sym == ds) {
509 if ((sym->type == S_BOOLEAN ||
510 sym->type == S_TRISTATE) &&
511 sym_get_tristate_value(sym) == yes)
512 goto next_menu;
513 }
514 }
515 conf_write_symbol(sym, sym->type, out, true);
516 }
517next_menu:
518 if (menu->list != NULL) {
519 menu = menu->list;
520 }
521 else if (menu->next != NULL) {
522 menu = menu->next;
523 } else {
524 while ((menu = menu->parent)) {
525 if (menu->next != NULL) {
526 menu = menu->next;
527 break;
528 }
529 }
530 }
531 }
532 fclose(out);
533 return 0;
534}
535
460int conf_write(const char *name) 536int conf_write(const char *name)
461{ 537{
462 FILE *out; 538 FILE *out;