From f0778c8c41001783d4074e34efc7d3e632d87ee3 Mon Sep 17 00:00:00 2001 From: Aristeu Rozanski Date: Thu, 6 May 2010 12:48:34 -0400 Subject: kconfig: introduce nonint_oldconfig and loose_nonint_oldconfig This patch has been around for a long time in Fedora and Red Hat Enterprise Linux kernels and it may be useful for others. The nonint_oldconfig target will fail and print the unset config options while loose_nonint_oldconfig will simply let the config option unset. They're useful in distro kernel packages where the config files are built using a combination of smaller config files. Arjan van de Ven wrote the initial nonint_config and Roland McGrath added the loose_nonint_oldconfig. Signed-off-by: Arjan van de Ven [defunct email] Whatevered-by: Kyle McMartin Acked-by: Arjan van de Ven Acked-by: Randy Dunlap Signed-off-by: Aristeu Rozanski [mmarek: whitespace fixes] Signed-off-by: Michal Marek --- scripts/kconfig/Makefile | 10 +++++++++ scripts/kconfig/conf.c | 53 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 75bdf5ae202c..f8d1ee3a372e 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -62,6 +62,12 @@ localyesconfig: $(obj)/streamline_config.pl $(obj)/conf fi $(Q)rm -f .tmp.config +nonint_oldconfig: $(obj)/conf + $< -b $(Kconfig) + +loose_nonint_oldconfig: $(obj)/conf + $< -B $(Kconfig) + # Create new linux.pot file # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files # The symlink is used to repair a deficiency in arch/um @@ -126,6 +132,10 @@ help: @echo ' allmodconfig - New config selecting modules when possible' @echo ' allyesconfig - New config where all options are accepted with yes' @echo ' allnoconfig - New config where all options are answered with no' + @echo ' nonint_oldconfig - Checks the current configuration and fails if an option is ' + @echo ' not set' + @echo ' loose_nonint_oldconfig - Same as nonint_oldconfig, but updates the config file with ' + @echo ' missing config options as unset' # lxdialog stuff check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9960d1c303f8..3fa4abf3b084 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -16,6 +16,10 @@ #define LKC_DIRECT_LINK #include "lkc.h" +/* Return codes */ +#define EUNSETOPT 2 /* if -B and -b are used and unset config + * options were found */ + static void conf(struct menu *menu); static void check_conf(struct menu *menu); @@ -23,6 +27,8 @@ enum { ask_all, ask_new, ask_silent, + dont_ask, + dont_ask_dont_tell, set_default, set_yes, set_mod, @@ -37,6 +43,7 @@ static int sync_kconfig; static int conf_cnt; static char line[128]; static struct menu *rootEntry; +static int unset_variables; static void print_help(struct menu *menu) { @@ -360,7 +367,10 @@ static void conf(struct menu *menu) switch (prop->type) { case P_MENU: - if (input_mode == ask_silent && rootEntry != menu) { + if ((input_mode == ask_silent || + input_mode == dont_ask || + input_mode == dont_ask_dont_tell) && + rootEntry != menu) { check_conf(menu); return; } @@ -418,10 +428,23 @@ static void check_conf(struct menu *menu) if (sym && !sym_has_value(sym)) { if (sym_is_changable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { - if (!conf_cnt++) - printf(_("*\n* Restart config...\n*\n")); - rootEntry = menu_get_parent_menu(menu); - conf(rootEntry); + if (input_mode == dont_ask || + input_mode == dont_ask_dont_tell) { + if (input_mode == dont_ask && + sym->name && !sym_is_choice_value(sym)) { + if (!unset_variables) + fprintf(stderr, "The following" + " variables are not set:\n"); + fprintf(stderr, "CONFIG_%s\n", + sym->name); + unset_variables++; + } + } else { + if (!conf_cnt++) + printf(_("*\n* Restart config...\n*\n")); + rootEntry = menu_get_parent_menu(menu); + conf(rootEntry); + } } } @@ -439,7 +462,7 @@ int main(int ac, char **av) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { + while ((opt = getopt(ac, av, "osbBdD:nmyrh")) != -1) { switch (opt) { case 'o': input_mode = ask_silent; @@ -448,6 +471,12 @@ int main(int ac, char **av) input_mode = ask_silent; sync_kconfig = 1; break; + case 'b': + input_mode = dont_ask; + break; + case 'B': + input_mode = dont_ask_dont_tell; + break; case 'd': input_mode = set_default; break; @@ -525,6 +554,8 @@ int main(int ac, char **av) case ask_silent: case ask_all: case ask_new: + case dont_ask: + case dont_ask_dont_tell: conf_read(NULL); break; case set_no: @@ -586,12 +617,16 @@ int main(int ac, char **av) conf(&rootmenu); input_mode = ask_silent; /* fall through */ + case dont_ask: + case dont_ask_dont_tell: case ask_silent: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); - } while (conf_cnt); + } while (conf_cnt && + (input_mode != dont_ask && + input_mode != dont_ask_dont_tell)); break; } @@ -607,11 +642,11 @@ int main(int ac, char **av) fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); return 1; } - } else { + } else if (!unset_variables || input_mode != dont_ask) { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); exit(1); } } - return 0; + return unset_variables ? EUNSETOPT : 0; } -- cgit v1.2.3-59-g8ed1b From b040b44c35c251882da8488a5f038435a531312c Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:56:33 +0800 Subject: kconfig: print symbol type in help text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Randy suggested to print out the symbol type in gconfig. Note this change does more than Randy's suggestion, that it also affects menuconfig and "make config". │ Symbol: BLOCK [=y] │ Type : boolean │ Prompt: Enable the block layer │ Defined at block/Kconfig:4 │ Depends on: EMBEDDED [=n] Signed-off-by: Li Zefan Acked-by: Randy Dunlap Signed-off-by: Michal Marek --- scripts/kconfig/menu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 203632cc30bd..187caa9142fd 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -501,9 +501,11 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) bool hit; struct property *prop; - if (sym && sym->name) + if (sym && sym->name) { str_printf(r, "Symbol: %s [=%s]\n", sym->name, sym_get_string_value(sym)); + str_printf(r, "Type : %s\n", sym_type_name(sym->type)); + } for_all_prompts(sym, prop) get_prompt_str(r, prop); hit = false; -- cgit v1.2.3-59-g8ed1b From 70ed074718a6704ac2f82d014f372ba25c42ba12 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:56:50 +0800 Subject: kconfig: print the range of integer/hex symbol in help text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this patch, one has to refer to the Kconfig file to find out the range of an integer/hex symbol. │ Symbol: NR_CPUS [=4] │ Type : integer │ Range : [2 8] │ Prompt: Maximum number of CPUs │ Defined at arch/x86/Kconfig:761 │ Depends on: SMP [=y] && !MAXSMP [=n] │ Location: │ -> Processor type and features Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/expr.c | 2 +- scripts/kconfig/menu.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index d83f2322893a..8f18e37892cb 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1121,7 +1121,7 @@ static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *s } str_append(gs, str); - if (sym) + if (sym && sym->type != S_UNKNOWN) str_printf(gs, " [=%s]", sym_str); } diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 187caa9142fd..9d1f2adf2289 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -505,6 +505,14 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) str_printf(r, "Symbol: %s [=%s]\n", sym->name, sym_get_string_value(sym)); str_printf(r, "Type : %s\n", sym_type_name(sym->type)); + if (sym->type == S_INT || sym->type == S_HEX) { + prop = sym_get_range_prop(sym); + if (prop) { + str_printf(r, "Range : "); + expr_gstr_print(prop->expr, r); + str_append(r, "\n"); + } + } } for_all_prompts(sym, prop) get_prompt_str(r, prop); -- cgit v1.2.3-59-g8ed1b From 3fb9acb3297f5e1170f3e45a18cc3f8b1fd1901a Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:57:07 +0800 Subject: kconfig: fix to tag NEW symbols correctly Those configs are not new: $ cat .config ... CONFIG_NAMESPACES=y ... CONFIG_BLOCK=y ... But are tagged as NEW: $ yes "" | make config > myconf $ cat myconf | grep '(NEW)' Namespaces support (NAMESPACES) [Y/?] (NEW) y ... Enable the block layer (BLOCK) [Y/?] (NEW) y ... You can also notice this bug when using gconfig/xconfig. It's because the SYMBOL_DEF_USER bit of an invisible symbol is cleared when the config file is read: int conf_read(const char *name) { ... for_all_symbols(i, sym) { if (sym_has_value(sym) && !sym_is_choice_value(sym)) { /* Reset values of generates values, so they'll appear * as new, if they should become visible, but that * doesn't quite work if the Kconfig and the saved * configuration disagree. */ if (sym->visible == no && !conf_unsaved) sym->flags &= ~SYMBOL_DEF_USER; ... } But a menu item which represents an invisible symbol is still visible, if it's sub-menu is visible, so its SYMBOL_DEF_USER bit should be set to indicate it's not NEW. Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/menu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 9d1f2adf2289..eef17bacb6bc 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -419,9 +419,13 @@ bool menu_is_visible(struct menu *menu) if (!sym || sym_get_tristate_value(menu->sym) == no) return false; - for (child = menu->list; child; child = child->next) - if (menu_is_visible(child)) + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child)) { + if (sym) + sym->flags |= SYMBOL_DEF_USER; return true; + } + } return false; } -- cgit v1.2.3-59-g8ed1b From f9447c49390f4935e19e89c88ce4a1311c080dbc Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:57:22 +0800 Subject: menuconfig: improive help text a bit Suggested-by: Randy Dunlap Signed-off-by: Li Zefan Acked-by: Randy Dunlap Signed-off-by: Michal Marek --- scripts/kconfig/mconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 2c83d3234d30..d2f6e056c058 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -74,7 +74,7 @@ static const char mconf_readme[] = N_( "\n" " Shortcut: Press or .\n" "\n" -"o To show hidden options, press .\n" +"o To toggle the display of hidden options, press .\n" "\n" "\n" "Radiolists (Choice lists)\n" -- cgit v1.2.3-59-g8ed1b From e0bb7fe2d7e6d7cfa6135fa9ca5634343fff63b5 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:57:35 +0800 Subject: gconfig: fix to tag NEW symbols correctly The logic should be reversed. Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/gconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index bef10411837f..1b1832943d7a 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -1114,7 +1114,7 @@ static gchar **fill_row(struct menu *menu) row[COL_OPTION] = g_strdup_printf("%s %s", _(menu_get_prompt(menu)), - sym && sym_has_value(sym) ? "(NEW)" : ""); + sym && !sym_has_value(sym) ? "(NEW)" : ""); if (opt_mode == OPT_ALL && !menu_is_visible(menu)) row[COL_COLOR] = g_strdup("DarkGray"); -- cgit v1.2.3-59-g8ed1b From c10d03caf303d91da07c7f093a4822453c13f9b1 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:57:49 +0800 Subject: gconfig: fix null pointer warning In gconfig if you enable "Show all options", you'll see some "(null)" config options, and clicking those options triggers a warning: (gconf:9368): Gtk-CRITICAL **: gtk_text_buffer_insert_with_tags: assertion `text != NULL' failed Signed-off-by: Li Zefan Acked-by: Randy Dunlap Signed-off-by: Michal Marek --- scripts/kconfig/gconf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 1b1832943d7a..d66988265f89 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -1343,7 +1343,8 @@ static void update_tree(struct menu *src, GtkTreeIter * dst) #endif if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) || - (opt_mode == OPT_PROMPT && !menu_has_prompt(child1))) { + (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) || + (opt_mode == OPT_ALL && !menu_get_prompt(child1))) { /* remove node */ if (gtktree_iter_find_node(dst, menu1) != NULL) { @@ -1425,7 +1426,7 @@ static void display_tree(struct menu *menu) if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) || (opt_mode == OPT_PROMPT && menu_has_prompt(child)) || - (opt_mode == OPT_ALL)) + (opt_mode == OPT_ALL && menu_get_prompt(child))) place_node(child, fill_row(child)); #ifdef DEBUG printf("%*c%s: ", indent, ' ', menu_get_prompt(child)); -- cgit v1.2.3-59-g8ed1b From c1f96f091ee146836dd73ecce531f8e0a170cfca Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:58:04 +0800 Subject: xconfig: clean up @ok is a pointer to a bool var, so we should check the value of *ok. But actually we don't need to check it, so just remove the if statement. Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/qconf.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 00c51507cfcc..47cdeae8378c 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -58,11 +58,10 @@ QValueList ConfigSettings::readSizes(const QString& key, bool *ok) { QValueList result; QStringList entryList = readListEntry(key, ok); - if (ok) { - QStringList::Iterator it; - for (it = entryList.begin(); it != entryList.end(); ++it) - result.push_back((*it).toInt()); - } + QStringList::Iterator it; + + for (it = entryList.begin(); it != entryList.end(); ++it) + result.push_back((*it).toInt()); return result; } -- cgit v1.2.3-59-g8ed1b From 120d63e63319aceea5d127f0de93bd7fe1cbaba1 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 7 May 2010 13:58:21 +0800 Subject: xconfig: remove unused function Remove ConfigInfoView::setSource(). Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/qconf.cc | 28 ---------------------------- scripts/kconfig/qconf.h | 1 - 2 files changed, 29 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 47cdeae8378c..5e01af2f41ac 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -963,34 +963,6 @@ void ConfigInfoView::setInfo(struct menu *m) menuInfo(); } -void ConfigInfoView::setSource(const QString& name) -{ - const char *p = name.latin1(); - - menu = NULL; - sym = NULL; - - switch (p[0]) { - case 'm': - struct menu *m; - - if (sscanf(p, "m%p", &m) == 1 && menu != m) { - menu = m; - menuInfo(); - emit menuSelected(menu); - } - break; - case 's': - struct symbol *s; - - if (sscanf(p, "s%p", &s) == 1 && sym != s) { - sym = s; - symbolInfo(); - } - break; - } -} - void ConfigInfoView::symbolInfo(void) { QString str; diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index b3b5657b6b35..54775ae38250 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -254,7 +254,6 @@ public: public slots: void setInfo(struct menu *menu); void saveSettings(void); - void setSource(const QString& name); void setShowDebug(bool); signals: -- cgit v1.2.3-59-g8ed1b From 39a4897c1bb66e8a36043c105d7fd73d8b32b480 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Mon, 10 May 2010 16:33:41 +0800 Subject: xconfig: add support to show hidden options which have prompts This feature has been supported in menuconfig and gconfig, so here add it to xconfig. Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/qconf.cc | 69 +++++++++++++++++++++++++++++++++++------------- scripts/kconfig/qconf.h | 16 ++++++++--- 2 files changed, 62 insertions(+), 23 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 5e01af2f41ac..820df2d1217b 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -148,7 +148,7 @@ void ConfigItem::updateMenu(void) case S_TRISTATE: char ch; - if (!sym_is_changable(sym) && !list->showAll) { + if (!sym_is_changable(sym) && list->optMode == normalOpt) { setPixmap(promptColIdx, 0); setText(noColIdx, QString::null); setText(modColIdx, QString::null); @@ -319,7 +319,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name) symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), - showAll(false), showName(false), showRange(false), showData(false), + showName(false), showRange(false), showData(false), optMode(normalOpt), rootEntry(0), headerPopup(0) { int i; @@ -336,10 +336,10 @@ ConfigList::ConfigList(ConfigView* p, const char *name) if (name) { configSettings->beginGroup(name); - showAll = configSettings->readBoolEntry("/showAll", false); showName = configSettings->readBoolEntry("/showName", false); showRange = configSettings->readBoolEntry("/showRange", false); showData = configSettings->readBoolEntry("/showData", false); + optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false); configSettings->endGroup(); connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); } @@ -351,6 +351,17 @@ ConfigList::ConfigList(ConfigView* p, const char *name) reinit(); } +bool ConfigList::menuSkip(struct menu *menu) +{ + if (optMode == normalOpt && menu_is_visible(menu)) + return false; + if (optMode == promptOpt && menu_has_prompt(menu)) + return false; + if (optMode == allOpt) + return false; + return true; +} + void ConfigList::reinit(void) { removeColumn(dataColIdx); @@ -379,7 +390,7 @@ void ConfigList::saveSettings(void) configSettings->writeEntry("/showName", showName); configSettings->writeEntry("/showRange", showRange); configSettings->writeEntry("/showData", showData); - configSettings->writeEntry("/showAll", showAll); + configSettings->writeEntry("/optionMode", (int)optMode); configSettings->endGroup(); } } @@ -605,7 +616,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu) } visible = menu_is_visible(child); - if (showAll || visible) { + if (!menuSkip(child)) { if (!child->sym && !child->list && !child->prompt) continue; if (!item || item->menu != child) @@ -834,7 +845,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) e->ignore(); } -ConfigView* ConfigView::viewList; +ConfigView*ConfigView::viewList; +QAction *ConfigView::showNormalAction; +QAction *ConfigView::showAllAction; +QAction *ConfigView::showPromptAction; ConfigView::ConfigView(QWidget* parent, const char *name) : Parent(parent, name) @@ -859,13 +873,16 @@ ConfigView::~ConfigView(void) } } -void ConfigView::setShowAll(bool b) +void ConfigView::setOptionMode(QAction *act) { - if (list->showAll != b) { - list->showAll = b; - list->updateListAll(); - emit showAllChanged(b); - } + if (act == showNormalAction) + list->optMode = normalOpt; + else if (act == showAllAction) + list->optMode = allOpt; + else + list->optMode = promptOpt; + + list->updateListAll(); } void ConfigView::setShowName(bool b) @@ -1320,11 +1337,24 @@ ConfigMainWindow::ConfigMainWindow(void) connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); showDataAction->setOn(configList->showData); - QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this); - showAllAction->setToggleAction(TRUE); - connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool))); - connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool))); - showAllAction->setOn(configList->showAll); + + QActionGroup *optGroup = new QActionGroup(this); + optGroup->setExclusive(TRUE); + connect(optGroup, SIGNAL(selected(QAction *)), configView, + SLOT(setOptionMode(QAction *))); + connect(optGroup, SIGNAL(selected(QAction *)), menuView, + SLOT(setOptionMode(QAction *))); + + configView->showNormalAction = new QAction(NULL, _("Show Normal Options"), 0, optGroup); + configView->showAllAction = new QAction(NULL, _("Show All Options"), 0, optGroup); + configView->showPromptAction = new QAction(NULL, _("Show Prompt Options"), 0, optGroup); + configView->showNormalAction->setToggleAction(TRUE); + configView->showNormalAction->setOn(configList->optMode == normalOpt); + configView->showAllAction->setToggleAction(TRUE); + configView->showAllAction->setOn(configList->optMode == allOpt); + configView->showPromptAction->setToggleAction(TRUE); + configView->showPromptAction->setOn(configList->optMode == promptOpt); + QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); showDebugAction->setToggleAction(TRUE); connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); @@ -1367,7 +1397,8 @@ ConfigMainWindow::ConfigMainWindow(void) showRangeAction->addTo(optionMenu); showDataAction->addTo(optionMenu); optionMenu->insertSeparator(); - showAllAction->addTo(optionMenu); + optGroup->addTo(optionMenu); + optionMenu->insertSeparator(); showDebugAction->addTo(optionMenu); // create help menu @@ -1462,7 +1493,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) ConfigList* list = NULL; ConfigItem* item; - if (!menu_is_visible(menu) && !configView->showAll()) + if (configList->menuSkip(menu)) return; switch (configList->mode) { diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 54775ae38250..636a74b23bf9 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -44,6 +44,9 @@ enum colIdx { enum listMode { singleMode, menuMode, symbolMode, fullMode, listMode }; +enum optionMode { + normalOpt = 0, allOpt, promptOpt +}; class ConfigList : public QListView { Q_OBJECT @@ -115,6 +118,8 @@ public: void setAllOpen(bool open); void setParentMenu(void); + bool menuSkip(struct menu *); + template void updateMenuList(P*, struct menu*); @@ -124,8 +129,9 @@ public: QPixmap choiceYesPix, choiceNoPix; QPixmap menuPix, menuInvPix, menuBackPix, voidPix; - bool showAll, showName, showRange, showData; + bool showName, showRange, showData; enum listMode mode; + enum optionMode optMode; struct menu *rootEntry; QColorGroup disabledColorGroup; QColorGroup inactivedColorGroup; @@ -222,17 +228,15 @@ public: static void updateList(ConfigItem* item); static void updateListAll(void); - bool showAll(void) const { return list->showAll; } bool showName(void) const { return list->showName; } bool showRange(void) const { return list->showRange; } bool showData(void) const { return list->showData; } public slots: - void setShowAll(bool); void setShowName(bool); void setShowRange(bool); void setShowData(bool); + void setOptionMode(QAction *); signals: - void showAllChanged(bool); void showNameChanged(bool); void showRangeChanged(bool); void showDataChanged(bool); @@ -242,6 +246,10 @@ public: static ConfigView* viewList; ConfigView* nextView; + + static QAction *showNormalAction; + static QAction *showAllAction; + static QAction *showPromptAction; }; class ConfigInfoView : public QTextBrowser { -- cgit v1.2.3-59-g8ed1b From 42ef223c4a0f6e34e13ccb503b423ebdc04878e1 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Thu, 3 Jun 2010 15:24:39 +0800 Subject: menuconfig: fix to center checklist correctly in a corner case Run: make ARCH=arm menuconfig And then select "System Type" -> "ARM system type". The kconfig "choice" menu at this point looks empty. It's because config ARCH_S3C2410 has a long prompt: config ARCH_S3C2410 bool "Samsung S3C2410, S3C2412, S3C2413, S3C2416, S3C2440, S3C2442, S3C2443, S3C2450" ... menuconfig centers the checklist according to this prompt without considering the width of the list, and then things get wrong. Reported-by: Nobin Mathew Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/lxdialog/checklist.c | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index bcc6f19c3a35..c92a05a2de17 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c @@ -175,6 +175,7 @@ do_resize: check_x = 0; item_foreach() check_x = MAX(check_x, strlen(item_str()) + 4); + check_x = MIN(check_x, list_width); check_x = (list_width - check_x) / 2; item_x = check_x + 4; -- cgit v1.2.3-59-g8ed1b From e7401d8321f89a3785a395ba307c720e2b390f96 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Thu, 3 Jun 2010 15:24:57 +0800 Subject: menuconfig: truncate list items Truncate list items to fit in a single line, otherwise those items which have long prompts will cover some other items. This follows the behavior of menubox. Signed-off-by: Li Zefan Signed-off-by: Michal Marek --- scripts/kconfig/lxdialog/checklist.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index c92a05a2de17..a2eb80fbc896 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c @@ -31,6 +31,10 @@ static int list_width, check_x, item_x; static void print_item(WINDOW * win, int choice, int selected) { int i; + char *list_item = malloc(list_width + 1); + + strncpy(list_item, item_str(), list_width - item_x); + list_item[list_width - item_x] = '\0'; /* Clear 'residue' of last item */ wattrset(win, dlg.menubox.atr); @@ -45,13 +49,14 @@ static void print_item(WINDOW * win, int choice, int selected) wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); - mvwaddch(win, choice, item_x, item_str()[0]); + mvwaddch(win, choice, item_x, list_item[0]); wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); - waddstr(win, (char *)item_str() + 1); + waddstr(win, list_item + 1); if (selected) { wmove(win, choice, check_x + 1); wrefresh(win); } + free(list_item); } /* -- cgit v1.2.3-59-g8ed1b From 60c8eca69f7fb2820677a635d921866f66727fcb Mon Sep 17 00:00:00 2001 From: "Justin P. Mattock" Date: Fri, 11 Jun 2010 13:41:04 -0700 Subject: scripts:conf.c Fix warning: variable 'type' set but not used Not sure if this is correct or not, but with make menuconfig HOSTCC scripts/kconfig/conf.o scripts/kconfig/conf.c: In function 'conf_sym': scripts/kconfig/conf.c:159:6: warning: variable 'type' set but not used scripts/kconfig/conf.c: In function 'conf_choice': scripts/kconfig/conf.c:231:6: warning: variable 'type' set but not used HOSTLD scripts/kconfig/mconf I get this using gcc 4.6.0 the below change fixes this form me. Signed-off-by: Justin P. Mattock Signed-off-by: Michal Marek --- scripts/kconfig/conf.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 3fa4abf3b084..bde01b4200ee 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -163,14 +163,12 @@ static int conf_string(struct menu *menu) static int conf_sym(struct menu *menu) { struct symbol *sym = menu->sym; - int type; tristate oldval, newval; while (1) { printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); if (sym->name) printf("(%s) ", sym->name); - type = sym_get_type(sym); putchar('['); oldval = sym_get_tristate_value(sym); switch (oldval) { @@ -235,11 +233,9 @@ static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; - int type; bool is_new; sym = menu->sym; - type = sym_get_type(sym); is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); -- cgit v1.2.3-59-g8ed1b From 246cf9c26bf11f2bffbecea6e5bd222eee7b1df8 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Tue, 8 Jun 2010 17:25:57 +0100 Subject: kbuild: Warn on selecting symbols with unmet direct dependencies The "select" statement in Kconfig files allows the enabling of options even if they have unmet direct dependencies (i.e. "depends on" expands to "no"). Currently, the "depends on" clauses are used in calculating the visibility but they do not affect the reverse dependencies in any way. The patch introduces additional tracking of the "depends on" statements and prints a warning on selecting an option if its direct dependencies are not met. Signed-off-by: Catalin Marinas Cc: Sam Ravnborg Cc: Arnd Bergmann Cc: Andrew Morton Cc: Linus Torvalds Signed-off-by: Michal Marek --- scripts/kconfig/expr.h | 2 ++ scripts/kconfig/menu.c | 5 +++++ scripts/kconfig/symbol.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 891cd9ce9ba2..75a31e4552f3 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -83,6 +83,7 @@ struct symbol { tristate visible; int flags; struct property *prop; + struct expr_value dir_dep; struct expr_value rev_dep; }; @@ -163,6 +164,7 @@ struct menu { struct symbol *sym; struct property *prompt; struct expr *dep; + struct expr *dir_dep; unsigned int flags; char *help; struct file *file; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index eef17bacb6bc..11799894f3bd 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -105,6 +105,7 @@ static struct expr *menu_check_dep(struct expr *e) void menu_add_dep(struct expr *dep) { current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); + current_entry->dir_dep = current_entry->dep; } void menu_set_type(int type) @@ -288,6 +289,10 @@ void menu_finalize(struct menu *parent) for (menu = parent->list; menu; menu = menu->next) menu_finalize(menu); } else if (sym) { + /* ignore inherited dependencies for dir_dep */ + sym->dir_dep.expr = expr_transform(expr_copy(parent->dir_dep)); + sym->dir_dep.expr = expr_eliminate_dups(sym->dir_dep.expr); + basedep = parent->prompt ? parent->prompt->visible.expr : NULL; basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); basedep = expr_eliminate_dups(expr_transform(basedep)); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 2e7a048e0cfc..174b230a52b0 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -205,6 +205,16 @@ static void sym_calc_visibility(struct symbol *sym) } if (sym_is_choice_value(sym)) return; + /* defaulting to "yes" if no explicit "depends on" are given */ + tri = yes; + if (sym->dir_dep.expr) + tri = expr_calc_value(sym->dir_dep.expr); + if (tri == mod) + tri = yes; + if (sym->dir_dep.tri != tri) { + sym->dir_dep.tri = tri; + sym_set_changed(sym); + } tri = no; if (sym->rev_dep.expr) tri = expr_calc_value(sym->rev_dep.expr); @@ -321,6 +331,14 @@ void sym_calc_value(struct symbol *sym) } } calc_newval: + if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { + fprintf(stderr, "warning: ("); + expr_fprint(sym->rev_dep.expr, stderr); + fprintf(stderr, ") selects %s which has unmet direct dependencies (", + sym->name); + expr_fprint(sym->dir_dep.expr, stderr); + fprintf(stderr, ")\n"); + } newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); } if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) -- cgit v1.2.3-59-g8ed1b From 0a28c47b8db8ff74d1bfbc5c5ad0100cea472351 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 30 Jun 2010 13:11:01 +0100 Subject: kconfig: Don't write invisible choice values This makes it so "make oldconfig" really prompts for any choice where options that previously weren't visible just became so. Previously one would have to remember to go over all choice values and check whether some that previously couldn't be selected now can be. Signed-off-by: Jan Beulich Signed-off-by: Michal Marek --- scripts/kconfig/symbol.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 174b230a52b0..c127fa342f1d 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -232,13 +232,15 @@ static struct symbol *sym_calc_choice(struct symbol *sym) struct property *prop; struct expr *e; + /* first calculate all choice values' visibilities */ + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, def_sym) + sym_calc_visibility(def_sym); + /* is the user choice visible? */ def_sym = sym->def[S_DEF_USER].val; - if (def_sym) { - sym_calc_visibility(def_sym); - if (def_sym->visible != no) - return def_sym; - } + if (def_sym && def_sym->visible != no) + return def_sym; /* any of the defaults visible? */ for_all_defaults(sym, prop) { @@ -246,18 +248,15 @@ static struct symbol *sym_calc_choice(struct symbol *sym) if (prop->visible.tri == no) continue; def_sym = prop_get_symbol(prop); - sym_calc_visibility(def_sym); if (def_sym->visible != no) return def_sym; } /* just get the first visible value */ prop = sym_get_choice_prop(sym); - expr_list_for_each_sym(prop->expr, e, def_sym) { - sym_calc_visibility(def_sym); + expr_list_for_each_sym(prop->expr, e, def_sym) if (def_sym->visible != no) return def_sym; - } /* no choice? reset tristate value */ sym->curr.tri = no; @@ -383,12 +382,13 @@ void sym_calc_value(struct symbol *sym) if (sym_is_choice(sym)) { struct symbol *choice_sym; - int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); prop = sym_get_choice_prop(sym); expr_list_for_each_sym(prop->expr, e, choice_sym) { - choice_sym->flags |= flags; - if (flags & SYMBOL_CHANGED) + if ((sym->flags & SYMBOL_WRITE) && + choice_sym->visible != no) + choice_sym->flags |= SYMBOL_WRITE; + if (sym->flags & SYMBOL_CHANGED) sym_set_changed(choice_sym); } } -- cgit v1.2.3-59-g8ed1b From 1244b41d00eb60cb3d05220383bc9d15b9045fb4 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 22 Jul 2010 14:24:57 +0200 Subject: kconfig: make randconfig fair for booleans Give boolean symbols a 50% chance of getting enabled, rather than 67%. Signed-off-by: Peter Korsgaard Acked-by: Sam Ravnborg Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index c4dec80cfd8e..210a49e27d47 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -862,7 +862,8 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) sym->def[S_DEF_USER].tri = no; break; case def_random: - sym->def[S_DEF_USER].tri = (tristate)(rand() % 3); + cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2; + sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt); break; default: continue; -- cgit v1.2.3-59-g8ed1b From ac1ffde1ba053db0266f886a15ed845a6628fcb0 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 27 Jul 2010 21:57:43 +0200 Subject: kconfig: fix MODULES-related bug in case of no .config There seems to be a kconfig bug due to MODULES not always being evaluated if no .config is found. Take the following Kconfig as an example: config MODULES def_bool y config FOO def_tristate m With no .config, the following configuration is generated: CONFIG_MODULES=y CONFIG_FOO=y With an empty .config, the following: CONFIG_MODULES=y CONFIG_FOO=m Tristate choice statements can also exhibit the problem, due to having an implicit rev_dep (select) containing "m". The problem is that MODULES is never evaluted in conf_read_simple() unless there's a .config. The following patch fixes this. Signed-off-by: Ulf Magnusson Reviewed-by: WANG Cong Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 210a49e27d47..8dce5862550d 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -170,8 +170,11 @@ int conf_read_simple(const char *name, int def) if (in) goto load; sym_add_change_count(1); - if (!sym_defconfig_list) + if (!sym_defconfig_list) { + if (modules_sym) + sym_calc_value(modules_sym); return 1; + } for_all_defaults(sym_defconfig_list, prop) { if (expr_calc_value(prop->visible.expr) == no || -- cgit v1.2.3-59-g8ed1b From 4062f1a4c030157216dc8932e27131975cf7253c Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:26 +0200 Subject: kconfig: use long options in conf The list of options supported by conf is growing and their abbreviation did not resemble anything usefull. So drop the single letter options in favour of long options. The long options are named equal to what we know from the make target. The internal implmentation was changed to match this, resulting in much more readable code. Support for short options is dropped - no one is supposed to call this program direct anyway. Signed-off-by: Sam Ravnborg Signed-off-by: Michal Marek --- scripts/kconfig/Makefile | 70 +++++++++------------ scripts/kconfig/conf.c | 161 ++++++++++++++++++++++------------------------- 2 files changed, 105 insertions(+), 126 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index f8d1ee3a372e..549e50e49cbf 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -21,53 +21,47 @@ menuconfig: $(obj)/mconf $< $(Kconfig) config: $(obj)/conf - $< $(Kconfig) + $< --oldaskconfig $(Kconfig) nconfig: $(obj)/nconf $< $(Kconfig) oldconfig: $(obj)/conf - $< -o $(Kconfig) + $< --$@ $(Kconfig) silentoldconfig: $(obj)/conf $(Q)mkdir -p include/generated - $< -s $(Kconfig) + $< --$@ $(Kconfig) localmodconfig: $(obj)/streamline_config.pl $(obj)/conf $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config - $(Q)if [ -f .config ]; then \ - cmp -s .tmp.config .config || \ - (mv -f .config .config.old.1; \ - mv -f .tmp.config .config; \ - $(obj)/conf -s $(Kconfig); \ - mv -f .config.old.1 .config.old) \ - else \ - mv -f .tmp.config .config; \ - $(obj)/conf -s $(Kconfig); \ + $(Q)if [ -f .config ]; then \ + cmp -s .tmp.config .config || \ + (mv -f .config .config.old.1; \ + mv -f .tmp.config .config; \ + $(obj)/conf --silentoldconfig $(Kconfig); \ + mv -f .config.old.1 .config.old) \ + else \ + mv -f .tmp.config .config; \ + $(obj)/conf --silentoldconfig $(Kconfig); \ fi $(Q)rm -f .tmp.config localyesconfig: $(obj)/streamline_config.pl $(obj)/conf $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config $(Q)sed -i s/=m/=y/ .tmp.config - $(Q)if [ -f .config ]; then \ - cmp -s .tmp.config .config || \ - (mv -f .config .config.old.1; \ - mv -f .tmp.config .config; \ - $(obj)/conf -s $(Kconfig); \ - mv -f .config.old.1 .config.old) \ - else \ - mv -f .tmp.config .config; \ - $(obj)/conf -s $(Kconfig); \ + $(Q)if [ -f .config ]; then \ + cmp -s .tmp.config .config || \ + (mv -f .config .config.old.1; \ + mv -f .tmp.config .config; \ + $(obj)/conf --silentoldconfig $(Kconfig); \ + mv -f .config.old.1 .config.old) \ + else \ + mv -f .tmp.config .config; \ + $(obj)/conf --silentoldconfig $(Kconfig); \ fi $(Q)rm -f .tmp.config -nonint_oldconfig: $(obj)/conf - $< -b $(Kconfig) - -loose_nonint_oldconfig: $(obj)/conf - $< -B $(Kconfig) - # Create new linux.pot file # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files # The symlink is used to repair a deficiency in arch/um @@ -91,30 +85,26 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h $(Q)rm -f arch/um/Kconfig.arch $(Q)rm -f $(obj)/config.pot -PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig - -randconfig: $(obj)/conf - $< -r $(Kconfig) +PHONY += allnoconfig allyesconfig allmodconfig randconfig -allyesconfig: $(obj)/conf - $< -y $(Kconfig) +allnoconfig allyesconfig allmodconfig randconfig: $(obj)/conf + $< --$@ $(Kconfig) -allnoconfig: $(obj)/conf - $< -n $(Kconfig) +PHONY += nonint_oldconfig loose_nonint_oldconfig defconfig -allmodconfig: $(obj)/conf - $< -m $(Kconfig) +nonint_oldconfig loose_nonint_oldconfig: $(obj)/conf + $< --$@ $(Kconfig) defconfig: $(obj)/conf ifeq ($(KBUILD_DEFCONFIG),) - $< -d $(Kconfig) + $< --defconfig $(Kconfig) else @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" - $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) + $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) endif %_defconfig: $(obj)/conf - $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig) + $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) # Help text used by make help help: diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index bde01b4200ee..2dec584f1268 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -23,18 +24,19 @@ static void conf(struct menu *menu); static void check_conf(struct menu *menu); -enum { - ask_all, - ask_new, - ask_silent, - dont_ask, - dont_ask_dont_tell, - set_default, - set_yes, - set_mod, - set_no, - set_random -} input_mode = ask_all; +enum input_mode { + oldaskconfig, + silentoldconfig, + oldconfig, + allnoconfig, + allyesconfig, + allmodconfig, + randconfig, + defconfig, + nonint_oldconfig, + loose_nonint_oldconfig, +} input_mode = oldaskconfig; + char *defconfig_file; static int indent = 1; @@ -100,14 +102,14 @@ static int conf_askvalue(struct symbol *sym, const char *def) } switch (input_mode) { - case ask_new: - case ask_silent: + case oldconfig: + case silentoldconfig: if (sym_has_value(sym)) { printf("%s\n", def); return 0; } check_stdin(); - case ask_all: + case oldaskconfig: fflush(stdout); fgets(line, 128, stdin); return 1; @@ -297,15 +299,15 @@ static int conf_choice(struct menu *menu) printf("?"); printf("]: "); switch (input_mode) { - case ask_new: - case ask_silent: + case oldconfig: + case silentoldconfig: if (!is_new) { cnt = def; printf("%d\n", cnt); break; } check_stdin(); - case ask_all: + case oldaskconfig: fflush(stdout); fgets(line, 128, stdin); strip(line); @@ -363,9 +365,9 @@ static void conf(struct menu *menu) switch (prop->type) { case P_MENU: - if ((input_mode == ask_silent || - input_mode == dont_ask || - input_mode == dont_ask_dont_tell) && + if ((input_mode == silentoldconfig || + input_mode == nonint_oldconfig || + input_mode == loose_nonint_oldconfig) && rootEntry != menu) { check_conf(menu); return; @@ -424,9 +426,9 @@ static void check_conf(struct menu *menu) if (sym && !sym_has_value(sym)) { if (sym_is_changable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { - if (input_mode == dont_ask || - input_mode == dont_ask_dont_tell) { - if (input_mode == dont_ask && + if (input_mode == nonint_oldconfig || + input_mode == loose_nonint_oldconfig) { + if (input_mode == nonint_oldconfig && sym->name && !sym_is_choice_value(sym)) { if (!unset_variables) fprintf(stderr, "The following" @@ -448,6 +450,20 @@ static void check_conf(struct menu *menu) check_conf(child); } +static struct option long_opts[] = { + {"oldaskconfig", no_argument, NULL, oldaskconfig}, + {"oldconfig", no_argument, NULL, oldconfig}, + {"silentoldconfig", no_argument, NULL, silentoldconfig}, + {"defconfig", optional_argument, NULL, defconfig}, + {"allnoconfig", no_argument, NULL, allnoconfig}, + {"allyesconfig", no_argument, NULL, allyesconfig}, + {"allmodconfig", no_argument, NULL, allmodconfig}, + {"randconfig", no_argument, NULL, randconfig}, + {"nonint_oldconfig", no_argument, NULL, nonint_oldconfig}, + {"loose_nonint_oldconfig", no_argument, NULL, loose_nonint_oldconfig}, + {NULL, 0, NULL, 0} +}; + int main(int ac, char **av) { int opt; @@ -458,38 +474,16 @@ int main(int ac, char **av) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - while ((opt = getopt(ac, av, "osbBdD:nmyrh")) != -1) { + while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) { + input_mode = (enum input_mode)opt; switch (opt) { - case 'o': - input_mode = ask_silent; - break; - case 's': - input_mode = ask_silent; + case silentoldconfig: sync_kconfig = 1; break; - case 'b': - input_mode = dont_ask; - break; - case 'B': - input_mode = dont_ask_dont_tell; - break; - case 'd': - input_mode = set_default; - break; - case 'D': - input_mode = set_default; + case defconfig: defconfig_file = optarg; break; - case 'n': - input_mode = set_no; - break; - case 'm': - input_mode = set_mod; - break; - case 'y': - input_mode = set_yes; - break; - case 'r': + case randconfig: { struct timeval now; unsigned int seed; @@ -502,17 +496,12 @@ int main(int ac, char **av) seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); srand(seed); - - input_mode = set_random; break; } - case 'h': - printf(_("See README for usage info\n")); - exit(0); - break; - default: + case '?': fprintf(stderr, _("See README for usage info\n")); exit(1); + break; } } if (ac == optind) { @@ -537,7 +526,7 @@ int main(int ac, char **av) } switch (input_mode) { - case set_default: + case defconfig: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { @@ -547,27 +536,27 @@ int main(int ac, char **av) exit(1); } break; - case ask_silent: - case ask_all: - case ask_new: - case dont_ask: - case dont_ask_dont_tell: + case silentoldconfig: + case oldaskconfig: + case oldconfig: + case nonint_oldconfig: + case loose_nonint_oldconfig: conf_read(NULL); break; - case set_no: - case set_mod: - case set_yes: - case set_random: + case allnoconfig: + case allyesconfig: + case allmodconfig: + case randconfig: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { - case set_no: name = "allno.config"; break; - case set_mod: name = "allmod.config"; break; - case set_yes: name = "allyes.config"; break; - case set_random: name = "allrandom.config"; break; + case allnoconfig: name = "allno.config"; break; + case allyesconfig: name = "allyes.config"; break; + case allmodconfig: name = "allmod.config"; break; + case randconfig: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) @@ -592,37 +581,37 @@ int main(int ac, char **av) } switch (input_mode) { - case set_no: + case allnoconfig: conf_set_all_new_symbols(def_no); break; - case set_yes: + case allyesconfig: conf_set_all_new_symbols(def_yes); break; - case set_mod: + case allmodconfig: conf_set_all_new_symbols(def_mod); break; - case set_random: + case randconfig: conf_set_all_new_symbols(def_random); break; - case set_default: + case defconfig: conf_set_all_new_symbols(def_default); break; - case ask_new: - case ask_all: + case oldconfig: + case oldaskconfig: rootEntry = &rootmenu; conf(&rootmenu); - input_mode = ask_silent; + input_mode = silentoldconfig; /* fall through */ - case dont_ask: - case dont_ask_dont_tell: - case ask_silent: + case nonint_oldconfig: + case loose_nonint_oldconfig: + case silentoldconfig: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt && - (input_mode != dont_ask && - input_mode != dont_ask_dont_tell)); + (input_mode != nonint_oldconfig && + input_mode != loose_nonint_oldconfig)); break; } @@ -638,7 +627,7 @@ int main(int ac, char **av) fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); return 1; } - } else if (!unset_variables || input_mode != dont_ask) { + } else if (!unset_variables || input_mode != nonint_oldconfig) { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); exit(1); -- cgit v1.2.3-59-g8ed1b From ef61ca88c511154d6bead23c08f9a021cfdfeb01 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:27 +0200 Subject: kconfig: rename loose_nonint_oldconfig => oldnoconfig Rename target to something that fall more in line with the other kconfig targets. oldnoconfig shall read as: - read the old configuration and set all new options to no Signed-off-by: Sam Ravnborg Cc: Aristeu Rozanski Signed-off-by: Michal Marek --- scripts/kconfig/Makefile | 7 +++---- scripts/kconfig/conf.c | 14 +++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 549e50e49cbf..2142afb0a13b 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -90,9 +90,9 @@ PHONY += allnoconfig allyesconfig allmodconfig randconfig allnoconfig allyesconfig allmodconfig randconfig: $(obj)/conf $< --$@ $(Kconfig) -PHONY += nonint_oldconfig loose_nonint_oldconfig defconfig +PHONY += nonint_oldconfig oldnoconfig defconfig -nonint_oldconfig loose_nonint_oldconfig: $(obj)/conf +nonint_oldconfig oldnoconfig: $(obj)/conf $< --$@ $(Kconfig) defconfig: $(obj)/conf @@ -124,8 +124,7 @@ help: @echo ' allnoconfig - New config where all options are answered with no' @echo ' nonint_oldconfig - Checks the current configuration and fails if an option is ' @echo ' not set' - @echo ' loose_nonint_oldconfig - Same as nonint_oldconfig, but updates the config file with ' - @echo ' missing config options as unset' + @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)' # lxdialog stuff check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 2dec584f1268..1f86fca6b07f 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -34,7 +34,7 @@ enum input_mode { randconfig, defconfig, nonint_oldconfig, - loose_nonint_oldconfig, + oldnoconfig, } input_mode = oldaskconfig; char *defconfig_file; @@ -367,7 +367,7 @@ static void conf(struct menu *menu) case P_MENU: if ((input_mode == silentoldconfig || input_mode == nonint_oldconfig || - input_mode == loose_nonint_oldconfig) && + input_mode == oldnoconfig) && rootEntry != menu) { check_conf(menu); return; @@ -427,7 +427,7 @@ static void check_conf(struct menu *menu) if (sym_is_changable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { if (input_mode == nonint_oldconfig || - input_mode == loose_nonint_oldconfig) { + input_mode == oldnoconfig) { if (input_mode == nonint_oldconfig && sym->name && !sym_is_choice_value(sym)) { if (!unset_variables) @@ -460,7 +460,7 @@ static struct option long_opts[] = { {"allmodconfig", no_argument, NULL, allmodconfig}, {"randconfig", no_argument, NULL, randconfig}, {"nonint_oldconfig", no_argument, NULL, nonint_oldconfig}, - {"loose_nonint_oldconfig", no_argument, NULL, loose_nonint_oldconfig}, + {"oldnoconfig", no_argument, NULL, oldnoconfig}, {NULL, 0, NULL, 0} }; @@ -540,7 +540,7 @@ int main(int ac, char **av) case oldaskconfig: case oldconfig: case nonint_oldconfig: - case loose_nonint_oldconfig: + case oldnoconfig: conf_read(NULL); break; case allnoconfig: @@ -603,7 +603,7 @@ int main(int ac, char **av) input_mode = silentoldconfig; /* fall through */ case nonint_oldconfig: - case loose_nonint_oldconfig: + case oldnoconfig: case silentoldconfig: /* Update until a loop caused no more changes */ do { @@ -611,7 +611,7 @@ int main(int ac, char **av) check_conf(&rootmenu); } while (conf_cnt && (input_mode != nonint_oldconfig && - input_mode != loose_nonint_oldconfig)); + input_mode != oldnoconfig)); break; } -- cgit v1.2.3-59-g8ed1b From 861b4ea4cc0eade661480f1ce197ae747f22a918 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:28 +0200 Subject: kconfig: change nonint_oldconfig to listnewconfig Rename to a name that better match the other kconfig targets. listnewconfig shall read as: - list new options compared to current configuration New options are now written to stdout so one can redirect the output. Do not exit with an error code if there is new options. These are feature changes compared to the original nonint_oldconfig - but as this feature has not yet been in a released kernel it should not matter. It is still possible to do: make listnewconfig lookup new config options in Kconfig* edit .config Signed-off-by: Sam Ravnborg Cc: Aristeu Rozanski Acked-by: Aristeu Rozanski Signed-off-by: Michal Marek --- scripts/kconfig/Makefile | 7 +++---- scripts/kconfig/conf.c | 34 +++++++++++----------------------- 2 files changed, 14 insertions(+), 27 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 2142afb0a13b..01bad1bd2550 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -90,9 +90,9 @@ PHONY += allnoconfig allyesconfig allmodconfig randconfig allnoconfig allyesconfig allmodconfig randconfig: $(obj)/conf $< --$@ $(Kconfig) -PHONY += nonint_oldconfig oldnoconfig defconfig +PHONY += listnewconfig oldnoconfig defconfig -nonint_oldconfig oldnoconfig: $(obj)/conf +listnewconfig oldnoconfig: $(obj)/conf $< --$@ $(Kconfig) defconfig: $(obj)/conf @@ -122,8 +122,7 @@ help: @echo ' allmodconfig - New config selecting modules when possible' @echo ' allyesconfig - New config where all options are accepted with yes' @echo ' allnoconfig - New config where all options are answered with no' - @echo ' nonint_oldconfig - Checks the current configuration and fails if an option is ' - @echo ' not set' + @echo ' listnewconfig - List new options' @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)' # lxdialog stuff diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 1f86fca6b07f..ff5c914c0e5c 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -17,10 +17,6 @@ #define LKC_DIRECT_LINK #include "lkc.h" -/* Return codes */ -#define EUNSETOPT 2 /* if -B and -b are used and unset config - * options were found */ - static void conf(struct menu *menu); static void check_conf(struct menu *menu); @@ -33,7 +29,7 @@ enum input_mode { allmodconfig, randconfig, defconfig, - nonint_oldconfig, + listnewconfig, oldnoconfig, } input_mode = oldaskconfig; @@ -45,7 +41,6 @@ static int sync_kconfig; static int conf_cnt; static char line[128]; static struct menu *rootEntry; -static int unset_variables; static void print_help(struct menu *menu) { @@ -366,7 +361,7 @@ static void conf(struct menu *menu) switch (prop->type) { case P_MENU: if ((input_mode == silentoldconfig || - input_mode == nonint_oldconfig || + input_mode == listnewconfig || input_mode == oldnoconfig) && rootEntry != menu) { check_conf(menu); @@ -426,16 +421,9 @@ static void check_conf(struct menu *menu) if (sym && !sym_has_value(sym)) { if (sym_is_changable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { - if (input_mode == nonint_oldconfig || - input_mode == oldnoconfig) { - if (input_mode == nonint_oldconfig && - sym->name && !sym_is_choice_value(sym)) { - if (!unset_variables) - fprintf(stderr, "The following" - " variables are not set:\n"); - fprintf(stderr, "CONFIG_%s\n", - sym->name); - unset_variables++; + if (input_mode == listnewconfig) { + if (sym->name && !sym_is_choice_value(sym)) { + printf("CONFIG_%s\n", sym->name); } } else { if (!conf_cnt++) @@ -459,7 +447,7 @@ static struct option long_opts[] = { {"allyesconfig", no_argument, NULL, allyesconfig}, {"allmodconfig", no_argument, NULL, allmodconfig}, {"randconfig", no_argument, NULL, randconfig}, - {"nonint_oldconfig", no_argument, NULL, nonint_oldconfig}, + {"listnewconfig", no_argument, NULL, listnewconfig}, {"oldnoconfig", no_argument, NULL, oldnoconfig}, {NULL, 0, NULL, 0} }; @@ -539,7 +527,7 @@ int main(int ac, char **av) case silentoldconfig: case oldaskconfig: case oldconfig: - case nonint_oldconfig: + case listnewconfig: case oldnoconfig: conf_read(NULL); break; @@ -602,7 +590,7 @@ int main(int ac, char **av) conf(&rootmenu); input_mode = silentoldconfig; /* fall through */ - case nonint_oldconfig: + case listnewconfig: case oldnoconfig: case silentoldconfig: /* Update until a loop caused no more changes */ @@ -610,7 +598,7 @@ int main(int ac, char **av) conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt && - (input_mode != nonint_oldconfig && + (input_mode != listnewconfig && input_mode != oldnoconfig)); break; } @@ -627,11 +615,11 @@ int main(int ac, char **av) fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); return 1; } - } else if (!unset_variables || input_mode != nonint_oldconfig) { + } else if (input_mode != listnewconfig) { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); exit(1); } } - return unset_variables ? EUNSETOPT : 0; + return 0; } -- cgit v1.2.3-59-g8ed1b From 59e89e3ddf8523be39a8e0a66bacbbdd6a72d069 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:29 +0200 Subject: kconfig: save location of config symbols When we add a new config symbol save the file/line so we later can refer to their location. The information is saved as a property to a config symbol because we may have multiple definitions of the same symbol. This has the side-effect that a symbol always has at least one property. Signed-off-by: Sam Ravnborg Cc: Roman Zippel Signed-off-by: Michal Marek --- scripts/kconfig/expr.h | 1 + scripts/kconfig/menu.c | 2 ++ scripts/kconfig/symbol.c | 2 ++ 3 files changed, 5 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 75a31e4552f3..6ee2e4fb1481 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -132,6 +132,7 @@ enum prop_type { P_SELECT, /* select BAR */ P_RANGE, /* range 7..100 (for a symbol) */ P_ENV, /* value from environment variable */ + P_SYMBOL, /* where a symbol is defined */ }; struct property { diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 11799894f3bd..4fb590247f33 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -58,6 +58,8 @@ void menu_add_entry(struct symbol *sym) *last_entry_ptr = menu; last_entry_ptr = &menu->next; current_entry = menu; + if (sym) + menu_add_symbol(P_SYMBOL, sym, NULL); } void menu_end_entry(void) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index c127fa342f1d..9f180ab7698d 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -961,6 +961,8 @@ const char *prop_get_type_name(enum prop_type type) return "select"; case P_RANGE: return "range"; + case P_SYMBOL: + return "symbol"; case P_UNKNOWN: break; } -- cgit v1.2.3-59-g8ed1b From d595cea62403db4e65b98a8bb96ff2b5205c7b82 Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Sat, 31 Jul 2010 23:35:30 +0200 Subject: kconfig: print more info when we see a recursive dependency Consider following kconfig file: config TEST1 bool "test 1" depends on TEST2 config TEST2 bool "test 2" depends on TEST1 Previously kconfig would report: foo:6:error: found recursive dependency: TEST2 -> TEST1 -> TEST2 With the following patch kconfig reports: foo:5:error: recursive dependency detected! foo:5: symbol TEST2 depends on TEST1 foo:1: symbol TEST1 depends on TEST2 Note that we now report where the offending symbols are defined. This can be a great help for complex situations involving several files. Patch is originally from Roman Zippel with a few adjustments by Sam. Signed-off-by: Sam Ravnborg Cc: Roman Zippel Signed-off-by: Michal Marek --- scripts/kconfig/symbol.c | 142 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 127 insertions(+), 15 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 9f180ab7698d..bc1e1584e2da 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -783,6 +783,110 @@ struct symbol **sym_re_search(const char *pattern) return sym_arr; } +/* + * When we check for recursive dependencies we use a stack to save + * current state so we can print out relevant info to user. + * The entries are located on the call stack so no need to free memory. + * Note inser() remove() must always match to properly clear the stack. + */ +static struct dep_stack { + struct dep_stack *prev, *next; + struct symbol *sym; + struct property *prop; + struct expr *expr; +} *check_top; + +static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) +{ + memset(stack, 0, sizeof(*stack)); + if (check_top) + check_top->next = stack; + stack->prev = check_top; + stack->sym = sym; + check_top = stack; +} + +static void dep_stack_remove(void) +{ + check_top = check_top->prev; + if (check_top) + check_top->next = NULL; +} + +/* + * Called when we have detected a recursive dependency. + * check_top point to the top of the stact so we use + * the ->prev pointer to locate the bottom of the stack. + */ +static void sym_check_print_recursive(struct symbol *last_sym) +{ + struct dep_stack *stack; + struct symbol *sym, *next_sym; + struct menu *menu = NULL; + struct property *prop; + struct dep_stack cv_stack; + + if (sym_is_choice_value(last_sym)) { + dep_stack_insert(&cv_stack, last_sym); + last_sym = prop_get_symbol(sym_get_choice_prop(last_sym)); + } + + for (stack = check_top; stack != NULL; stack = stack->prev) + if (stack->sym == last_sym) + break; + if (!stack) { + fprintf(stderr, "unexpected recursive dependency error\n"); + return; + } + + for (; stack; stack = stack->next) { + sym = stack->sym; + next_sym = stack->next ? stack->next->sym : last_sym; + prop = stack->prop; + + /* for choice values find the menu entry (used below) */ + if (sym_is_choice(sym) || sym_is_choice_value(sym)) { + for (prop = sym->prop; prop; prop = prop->next) { + menu = prop->menu; + if (prop->menu) + break; + } + } + if (stack->sym == last_sym) + fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", + prop->file->name, prop->lineno); + if (stack->expr) { + fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "", + prop_get_type_name(prop->type), + next_sym->name ? next_sym->name : ""); + } else if (stack->prop) { + fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "", + next_sym->name ? next_sym->name : ""); + } else if (sym_is_choice(sym)) { + fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "", + next_sym->name ? next_sym->name : ""); + } else if (sym_is_choice_value(sym)) { + fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "", + next_sym->name ? next_sym->name : ""); + } else { + fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "", + next_sym->name ? next_sym->name : ""); + } + } + + if (check_top == &cv_stack) + dep_stack_remove(); +} static struct symbol *sym_check_expr_deps(struct expr *e) { @@ -819,24 +923,33 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) { struct symbol *sym2; struct property *prop; + struct dep_stack stack; + + dep_stack_insert(&stack, sym); sym2 = sym_check_expr_deps(sym->rev_dep.expr); if (sym2) - return sym2; + goto out; for (prop = sym->prop; prop; prop = prop->next) { if (prop->type == P_CHOICE || prop->type == P_SELECT) continue; + stack.prop = prop; sym2 = sym_check_expr_deps(prop->visible.expr); if (sym2) break; if (prop->type != P_DEFAULT || sym_is_choice(sym)) continue; + stack.expr = prop->expr; sym2 = sym_check_expr_deps(prop->expr); if (sym2) break; + stack.expr = NULL; } +out: + dep_stack_remove(); + return sym2; } @@ -845,6 +958,9 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice) struct symbol *sym, *sym2; struct property *prop; struct expr *e; + struct dep_stack stack; + + dep_stack_insert(&stack, choice); prop = sym_get_choice_prop(choice); expr_list_for_each_sym(prop->expr, e, sym) @@ -858,10 +974,8 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice) expr_list_for_each_sym(prop->expr, e, sym) { sym2 = sym_check_sym_deps(sym); - if (sym2) { - fprintf(stderr, " -> %s", sym->name); + if (sym2) break; - } } out: expr_list_for_each_sym(prop->expr, e, sym) @@ -871,6 +985,8 @@ out: prop_get_symbol(sym_get_choice_prop(sym2)) == choice) sym2 = choice; + dep_stack_remove(); + return sym2; } @@ -880,18 +996,20 @@ struct symbol *sym_check_deps(struct symbol *sym) struct property *prop; if (sym->flags & SYMBOL_CHECK) { - fprintf(stderr, "%s:%d:error: found recursive dependency: %s", - sym->prop->file->name, sym->prop->lineno, - sym->name ? sym->name : ""); + sym_check_print_recursive(sym); return sym; } if (sym->flags & SYMBOL_CHECKED) return NULL; if (sym_is_choice_value(sym)) { + struct dep_stack stack; + /* for choice groups start the check with main choice symbol */ + dep_stack_insert(&stack, sym); prop = sym_get_choice_prop(sym); sym2 = sym_check_deps(prop_get_symbol(prop)); + dep_stack_remove(); } else if (sym_is_choice(sym)) { sym2 = sym_check_choice_deps(sym); } else { @@ -900,14 +1018,8 @@ struct symbol *sym_check_deps(struct symbol *sym) sym->flags &= ~SYMBOL_CHECK; } - if (sym2) { - fprintf(stderr, " -> %s", sym->name ? sym->name : ""); - if (sym2 == sym) { - fprintf(stderr, "\n"); - zconfnerrs++; - sym2 = NULL; - } - } + if (sym2 && sym2 == sym) + sym2 = NULL; return sym2; } -- cgit v1.2.3-59-g8ed1b From 0748cb3e1fbd89c03a98c15e91ad65797981de77 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:31 +0200 Subject: kconfig: add alldefconfig alldefconfig create a configuration with all values set to their default value (form the Kconfig files). This may be useful when we try to use more sensible default values and may also be used in combination with the minimal defconfigs. Signed-off-by: Sam Ravnborg Signed-off-by: Michal Marek --- Documentation/kbuild/kconfig.txt | 2 +- scripts/kconfig/Makefile | 13 +++++++------ scripts/kconfig/conf.c | 7 +++++++ 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/Documentation/kbuild/kconfig.txt b/Documentation/kbuild/kconfig.txt index 49efae703979..0e69dd5f7a05 100644 --- a/Documentation/kbuild/kconfig.txt +++ b/Documentation/kbuild/kconfig.txt @@ -65,7 +65,7 @@ also use the environment variable KCONFIG_ALLCONFIG as a flag or a filename that contains config symbols that the user requires to be set to a specific value. If KCONFIG_ALLCONFIG is used without a filename, "make *config" checks for a file named -"all{yes/mod/no/random}.config" (corresponding to the *config command +"all{yes/mod/no/def/random}.config" (corresponding to the *config command that was used) for symbol values that are to be forced. If this file is not found, it checks for a file named "all.config" to contain forced values. diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 01bad1bd2550..72973591c0f1 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -85,9 +85,9 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h $(Q)rm -f arch/um/Kconfig.arch $(Q)rm -f $(obj)/config.pot -PHONY += allnoconfig allyesconfig allmodconfig randconfig +PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig -allnoconfig allyesconfig allmodconfig randconfig: $(obj)/conf +allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf $< --$@ $(Kconfig) PHONY += listnewconfig oldnoconfig defconfig @@ -117,11 +117,12 @@ help: @echo ' localmodconfig - Update current config disabling modules not loaded' @echo ' localyesconfig - Update current config converting local mods to core' @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' - @echo ' randconfig - New config with random answer to all options' - @echo ' defconfig - New config with default answer to all options' - @echo ' allmodconfig - New config selecting modules when possible' - @echo ' allyesconfig - New config where all options are accepted with yes' + @echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' allnoconfig - New config where all options are answered with no' + @echo ' allyesconfig - New config where all options are accepted with yes' + @echo ' allmodconfig - New config selecting modules when possible' + @echo ' alldefconfig - New config with all symbols set to default' + @echo ' randconfig - New config with random answer to all options' @echo ' listnewconfig - List new options' @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)' diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index ff5c914c0e5c..c8bd33cb3bf7 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -27,6 +27,7 @@ enum input_mode { allnoconfig, allyesconfig, allmodconfig, + alldefconfig, randconfig, defconfig, listnewconfig, @@ -446,6 +447,7 @@ static struct option long_opts[] = { {"allnoconfig", no_argument, NULL, allnoconfig}, {"allyesconfig", no_argument, NULL, allyesconfig}, {"allmodconfig", no_argument, NULL, allmodconfig}, + {"alldefconfig", no_argument, NULL, alldefconfig}, {"randconfig", no_argument, NULL, randconfig}, {"listnewconfig", no_argument, NULL, listnewconfig}, {"oldnoconfig", no_argument, NULL, oldnoconfig}, @@ -534,6 +536,7 @@ int main(int ac, char **av) case allnoconfig: case allyesconfig: case allmodconfig: + case alldefconfig: case randconfig: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { @@ -544,6 +547,7 @@ int main(int ac, char **av) case allnoconfig: name = "allno.config"; break; case allyesconfig: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break; + case alldefconfig: name = "alldef.config"; break; case randconfig: name = "allrandom.config"; break; default: break; } @@ -578,6 +582,9 @@ int main(int ac, char **av) case allmodconfig: conf_set_all_new_symbols(def_mod); break; + case alldefconfig: + conf_set_all_new_symbols(def_default); + break; case randconfig: conf_set_all_new_symbols(def_random); break; -- cgit v1.2.3-59-g8ed1b From c252147de68cf58ba601278481e473dab432cee4 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:32 +0200 Subject: kconfig: refactor code in symbol.c Move logic to determine default for a choice to a separate function. No functional changes. Signed-off-by: Sam Ravnborg Signed-off-by: Michal Marek --- scripts/kconfig/lkc.h | 1 + scripts/kconfig/symbol.c | 46 +++++++++++++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index ce6549cdaccf..755b8190eb64 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -126,6 +126,7 @@ void sym_init(void); void sym_clear_all_valid(void); void sym_set_all_changed(void); void sym_set_changed(struct symbol *sym); +struct symbol *sym_choice_default(struct symbol *sym); struct symbol *sym_check_deps(struct symbol *sym); struct property *prop_alloc(enum prop_type type, struct symbol *sym); struct symbol *prop_get_symbol(struct property *prop); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index bc1e1584e2da..0a013ab3ae27 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -226,22 +226,18 @@ static void sym_calc_visibility(struct symbol *sym) } } -static struct symbol *sym_calc_choice(struct symbol *sym) +/* + * Find the default symbol for a choice. + * First try the default values for the choice symbol + * Next locate the first visible choice value + * Return NULL if none was found + */ +struct symbol *sym_choice_default(struct symbol *sym) { struct symbol *def_sym; struct property *prop; struct expr *e; - /* first calculate all choice values' visibilities */ - prop = sym_get_choice_prop(sym); - expr_list_for_each_sym(prop->expr, e, def_sym) - sym_calc_visibility(def_sym); - - /* is the user choice visible? */ - def_sym = sym->def[S_DEF_USER].val; - if (def_sym && def_sym->visible != no) - return def_sym; - /* any of the defaults visible? */ for_all_defaults(sym, prop) { prop->visible.tri = expr_calc_value(prop->visible.expr); @@ -258,11 +254,35 @@ static struct symbol *sym_calc_choice(struct symbol *sym) if (def_sym->visible != no) return def_sym; - /* no choice? reset tristate value */ - sym->curr.tri = no; + /* failed to locate any defaults */ return NULL; } +static struct symbol *sym_calc_choice(struct symbol *sym) +{ + struct symbol *def_sym; + struct property *prop; + struct expr *e; + + /* first calculate all choice values' visibilities */ + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, def_sym) + sym_calc_visibility(def_sym); + + /* is the user choice visible? */ + def_sym = sym->def[S_DEF_USER].val; + if (def_sym && def_sym->visible != no) + return def_sym; + + def_sym = sym_choice_default(sym); + + if (def_sym == NULL) + /* no choice? reset tristate value */ + sym->curr.tri = no; + + return def_sym; +} + void sym_calc_value(struct symbol *sym) { struct symbol_value newval, oldval; -- cgit v1.2.3-59-g8ed1b From 49192f266ffa187bd7adaf5c2d881f85bd53e0ed Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:33 +0200 Subject: kconfig: code refactoring in confdata.c Add a a few local functions to avoid some code duplication No functional changes. Signed-off-by: Sam Ravnborg Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 137 +++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 67 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 8dce5862550d..583f6405f01d 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -399,15 +399,73 @@ int conf_read(const char *name) return 0; } +/* Write a S_STRING */ +static void conf_write_string(bool headerfile, const char *name, + const char *str, FILE *out) +{ + int l; + if (headerfile) + fprintf(out, "#define CONFIG_%s \"", name); + else + fprintf(out, "CONFIG_%s=\"", name); + + while (1) { + l = strcspn(str, "\"\\"); + if (l) { + fwrite(str, l, 1, out); + str += l; + } + if (!*str) + break; + fprintf(out, "\\%c", *str++); + } + fputs("\"\n", out); +} + +static void conf_write_symbol(struct symbol *sym, enum symbol_type type, + FILE *out, bool write_no) +{ + const char *str; + + switch (type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (sym_get_tristate_value(sym)) { + case no: + if (write_no) + fprintf(out, "# CONFIG_%s is not set\n", sym->name); + break; + case mod: + fprintf(out, "CONFIG_%s=m\n", sym->name); + break; + case yes: + fprintf(out, "CONFIG_%s=y\n", sym->name); + break; + } + break; + case S_STRING: + conf_write_string(false, sym->name, sym_get_string_value(sym), out); + break; + case S_HEX: + case S_INT: + str = sym_get_string_value(sym); + fprintf(out, "CONFIG_%s=%s\n", sym->name, str); + break; + case S_OTHER: + case S_UNKNOWN: + break; + } +} + int conf_write(const char *name) { FILE *out; struct symbol *sym; struct menu *menu; const char *basename; - char dirname[128], tmpname[128], newname[128]; - int type, l; const char *str; + char dirname[128], tmpname[128], newname[128]; + enum symbol_type type; time_t now; int use_timestamp = 1; char *env; @@ -487,50 +545,11 @@ int conf_write(const char *name) if (modules_sym->curr.tri == no) type = S_BOOLEAN; } - switch (type) { - case S_BOOLEAN: - case S_TRISTATE: - switch (sym_get_tristate_value(sym)) { - case no: - fprintf(out, "# CONFIG_%s is not set\n", sym->name); - break; - case mod: - fprintf(out, "CONFIG_%s=m\n", sym->name); - break; - case yes: - fprintf(out, "CONFIG_%s=y\n", sym->name); - break; - } - break; - case S_STRING: - str = sym_get_string_value(sym); - fprintf(out, "CONFIG_%s=\"", sym->name); - while (1) { - l = strcspn(str, "\"\\"); - if (l) { - fwrite(str, l, 1, out); - str += l; - } - if (!*str) - break; - fprintf(out, "\\%c", *str++); - } - fputs("\"\n", out); - break; - case S_HEX: - str = sym_get_string_value(sym); - if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out, "CONFIG_%s=%s\n", sym->name, str); - break; - } - case S_INT: - str = sym_get_string_value(sym); - fprintf(out, "CONFIG_%s=%s\n", sym->name, str); - break; - } + /* Write config symbol to file */ + conf_write_symbol(sym, type, out, true); } - next: +next: if (menu->list) { menu = menu->list; continue; @@ -682,7 +701,7 @@ int conf_write_autoconf(void) const char *name; FILE *out, *tristate, *out_h; time_t now; - int i, l; + int i; sym_clear_all_valid(); @@ -732,6 +751,11 @@ int conf_write_autoconf(void) sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE) || !sym->name) continue; + + /* write symbol to config file */ + conf_write_symbol(sym, sym->type, out, false); + + /* update autoconf and tristate files */ switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: @@ -739,12 +763,10 @@ int conf_write_autoconf(void) case no: break; case mod: - fprintf(out, "CONFIG_%s=m\n", sym->name); fprintf(tristate, "CONFIG_%s=M\n", sym->name); fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); break; case yes: - fprintf(out, "CONFIG_%s=y\n", sym->name); if (sym->type == S_TRISTATE) fprintf(tristate, "CONFIG_%s=Y\n", sym->name); @@ -753,35 +775,16 @@ int conf_write_autoconf(void) } break; case S_STRING: - str = sym_get_string_value(sym); - fprintf(out, "CONFIG_%s=\"", sym->name); - fprintf(out_h, "#define CONFIG_%s \"", sym->name); - while (1) { - l = strcspn(str, "\"\\"); - if (l) { - fwrite(str, l, 1, out); - fwrite(str, l, 1, out_h); - str += l; - } - if (!*str) - break; - fprintf(out, "\\%c", *str); - fprintf(out_h, "\\%c", *str); - str++; - } - fputs("\"\n", out); - fputs("\"\n", out_h); + conf_write_string(true, sym->name, sym_get_string_value(sym), out_h); break; case S_HEX: str = sym_get_string_value(sym); if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out, "CONFIG_%s=%s\n", sym->name, str); fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); break; } case S_INT: str = sym_get_string_value(sym); - fprintf(out, "CONFIG_%s=%s\n", sym->name, str); fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); break; default: -- cgit v1.2.3-59-g8ed1b From 7cf3d73b4360e91b14326632ab1aeda4cb26308d Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:34 +0200 Subject: kconfig: add savedefconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit savedefconfig will save a minimal config to a file named "defconfig". The config symbols are saved in the same order as they appear in the menu structure so it should be possible to map them to the relevant menus if desired. The implementation was tested against several minimal configs for arm which was created using brute-force. There was one regression related to default numbers which had their valid range further limited by another symbol. Sample: config FOO int "foo" default 4 config BAR int "bar" range 0 FOO If FOO is set to 3 then BAR cannot take a value higher than 3. But the current implementation will set BAR equal to 4. This is seldomly used and the final configuration is OK, and the fix was non-trivial. So it was documented in the code and left as is. Signed-off-by: Sam Ravnborg Acked-by: Uwe Kleine-König Signed-off-by: Michal Marek --- scripts/kconfig/Makefile | 6 +++- scripts/kconfig/conf.c | 14 +++++++++ scripts/kconfig/confdata.c | 76 +++++++++++++++++++++++++++++++++++++++++++++ scripts/kconfig/lkc.h | 1 + scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/symbol.c | 74 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 171 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 72973591c0f1..c0e459e2b014 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -90,11 +90,14 @@ PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf $< --$@ $(Kconfig) -PHONY += listnewconfig oldnoconfig defconfig +PHONY += listnewconfig oldnoconfig savedefconfig defconfig listnewconfig oldnoconfig: $(obj)/conf $< --$@ $(Kconfig) +savedefconfig: $(obj)/conf + $< --$@=defconfig $(Kconfig) + defconfig: $(obj)/conf ifeq ($(KBUILD_DEFCONFIG),) $< --defconfig $(Kconfig) @@ -118,6 +121,7 @@ help: @echo ' localyesconfig - Update current config converting local mods to core' @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' @echo ' defconfig - New config with default from ARCH supplied defconfig' + @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' @echo ' allnoconfig - New config where all options are answered with no' @echo ' allyesconfig - New config where all options are accepted with yes' @echo ' allmodconfig - New config selecting modules when possible' diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index c8bd33cb3bf7..010600ef58c0 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -30,6 +30,7 @@ enum input_mode { alldefconfig, randconfig, defconfig, + savedefconfig, listnewconfig, oldnoconfig, } input_mode = oldaskconfig; @@ -444,6 +445,7 @@ static struct option long_opts[] = { {"oldconfig", no_argument, NULL, oldconfig}, {"silentoldconfig", no_argument, NULL, silentoldconfig}, {"defconfig", optional_argument, NULL, defconfig}, + {"savedefconfig", required_argument, NULL, savedefconfig}, {"allnoconfig", no_argument, NULL, allnoconfig}, {"allyesconfig", no_argument, NULL, allyesconfig}, {"allmodconfig", no_argument, NULL, allmodconfig}, @@ -471,6 +473,7 @@ int main(int ac, char **av) sync_kconfig = 1; break; case defconfig: + case savedefconfig: defconfig_file = optarg; break; case randconfig: @@ -526,6 +529,9 @@ int main(int ac, char **av) exit(1); } break; + case savedefconfig: + conf_read(NULL); + break; case silentoldconfig: case oldaskconfig: case oldconfig: @@ -591,6 +597,8 @@ int main(int ac, char **av) case defconfig: conf_set_all_new_symbols(def_default); break; + case savedefconfig: + break; case oldconfig: case oldaskconfig: rootEntry = &rootmenu; @@ -622,6 +630,12 @@ int main(int ac, char **av) fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); return 1; } + } else if (input_mode == savedefconfig) { + if (conf_write_defconfig(defconfig_file)) { + fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"), + defconfig_file); + return 1; + } } else if (input_mode != listnewconfig) { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 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, } } +/* + * Write out a minimal config. + * All values that has default values are skipped as this is redundant. + */ +int conf_write_defconfig(const char *filename) +{ + struct symbol *sym; + struct menu *menu; + FILE *out; + + out = fopen(filename, "w"); + if (!out) + return 1; + + sym_clear_all_valid(); + + /* Traverse all menus to find all relevant symbols */ + menu = rootmenu.list; + + while (menu != NULL) + { + sym = menu->sym; + if (sym == NULL) { + if (!menu_is_visible(menu)) + goto next_menu; + } else if (!sym_is_choice(sym)) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE)) + goto next_menu; + sym->flags &= ~SYMBOL_WRITE; + /* If we cannot change the symbol - skip */ + if (!sym_is_changable(sym)) + goto next_menu; + /* If symbol equals to default value - skip */ + if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0) + goto next_menu; + + /* + * If symbol is a choice value and equals to the + * default for a choice - skip. + * But only if value equal to "y". + */ + if (sym_is_choice_value(sym)) { + struct symbol *cs; + struct symbol *ds; + + cs = prop_get_symbol(sym_get_choice_prop(sym)); + ds = sym_choice_default(cs); + if (sym == ds) { + if ((sym->type == S_BOOLEAN || + sym->type == S_TRISTATE) && + sym_get_tristate_value(sym) == yes) + goto next_menu; + } + } + conf_write_symbol(sym, sym->type, out, true); + } +next_menu: + if (menu->list != NULL) { + menu = menu->list; + } + else if (menu->next != NULL) { + menu = menu->next; + } else { + while ((menu = menu->parent)) { + if (menu->next != NULL) { + menu = menu->next; + break; + } + } + } + } + fclose(out); + return 0; +} + int conf_write(const char *name) { FILE *out; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 755b8190eb64..76db065ed72c 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -127,6 +127,7 @@ void sym_clear_all_valid(void); void sym_set_all_changed(void); void sym_set_changed(struct symbol *sym); struct symbol *sym_choice_default(struct symbol *sym); +const char *sym_get_string_default(struct symbol *sym); struct symbol *sym_check_deps(struct symbol *sym); struct property *prop_alloc(enum prop_type type, struct symbol *sym); struct symbol *prop_get_symbol(struct property *prop); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 7cadcad8233b..9a948c9ce44e 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -3,6 +3,7 @@ P(conf_parse,void,(const char *name)); P(conf_read,int,(const char *name)); P(conf_read_simple,int,(const char *name, int)); +P(conf_write_defconfig,int,(const char *name)); P(conf_write,int,(const char *name)); P(conf_write_autoconf,int,(void)); P(conf_get_changed,bool,(void)); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 0a013ab3ae27..e95718fea355 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -661,6 +661,80 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) return true; } +/* + * Find the default value associated to a symbol. + * For tristate symbol handle the modules=n case + * in which case "m" becomes "y". + * If the symbol does not have any default then fallback + * to the fixed default values. + */ +const char *sym_get_string_default(struct symbol *sym) +{ + struct property *prop; + struct symbol *ds; + const char *str; + tristate val; + + sym_calc_visibility(sym); + sym_calc_value(modules_sym); + val = symbol_no.curr.tri; + str = symbol_empty.curr.val; + + /* If symbol has a default value look it up */ + prop = sym_get_default_prop(sym); + if (prop != NULL) { + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + /* The visibility imay limit the value from yes => mod */ + val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); + break; + default: + /* + * The following fails to handle the situation + * where a default value is further limited by + * the valid range. + */ + ds = prop_get_symbol(prop); + if (ds != NULL) { + sym_calc_value(ds); + str = (const char *)ds->curr.val; + } + } + } + + /* Handle select statements */ + val = EXPR_OR(val, sym->rev_dep.tri); + + /* transpose mod to yes if modules are not enabled */ + if (val == mod) + if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) + val = yes; + + /* transpose mod to yes if type is bool */ + if (sym->type == S_BOOLEAN && val == mod) + val = yes; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (val) { + case no: return "n"; + case mod: return "m"; + case yes: return "y"; + } + case S_INT: + case S_HEX: + return str; + case S_STRING: + return str; + case S_OTHER: + case S_UNKNOWN: + break; + } + return ""; +} + const char *sym_get_string_value(struct symbol *sym) { tristate val; -- cgit v1.2.3-59-g8ed1b