Skip to contentSkip to conversation

Factor Kconfig's prefix and package name

RFC In review Arnaud Lacombe 3 participants 23 messages Aug 16, 2010 – Aug 18, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Factor Kconfig's prefix and package name

Hi,

Many projects are using Kconfig's derivate as their configuration UI. Some of these projects change the default "CONFIG_" prefix for something else. It obliges them to dig in the sources to find and replace all occurences and associated constant. Same goes for package name where when the project ship a C library, messages about a kernel may not be welcome. OOTH, a project may want to limit its changes to be able to re-sync with the kernel's Kconfig and benefits from latest features and bug fixes.

The two next patches factorizes Kconfig's prefix and package name to generic macros defined in `scripts/kconfig/lkc.h'. This allow projects to easily tune Kconfig for their need with trivial source modification.

There may have been similar patches in the past, in which case this message can be silently discarded :)

any comments appreciated !

- Arnaud

Arnaud Lacombe (2):
kbuild: genericizes package name
kbuild: genericizes kbuild's config prefix

 scripts/kconfig/conf.c              |   12 ++++----
 scripts/kconfig/confdata.c          |   48 +++++++++++++++++-----------------
 scripts/kconfig/gconf.c             |    4 +-
 scripts/kconfig/lkc.h               |    7 ++++-
 scripts/kconfig/mconf.c             |   44 ++++++++++++++++----------------
 scripts/kconfig/menu.c              |    2 +-
 scripts/kconfig/nconf.c             |   40 ++++++++++++++---------------
 scripts/kconfig/qconf.cc            |    6 ++--
 scripts/kconfig/zconf.tab.c_shipped |    2 +-
 scripts/kconfig/zconf.y             |    2 +-
 10 files changed, 85 insertions(+), 82 deletions(-)
Signature · 1 line
1.7.2.30.gc37d7.dirty
#1 lore raw

RFC 1/2 kbuild: genericizes package name

---
 scripts/kconfig/conf.c              |   12 ++++++------
 scripts/kconfig/confdata.c          |    8 ++++----
 scripts/kconfig/gconf.c             |    4 ++--
 scripts/kconfig/lkc.h               |    7 ++++++-
 scripts/kconfig/mconf.c             |   34 +++++++++++++++++-----------------
 scripts/kconfig/nconf.c             |   20 +++++++++-----------
 scripts/kconfig/qconf.cc            |    6 +++---
 scripts/kconfig/zconf.tab.c_shipped |    2 +-
 scripts/kconfig/zconf.y             |    2 +-
 9 files changed, 49 insertions(+), 46 deletions(-)
scripts/kconfig/conf.c +6 -6
index 5b7c86e..8233d85 100644
@@ -508,8 +508,8 @@ int main(int ac, char **av)
 		name = conf_get_configname();
 		if (stat(name, &tmpstat)) {
 			fprintf(stderr, _("***\n"
-				"*** You have not yet configured your kernel!\n"
-				"*** (missing kernel config file \"%s\")\n"
+				"*** Configuration file \"%s\" not found!\n"
+				"*** " PACKAGE_LONG " has not yet been configured.\n"
 				"***\n"
 				"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
 				"*** \"make menuconfig\" or \"make xconfig\").\n"
@@ -571,7 +571,7 @@ int main(int ac, char **av)
 			name = getenv("KCONFIG_NOSILENTUPDATE");
 			if (name && *name) {
 				fprintf(stderr,
-					_("\n*** Kernel configuration requires explicit update.\n\n"));
+					_("\n*** " PACKAGE_LONG " configuration requires explicit update.\n\n"));
 				return 1;
 			}
 		}
@@ -623,11 +623,11 @@ int main(int ac, char **av)
 		 * All other commands are only used to generate a config.
 		 */
 		if (conf_get_changed() && conf_write(NULL)) {
-			fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
+			fprintf(stderr, _("\n*** Error during writing of the " PACKAGE_LONG " configuration.\n\n"));
 			exit(1);
 		}
 		if (conf_write_autoconf()) {
-			fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n"));
+			fprintf(stderr, _("\n*** Error during update of the " PACKAGE_LONG " configuration.\n\n"));
 			return 1;
 		}
 	} else if (input_mode == savedefconfig) {
@@ -638,7 +638,7 @@ int main(int ac, char **av)
 		}
 	} else if (input_mode != listnewconfig) {
 		if (conf_write(NULL)) {
-			fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
+			fprintf(stderr, _("\n*** Error during writing of the " PACKAGE_LONG " configuration.\n\n"));
 			exit(1);
 		}
 	}
scripts/kconfig/confdata.c +4 -4
index c39327e..74327c3 100644
@@ -579,7 +579,7 @@ int conf_write(const char *name)
 	if (!out)
 		return 1;
 
-	sym = sym_lookup("KERNELVERSION", 0);
+	sym = sym_lookup("PROJECTVERSION", 0);
 	sym_calc_value(sym);
 	time(&now);
 	env = getenv("KCONFIG_NOTIMESTAMP");
@@ -588,7 +588,7 @@ int conf_write(const char *name)
 
 	fprintf(out, _("#\n"
 		       "# Automatically generated make config: don't edit\n"
-		       "# Linux kernel version: %s\n"
+		       "# " PACKAGE_LONG " version: %s\n"
 		       "%s%s"
 		       "#\n"),
 		     sym_get_string_value(sym),
@@ -807,7 +807,7 @@ int conf_write_autoconf(void)
 	time(&now);
 	fprintf(out, "#\n"
 		     "# Automatically generated make config: don't edit\n"
-		     "# Linux kernel version: %s\n"
+		     "# " PACKAGE_LONG " version: %s\n"
 		     "# %s"
 		     "#\n",
 		     sym_get_string_value(sym), ctime(&now));
@@ -816,7 +816,7 @@ int conf_write_autoconf(void)
 			  "\n");
 	fprintf(out_h, "/*\n"
 		       " * Automatically generated C config: don't edit\n"
-		       " * Linux kernel version: %s\n"
+		       " * " PACKAGE_LONG " version: %s\n"
 		       " * %s"
 		       " */\n"
 		       "#define AUTOCONF_INCLUDED\n",
scripts/kconfig/gconf.c +2 -2
index d669882..0f93dc6 100644
@@ -210,8 +210,8 @@ void init_main_window(const gchar * glade_file)
 					  /*"style", PANGO_STYLE_OBLIQUE, */
 					  NULL);
 
-	sprintf(title, _("Linux Kernel v%s Configuration"),
-		getenv("KERNELVERSION"));
+	sprintf(title, _("%s v%s Configuration"),
+		PACKAGE_LONG, getenv("KERNELVERSION"));
 	gtk_window_set_title(GTK_WINDOW(main_wnd), title);
 
 	gtk_widget_show(main_wnd);
scripts/kconfig/lkc.h +6 -1
index bdf71bd..1fcd756 100644
@@ -31,7 +31,12 @@ extern "C" {
 
 #define SRCTREE "srctree"
 
-#define PACKAGE "linux"
+#define PACKAGE			"linux"
+#define PACKAGE_LONG		"Linux Kernel"
+
+#define KBUILD_PREFIX		"CONFIG_"
+#define KBUILD_PREFIX_LEN	(sizeof(KBUILD_PREFIX) - 1)
+
 #define LOCALEDIR "/usr/share/locale"
 
 #define _(text) gettext(text)
scripts/kconfig/mconf.c +17 -17
index d2f6e05..c2caf0c 100644
@@ -25,10 +25,10 @@
 static const char mconf_readme[] = N_(
 "Overview\n"
 "--------\n"
-"Some kernel features may be built directly into the kernel.\n"
+"Some " PACKAGE_LONG " features may be built directly into it.\n"
 "Some may be made into loadable runtime modules.  Some features\n"
 "may be completely removed altogether.  There are also certain\n"
-"kernel parameters which are not really features, but must be\n"
+PACKAGE_LONG " parameters which are not really features, but must be\n"
 "entered in as decimal or hexadecimal numbers or possibly text.\n"
 "\n"
 "Menu items beginning with following braces represent features that\n"
@@ -117,7 +117,7 @@ static const char mconf_readme[] = N_(
 "-----------------------------\n"
 "Menuconfig supports the use of alternate configuration files for\n"
 "those who, for various reasons, find it necessary to switch\n"
-"between different kernel configurations.\n"
+"between different " PACKAGE_LONG " configurations.\n"
 "\n"
 "At the end of the main menu you will find two options.  One is\n"
 "for saving the current configuration to a file of your choosing.\n"
@@ -150,7 +150,7 @@ static const char mconf_readme[] = N_(
 "\n"
 "Optional personality available\n"
 "------------------------------\n"
-"If you prefer to have all of the kernel options listed in a single\n"
+"If you prefer to have all of the " PACKAGE_LONG " options listed in a single\n"
 "menu, rather than the default multimenu hierarchy, run the menuconfig\n"
 "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
 "\n"
@@ -207,11 +207,11 @@ load_config_text[] = N_(
 	"last retrieved.  Leave blank to abort."),
 load_config_help[] = N_(
 	"\n"
-	"For various reasons, one may wish to keep several different kernel\n"
+	"For various reasons, one may wish to keep several different " PACKAGE_LONG "\n"
 	"configurations available on a single machine.\n"
 	"\n"
 	"If you have saved a previous configuration in a file other than the\n"
-	"kernel's default, entering the name of the file here will allow you\n"
+	PACKAGE_LONG "'s default, entering the name of the file here will allow you\n"
 	"to modify that configuration.\n"
 	"\n"
 	"If you are uncertain, then you have probably never used alternate\n"
@@ -221,7 +221,7 @@ save_config_text[] = N_(
 	"as an alternate.  Leave blank to abort."),
 save_config_help[] = N_(
 	"\n"
-	"For various reasons, one may wish to keep different kernel\n"
+	"For various reasons, one may wish to keep different " PACKAGE_LONG "\n"
 	"configurations available on a single machine.\n"
 	"\n"
 	"Entering a file name here will allow you to later retrieve, modify\n"
@@ -265,9 +265,9 @@ search_help[] = N_(
 	"Only relevant lines are shown.\n"
 	"\n\n"
 	"Search examples:\n"
-	"Examples: USB	=> find all CONFIG_ symbols containing USB\n"
-	"          ^USB => find all CONFIG_ symbols starting with USB\n"
-	"          USB$ => find all CONFIG_ symbols ending with USB\n"
+	"Examples: USB	=> find all " KBUILD_PREFIX " symbols containing USB\n"
+	"          ^USB => find all " KBUILD_PREFIX " symbols starting with USB\n"
+	"          USB$ => find all " KBUILD_PREFIX " symbols ending with USB\n"
 	"\n");
 
 static int indent;
@@ -292,10 +292,10 @@ static void set_config_filename(const char *config_filename)
 	int size;
 	struct symbol *sym;
 
-	sym = sym_lookup("KERNELVERSION", 0);
+	sym = sym_lookup("PROJECTVERSION", 0);
 	sym_calc_value(sym);
 	size = snprintf(menu_backtitle, sizeof(menu_backtitle),
-	                _("%s - Linux Kernel v%s Configuration"),
+	                _("%s - %s v%s Configuration"), PACKAGE_LONG,
 		        config_filename, sym_get_string_value(sym));
 	if (size >= sizeof(menu_backtitle))
 		menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
@@ -834,7 +834,7 @@ int main(int ac, char **av)
 		if (conf_get_changed())
 			res = dialog_yesno(NULL,
 					   _("Do you wish to save your "
-					     "new kernel configuration?\n"
+					     "new configuration?\n"
 					     "<ESC><ESC> to continue."),
 					   6, 60);
 		else
@@ -846,20 +846,20 @@ int main(int ac, char **av)
 	case 0:
 		if (conf_write(filename)) {
 			fprintf(stderr, _("\n\n"
-				"Error during writing of the kernel configuration.\n"
-				"Your kernel configuration changes were NOT saved."
+				"Error while writing of the configuration.\n"
+				"Your " PACKAGE_LONG " configuration changes were NOT saved."
 				"\n\n"));
 			return 1;
 		}
 	case -1:
 		printf(_("\n\n"
-			"*** End of Linux kernel configuration.\n"
+			"*** End of " PACKAGE_LONG " configuration.\n"
 			"*** Execute 'make' to build the kernel or try 'make help'."
 			"\n\n"));
 		break;
 	default:
 		fprintf(stderr, _("\n\n"
-			"Your kernel configuration changes were NOT saved."
+			"Your " PACKAGE_LONG " configuration changes were NOT saved."
 			"\n\n"));
 	}
 
scripts/kconfig/nconf.c +9 -11
index 2ba71bc..f5550a9 100644
@@ -12,10 +12,10 @@
 static const char nconf_readme[] = N_(
 "Overview\n"
 "--------\n"
-"Some kernel features may be built directly into the kernel.\n"
+"Some " PACKAGE_LONG " features may be built directly in it.\n"
 "Some may be made into loadable runtime modules.  Some features\n"
 "may be completely removed altogether.  There are also certain\n"
-"kernel parameters which are not really features, but must be\n"
+PACKAGE_LONG " parameters which are not really features, but must be\n"
 "entered in as decimal or hexadecimal numbers or possibly text.\n"
 "\n"
 "Menu items beginning with following braces represent features that\n"
@@ -695,10 +695,10 @@ static const char *set_config_filename(const char *config_filename)
 	int size;
 	struct symbol *sym;
 
-	sym = sym_lookup("KERNELVERSION", 0);
+	sym = sym_lookup("PROJECTVERSION", 0);
 	sym_calc_value(sym);
 	size = snprintf(menu_backtitle, sizeof(menu_backtitle),
-			_("%s - Linux Kernel v%s Configuration"),
+			_("%s - %s v%s Configuration"), PACKAGE_LONG,
 			config_filename, sym_get_string_value(sym));
 	if (size >= sizeof(menu_backtitle))
 		menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
@@ -739,8 +739,7 @@ static int do_exit(void)
 		return 0;
 	}
 	res = btn_dialog(main_window,
-			_("Do you wish to save your "
-				"new kernel configuration?\n"
+			_("Do you wish to save your new configuration?\n"
 				"<ESC> to cancel and resume nconfig."),
 			2,
 			"   <save>   ",
@@ -759,9 +758,8 @@ static int do_exit(void)
 		if (res)
 			btn_dialog(
 				main_window,
-				_("Error during writing of the kernel "
-				  "configuration.\n"
-				  "Your kernel configuration "
+				_("Error during writing of configuration.\n"
+				  "Your " PACKAGE_LONG " configuration "
 				  "changes were NOT saved."),
 				  1,
 				  "<OK>");
@@ -769,7 +767,7 @@ static int do_exit(void)
 			char buf[1024];
 			snprintf(buf, 1024,
 				_("Configuration written to %s\n"
-				  "End of Linux kernel configuration.\n"
+				  "End of " PACKAGE_LONG " configuration.\n"
 				  "Execute 'make' to build the kernel or try"
 				  " 'make help'."), filename);
 			btn_dialog(
@@ -782,7 +780,7 @@ static int do_exit(void)
 	default:
 		btn_dialog(
 			main_window,
-			_("Your kernel configuration changes were NOT saved."),
+			_("Your " PACKAGE_LONG " configuration changes were NOT saved."),
 			1,
 			"<OK>");
 		break;
scripts/kconfig/qconf.cc +3 -3
index 820df2d..9bcf572 100644
@@ -1263,8 +1263,8 @@ ConfigMainWindow::ConfigMainWindow(void)
 	char title[256];
 
 	QDesktopWidget *d = configApp->desktop();
-	snprintf(title, sizeof(title), _("Linux Kernel v%s Configuration"),
-		getenv("KERNELVERSION"));
+	snprintf(title, sizeof(title), _("%s v%s Configuration"),
+		PACKAGE_LONG, getenv("PROJECTVERSION"));
 	setCaption(title);
 
 	width = configSettings->readNumEntry("/window width", d->width() - 64);
@@ -1633,7 +1633,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
 
 void ConfigMainWindow::showIntro(void)
 {
-	static const QString str = _("Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
+	static const QString str = _("Welcome to the qconf graphical configuration tool for " PACKAGE_LONG ".\n\n"
 		"For each option, a blank box indicates the feature is disabled, a check\n"
 		"indicates it is enabled, and a dot indicates that it is to be compiled\n"
 		"as a module.  Clicking on the box will cycle through the three states.\n\n"
scripts/kconfig/zconf.tab.c_shipped +1 -1
index 32a9eef..b8a7dad 100644
@@ -2224,7 +2224,7 @@ void conf_parse(const char *name)
 	modules_sym = sym_lookup(NULL, 0);
 	modules_sym->type = S_BOOLEAN;
 	modules_sym->flags |= SYMBOL_AUTO;
-	rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
+	rootmenu.prompt = menu_add_prompt(P_MENU, PACKAGE_LONG " Configuration", NULL);
 
 #if YYDEBUG
 	if (getenv("ZCONF_DEBUG"))
scripts/kconfig/zconf.y +1 -1
index 23dfd3b..9dc83e6 100644
@@ -479,7 +479,7 @@ void conf_parse(const char *name)
 	modules_sym = sym_lookup(NULL, 0);
 	modules_sym->type = S_BOOLEAN;
 	modules_sym->flags |= SYMBOL_AUTO;
-	rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
+	rootmenu.prompt = menu_add_prompt(P_MENU, PACKAGE_LONG " Configuration", NULL);
 
 #if YYDEBUG
 	if (getenv("ZCONF_DEBUG"))
Signature · 1 line
1.7.2.30.gc37d7.dirty
#6 lore raw

RFC 2/2 kbuild: genericizes kbuild's config prefix

In reply to Arnaud Lacombe
---
 scripts/kconfig/confdata.c |   40 ++++++++++++++++++++--------------------
 scripts/kconfig/mconf.c    |   10 +++++-----
 scripts/kconfig/menu.c     |    2 +-
 scripts/kconfig/nconf.c    |   20 ++++++++++----------
 4 files changed, 36 insertions(+), 36 deletions(-)
scripts/kconfig/confdata.c +20 -20
index 74327c3..f0f6cdc 100644
@@ -222,22 +222,22 @@ load:
 		sym = NULL;
 		switch (line[0]) {
 		case '#':
-			if (memcmp(line + 2, "CONFIG_", 7))
+			if (memcmp(line + 2, KBUILD_PREFIX, KBUILD_PREFIX_LEN))
 				continue;
-			p = strchr(line + 9, ' ');
+			p = strchr(line + 2 + KBUILD_PREFIX_LEN, ' ');
 			if (!p)
 				continue;
 			*p++ = 0;
 			if (strncmp(p, "is not set", 10))
 				continue;
 			if (def == S_DEF_USER) {
-				sym = sym_find(line + 9);
+				sym = sym_find(line + 2 + KBUILD_PREFIX_LEN);
 				if (!sym) {
 					sym_add_change_count(1);
 					break;
 				}
 			} else {
-				sym = sym_lookup(line + 9, 0);
+				sym = sym_lookup(line + 2 + KBUILD_PREFIX_LEN, 0);
 				if (sym->type == S_UNKNOWN)
 					sym->type = S_BOOLEAN;
 			}
@@ -255,11 +255,11 @@ load:
 			}
 			break;
 		case 'C':
-			if (memcmp(line, "CONFIG_", 7)) {
+			if (memcmp(line, KBUILD_PREFIX, KBUILD_PREFIX_LEN)) {
 				conf_warning("unexpected data");
 				continue;
 			}
-			p = strchr(line + 7, '=');
+			p = strchr(line + KBUILD_PREFIX_LEN, '=');
 			if (!p)
 				continue;
 			*p++ = 0;
@@ -270,13 +270,13 @@ load:
 					*p2 = 0;
 			}
 			if (def == S_DEF_USER) {
-				sym = sym_find(line + 7);
+				sym = sym_find(line + KBUILD_PREFIX_LEN);
 				if (!sym) {
 					sym_add_change_count(1);
 					break;
 				}
 			} else {
-				sym = sym_lookup(line + 7, 0);
+				sym = sym_lookup(line + KBUILD_PREFIX_LEN, 0);
 				if (sym->type == S_UNKNOWN)
 					sym->type = S_OTHER;
 			}
@@ -405,9 +405,9 @@ static void conf_write_string(bool headerfile, const char *name,
 {
 	int l;
 	if (headerfile)
-		fprintf(out, "#define CONFIG_%s \"", name);
+		fprintf(out, "#define " KBUILD_PREFIX "%s \"", name);
 	else
-		fprintf(out, "CONFIG_%s=\"", name);
+		fprintf(out, KBUILD_PREFIX "%s=\"", name);
 
 	while (1) {
 		l = strcspn(str, "\"\\");
@@ -433,13 +433,13 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
 		switch (sym_get_tristate_value(sym)) {
 		case no:
 			if (write_no)
-				fprintf(out, "# CONFIG_%s is not set\n", sym->name);
+				fprintf(out, "# " KBUILD_PREFIX "%s is not set\n", sym->name);
 			break;
 		case mod:
-			fprintf(out, "CONFIG_%s=m\n", sym->name);
+			fprintf(out, KBUILD_PREFIX "%s=m\n", sym->name);
 			break;
 		case yes:
-			fprintf(out, "CONFIG_%s=y\n", sym->name);
+			fprintf(out, KBUILD_PREFIX "%s=y\n", sym->name);
 			break;
 		}
 		break;
@@ -449,7 +449,7 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
 	case S_HEX:
 	case S_INT:
 		str = sym_get_string_value(sym);
-		fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
+		fprintf(out, KBUILD_PREFIX "%s=%s\n", sym->name, str);
 		break;
 	case S_OTHER:
 	case S_UNKNOWN:
@@ -838,14 +838,14 @@ int conf_write_autoconf(void)
 			case no:
 				break;
 			case mod:
-				fprintf(tristate, "CONFIG_%s=M\n", sym->name);
-				fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
+				fprintf(tristate, KBUILD_PREFIX "%s=M\n", sym->name);
+				fprintf(out_h, "#define " KBUILD_PREFIX "%s_MODULE 1\n", sym->name);
 				break;
 			case yes:
 				if (sym->type == S_TRISTATE)
-					fprintf(tristate, "CONFIG_%s=Y\n",
+					fprintf(tristate, KBUILD_PREFIX "%s=Y\n",
 							sym->name);
-				fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
+				fprintf(out_h, "#define " KBUILD_PREFIX "%s 1\n", sym->name);
 				break;
 			}
 			break;
@@ -855,12 +855,12 @@ int conf_write_autoconf(void)
 		case S_HEX:
 			str = sym_get_string_value(sym);
 			if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
-				fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str);
+				fprintf(out_h, "#define " KBUILD_PREFIX "%s 0x%s\n", sym->name, str);
 				break;
 			}
 		case S_INT:
 			str = sym_get_string_value(sym);
-			fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str);
+			fprintf(out_h, "#define " KBUILD_PREFIX "%s %s\n", sym->name, str);
 			break;
 		default:
 			break;
scripts/kconfig/mconf.c +5 -5
index c2caf0c..b9b08cd 100644
@@ -232,7 +232,7 @@ save_config_help[] = N_(
 	"leave this blank.\n"),
 search_help[] = N_(
 	"\n"
-	"Search for CONFIG_ symbols and display their relations.\n"
+	"Search for " KBUILD_PREFIX " symbols and display their relations.\n"
 	"Regular expressions are allowed.\n"
 	"Example: search for \"^FOO\"\n"
 	"Result:\n"
@@ -249,7 +249,7 @@ search_help[] = N_(
 	"Selected by: BAR\n"
 	"-----------------------------------------------------------------\n"
 	"o The line 'Prompt:' shows the text used in the menu structure for\n"
-	"  this CONFIG_ symbol\n"
+	"  this " KBUILD_PREFIX " symbol\n"
 	"o The 'Defined at' line tell at what file / line number the symbol\n"
 	"  is defined\n"
 	"o The 'Depends on:' line tell what symbols needs to be defined for\n"
@@ -316,7 +316,7 @@ static void search_conf(void)
 again:
 	dialog_clear();
 	dres = dialog_inputbox(_("Search Configuration Parameter"),
-			      _("Enter CONFIG_ (sub)string to search for "
+			      _("Enter " KBUILD_PREFIX " (sub)string to search for "
 				"(with or without \"CONFIG\")"),
 			      10, 75, "");
 	switch (dres) {
@@ -329,9 +329,9 @@ again:
 		return;
 	}
 
-	/* strip CONFIG_ if necessary */
+	/* strip the prefix if necessary */
 	dialog_input = dialog_input_result;
-	if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0)
+	if (strncasecmp(dialog_input_result, KBUILD_PREFIX, KBUILD_PREFIX_LEN) == 0)
 		dialog_input += 7;
 
 	sym_arr = sym_re_search(dialog_input);
scripts/kconfig/menu.c +1 -1
index 4fb5902..b4800d8 100644
@@ -566,7 +566,7 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help)
 
 	if (menu_has_help(menu)) {
 		if (sym->name) {
-			str_printf(help, "CONFIG_%s:\n\n", sym->name);
+			str_printf(help, KBUILD_PREFIX "%s:\n\n", sym->name);
 			str_append(help, _(menu_get_help(menu)));
 			str_append(help, "\n");
 		}
scripts/kconfig/nconf.c +10 -10
index f5550a9..6cb19dc 100644
@@ -210,7 +210,7 @@ save_config_help[] = N_(
 "leave this blank.\n"),
 search_help[] = N_(
 "\n"
-"Search for CONFIG_ symbols and display their relations.\n"
+"Search for " KBUILD_PREFIX " symbols and display their relations.\n"
 "Regular expressions are allowed.\n"
 "Example: search for \"^FOO\"\n"
 "Result:\n"
@@ -227,7 +227,7 @@ search_help[] = N_(
 "Selected by: BAR\n"
 "-----------------------------------------------------------------\n"
 "o The line 'Prompt:' shows the text used in the menu structure for\n"
-"  this CONFIG_ symbol\n"
+"  this " KBUILD_PREFIX " symbol\n"
 "o The 'Defined at' line tell at what file / line number the symbol\n"
 "  is defined\n"
 "o The 'Depends on:' line tell what symbols needs to be defined for\n"
@@ -243,9 +243,9 @@ search_help[] = N_(
 "Only relevant lines are shown.\n"
 "\n\n"
 "Search examples:\n"
-"Examples: USB   = > find all CONFIG_ symbols containing USB\n"
-"          ^USB => find all CONFIG_ symbols starting with USB\n"
-"          USB$ => find all CONFIG_ symbols ending with USB\n"
+"Examples: USB   = > find all " KBUILD_PREFIX " symbols containing USB\n"
+"          ^USB => find all " KBUILD_PREFIX " symbols starting with USB\n"
+"          USB$ => find all " KBUILD_PREFIX " symbols ending with USB\n"
 "\n");
 
 struct mitem {
@@ -800,8 +800,8 @@ static void search_conf(void)
 again:
 	dres = dialog_inputbox(main_window,
 			_("Search Configuration Parameter"),
-			_("Enter CONFIG_ (sub)string to search for "
-				"(with or without \"CONFIG\")"),
+			_("Enter " KBUILD_PREFIX " (sub)string to search for "
+				"(with or without \"" KBUILD_PREFIX "\")"),
 			"", dialog_input_result, 99);
 	switch (dres) {
 	case 0:
@@ -814,9 +814,9 @@ again:
 		return;
 	}
 
-	/* strip CONFIG_ if necessary */
+	/* strip the prefix if necessary */
 	dialog_input = dialog_input_result;
-	if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0)
+	if (strncasecmp(dialog_input_result, KBUILD_PREFIX, KBUILD_PREFIX_LEN) == 0)
 		dialog_input += 7;
 
 	sym_arr = sym_re_search(dialog_input);
@@ -1246,7 +1246,7 @@ static void show_help(struct menu *menu)
 
 	if (menu && menu->sym && menu_has_help(menu)) {
 		if (menu->sym->name) {
-			str_printf(&help, "CONFIG_%s:\n\n", menu->sym->name);
+			str_printf(&help, KBUILD_PREFIX "%s:\n\n", menu->sym->name);
 			str_append(&help, _(menu_get_help(menu)));
 			str_append(&help, "\n");
 			get_symbol_str(&help, menu->sym);
Signature · 1 line
1.7.2.30.gc37d7.dirty
#2 lore raw

Re: [RFC 1/2] kbuild: genericizes package name

In reply to Arnaud Lacombe

Dne 16.8.2010 06:54, Arnaud Lacombe napsal(a):

Review

Quoted 2 lines
(quoted diff) +1 -1
-	sym = sym_lookup("KERNELVERSION", 0);
+	sym = sym_lookup("PROJECTVERSION", 0);

The required change to the top-level Makefile is missing. I suggest you rather replace "KERNELVERSION" with a macro defaulting to "KERNELVERSION", so that we don't have to change it in the Makefile and other scripts.

Michal

#3 lore raw

Re: [RFC 1/2] kbuild: genericizes package name

Dne 16.8.2010 13:57, Michal Marek napsal(a):

Quoted 8 lines

Dne 16.8.2010 06:54, Arnaud Lacombe napsal(a):

Review

Quoted 2 lines
(quoted diff) +1 -1
-	sym = sym_lookup("KERNELVERSION", 0);
+	sym = sym_lookup("PROJECTVERSION", 0);

The required change to the top-level Makefile is missing. I suggest you rather replace "KERNELVERSION" with a macro defaulting to "KERNELVERSION", so that we don't have to change it in the Makefile and other scripts.

Maybe a cleaner way would be to use the same syntax as for DEFCONFIG_LIST or MODULES, i.e. mark KERNELVERSION specially in the Kconfig file:

config KERNELVERSION
string
option version env=

and then look for a symbol with this property in kconfig.

Michal

#7 lore raw
In reply to Arnaud Lacombe
Quoted 10 lines · Arnaud Lacombe

Hi,

Many projects are using Kconfig's derivate as their configuration UI. Some of these projects change the default "CONFIG_" prefix for something else. It obliges them to dig in the sources to find and replace all occurences and associated constant. Same goes for package name where when the project ship a C library, messages about a kernel may not be welcome. OOTH, a project may want to limit its changes to be able to re-sync with the kernel's Kconfig and benefits from latest features and bug fixes.

Quoted 8 lines

The two next patches factorizes Kconfig's prefix and package name to generic macros defined in `scripts/kconfig/lkc.h'. This allow projects to easily tune Kconfig for their need with trivial source modification.

There may have been similar patches in the past, in which case this message can be silently discarded :)

any comments appreciated !

Hi Arnaud.

I am very much in favour of getting kconfig less tied into the kernel. We discussed this topic briefly af the buildrrot list the other day, and I am started to look at it too.

What you have done below looks like similar attempts I have seen in the past - and I did not like them then and do not like it now.
I have outlined below there three steps needed as I see it. And I would be very glad for help on two of these.

1) "Kernel" appear in diverse feedback texts
- Re-phrase this to refer to the configuration.
You know that you change the configuration
of kernel/buildroot/ptxdist/whatever and
there is no value of repeating this info in
the feedback texts.
- Re-phrasing have the benefit that once the
translators pick up the new version the
translated text is valied for all users.
This would not be the case if you replace
the project name.

2) References to kernel + version in title in frontends
- Use the (today unused) mainmenu entry to pick up the title.
Consider following example:

mainmenu "Linux kernel configuration v$KERNELVERSION"

config KERNELVERSION
string
option env=KERNELVERSION

With the above exampe we no longer hardcode the title and we use already existing features to get the version from the environment. The expansion of "$KERNELVERSION" to the value of the symbol is something I only see supported by "mainmenu".
- This should also address the cases where we referer to the project name/version in the .config file (see confdata.c).

3) Do not hardcode "CONFIG_"
- I suggest to introduce a single define named "CONFIG_". All the places that hardcode the length should be replaced by strlen(CONFIG_).
- The define should be conditional like this:
#if !defined(CONFIG_)
#define CONFIG_ "CONFIG_"
#endif
In this way other users can just use -DCONFIG_=BR2_ as they prefer.

Your patch #2 needs only small adjustments to implement 3). Please adjust and resend.

Your patch #1 identifies all places where a re-phrase is needed. It would be good if you could give that a try.

I am working on 2) as time permits. It seems doable. I have something ready within a few days/weeks.

Please always cc: Michal Marek on patches touching kconfig. He is the (unofficial) maintainer of kconfig.
We have not heard from Roman Zippel for > one year :-(

Sam

#4 lore raw

Re: [RFC 1/2] kbuild: genericizes package name

In reply to Michal Marek
Quoted 14 lines · Michal Marek

Dne 16.8.2010 13:57, Michal Marek napsal(a):

Quoted 8 lines

Dne 16.8.2010 06:54, Arnaud Lacombe napsal(a):

Review

Quoted 2 lines
(quoted diff) +1 -1
-	sym = sym_lookup("KERNELVERSION", 0);
+	sym = sym_lookup("PROJECTVERSION", 0);

The required change to the top-level Makefile is missing. I suggest you rather replace "KERNELVERSION" with a macro defaulting to "KERNELVERSION", so that we don't have to change it in the Makefile and other scripts.

Maybe a cleaner way would be to use the same syntax as for DEFCONFIG_LIST or MODULES, i.e. mark KERNELVERSION specially in the Kconfig file:

Quoted 5 lines

config KERNELVERSION
string
option version env=

and then look for a symbol with this property in kconfig.

I liked my proposal better - but alas that require some kconfig changes. I would be glad to receive your opinion on the suggested changes before putting too much time on it.

Note: I have not touced upon the "how do external projects build kconfig". I dunno yet what to do there and I consider the other topics more relevant as this will help existing users that have already solved the build stuff.

Sam

#5 lore raw

Re: [RFC 1/2] kbuild: genericizes package name

Dne 16.8.2010 19:26, Sam Ravnborg napsal(a):

Quoted 5 lines · Michal Marek
Quoted 4 lines

Maybe a cleaner way would be to use the same syntax as for DEFCONFIG_LIST or MODULES, i.e. mark KERNELVERSION specially in the Kconfig file:

Quoted 7 lines
Quoted 5 lines

config KERNELVERSION
string
option version env=

and then look for a symbol with this property in kconfig.

I liked my proposal better - but alas that require some kconfig changes.

Support for 'option version' would also require some kconfig changes.

Quoted 2 lines

I would be glad to receive your opinion on the suggested changes before putting too much time on it.

I'm all for rephrasing the texts to not mention "kernel" explicitly. As for how to tackle the KERNELVERSION symbol - I have no strong opinion either way. Both approaches would move the knowledge about the exact symbol name to the Kconfig files, which is good. And the version string is only used in titlebars and banners, so kconfig does not need to know the value. I'd leave it up to Arnaud, whichever he finds easier to implement :-).

Michal

#8 lore raw
In reply to Sam Ravnborg

Hi,

Quoted 12 lines · Sam Ravnborg

Hi Arnaud.

I am very much in favour of getting kconfig less tied into the kernel. We discussed this topic briefly af the buildrrot list the other day, and I am started to look at it too.

What you have done below looks like similar attempts I have seen in the past - and I did not like them then and do not like it now.
I have outlined below there three steps needed as I see it. And I would be very glad for help on two of these.

Quoted 12 lines

1) "Kernel" appear in diverse feedback texts
 - Re-phrase this to refer to the configuration.
   You know that you change the configuration
   of kernel/buildroot/ptxdist/whatever and
   there is no value of repeating this info in
   the feedback texts.
 - Re-phrasing have the benefit that once the
   translators pick up the new version the
   translated text is valied for all users.
   This would not be the case if you replace
   the project name.

sounds good. This would also eliminate the line length problem for hardcoded paragraph.

Quoted 11 lines

2) References to kernel + version in title in frontends
 - Use the (today unused) mainmenu entry to pick up the title.
   Consider following example:

mainmenu "Linux kernel configuration v$KERNELVERSION"

config KERNELVERSION
       string
       option env=KERNELVERSION

Quoted 10 lines

  With the above exampe we no longer hardcode
  the title and we use already existing features
  to get the version from the environment.
  The expansion of "$KERNELVERSION" to the value
  of the symbol is something I only see supported
  by "mainmenu".
 - This should also address the cases where we
  referer to the project name/version in the
  .config file (see confdata.c).

seems a good way to go.

Quoted 10 lines

3) Do not hardcode "CONFIG_"
 - I suggest to introduce a single define named "CONFIG_". All the places that hardcode the length should be replaced by strlen(CONFIG_).
 - The define should be conditional like this:
#if !defined(CONFIG_)
#define CONFIG_ "CONFIG_"
#endif
   In this way other users can just use -DCONFIG_=BR2_ as they prefer.

agreed. the only thing I am not really fond of is that "strlen(...)" is computed at runtime, whereas "sizeof(...)-1" is a build time constant, but this might not be that worth.

Quoted 3 lines

Your patch #2 needs only small adjustments to implement 3). Please adjust and resend.

will do.

Quoted 3 lines

Your patch #1 identifies all places where a re-phrase is needed. It would be good if you could give that a try.

will do.

Quoted 3 lines

I am working on 2) as time permits. It seems doable. I have something ready within a few days/weeks.

ok.

Quoted 4 lines

Please always cc: Michal Marek on patches touching kconfig. He is the (unofficial) maintainer of kconfig.
We have not heard from Roman Zippel for > one year :-(

shouldn't MAINTAINERS be updated to reflect this ?

Thanks,
- Arnaud

#9 lore raw
Quoted 11 lines
Quoted 11 lines

3) Do not hardcode "CONFIG_"
 - I suggest to introduce a single define named "CONFIG_". All the places that hardcode the length should be replaced by strlen(CONFIG_).
 - The define should be conditional like this:
#if !defined(CONFIG_)
#define CONFIG_ "CONFIG_"
#endif
   In this way other users can just use -DCONFIG_=BR2_ as they prefer.

Quoted 3 lines

agreed. the only thing I am not really fond of is that "strlen(...)" is computed at runtime, whereas "sizeof(...)-1" is a build time constant, but this might not be that worth.

gcc will recognize that strlen("CONFIG_") is a constant and will optimize out the call.

Sam

#10 lore raw
In reply to Sam Ravnborg

Hi,

Quoted 11 lines · Sam Ravnborg

2) References to kernel + version in title in frontends
 - Use the (today unused) mainmenu entry to pick up the title.
   Consider following example:

mainmenu "Linux kernel configuration v$KERNELVERSION"

config KERNELVERSION
       string
       option env=KERNELVERSION

actually, this will need to be more tricky as there is not one, but 2 titles:

- "Linux Kernel Configuration" hardcoded in zconf.c
- "Linux Kernel v$KERNELVERSION Configuration" in {g,m,n,q}conf.c

The first prompt does not seem to be easily discardable, and I'm not sure if it can be made dynamical, as we will need to make any substitution only when everything else will have been parsed. In any case I need to dig more in the code...

- Arnaud

ps: Sam, do you mind if I have a look at this ? the rephrasing and prefix substitution will not take that much time.

#11 lore raw
Quoted 16 lines · Arnaud Lacombe

Hi,

Quoted 11 lines · Sam Ravnborg

2) References to kernel + version in title in frontends
 - Use the (today unused) mainmenu entry to pick up the title.
   Consider following example:

mainmenu "Linux kernel configuration v$KERNELVERSION"

config KERNELVERSION
       string
       option env=KERNELVERSION

actually, this will need to be more tricky as there is not one, but 2 titles:

Quoted 7 lines

- "Linux Kernel Configuration" hardcoded in zconf.c
- "Linux Kernel v$KERNELVERSION Configuration" in {g,m,n,q}conf.c

The first prompt does not seem to be easily discardable, and I'm not sure if it can be made dynamical, as we will need to make any substitution only when everything else will have been parsed. In any case I need to dig more in the code...

If you look closer you will see that the prompt in zconf.y is not used at all.

Quoted 5 lines

- Arnaud

ps: Sam, do you mind if I have a look at this ? the rephrasing and prefix substitution will not take that much time.

I would only be happy if you do so, any help is appreciated!

Sam

#12 lore raw

Hi,

Quoted 3 lines · Sam Ravnborg

If you look closer you will see that the prompt in zconf.y is not used at all.

yep, that part is done, now lets have a look to the symbol replacement stuff...

- Arnaud

#13 lore raw

PATCH 1/1 kbuild: implement the `mainmenu' directive

note: the prompt is voluntarily still a bare const char *'. It may need to be represented in a more detailled way, say a struct property'.

---
 scripts/kconfig/lkc.h   |    2 ++
 scripts/kconfig/menu.c  |   23 +++++++++++++++++++++++
 scripts/kconfig/zconf.y |    9 ++++++++-
 3 files changed, 33 insertions(+), 1 deletions(-)
scripts/kconfig/lkc.h +2 -0
index bdf71bd..f00854f 100644
@@ -94,6 +94,8 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
 void kconfig_load(void);
 
 /* menu.c */
+void mainmenu_set_prompt(char *);
+const char *mainmenu_get_prompt(void);
 void _menu_init(void);
 void menu_warn(struct menu *menu, const char *fmt, ...);
 struct menu *menu_add_menu(void);
scripts/kconfig/menu.c +23 -0
index 4fb5902..6aa219e 100644
@@ -38,6 +38,29 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
 	va_end(ap);
 }
 
+static const char *mainmenu_prompt = NULL;
+
+void mainmenu_set_prompt(char *prompt)
+{
+	if (mainmenu_prompt != NULL)
+		fprintf(stderr, "%s:%d:warning: mainmenu redefined\n",
+		    current_file->name, zconf_lineno());
+
+	if (isspace(*prompt)) {
+		fprintf(stderr, "%s:%d:warning: leading whitespace ignored\n",
+		    current_file->name, zconf_lineno());
+		while (isspace(*prompt))
+			prompt++;
+	}
+
+	mainmenu_prompt = prompt;
+}
+
+const char *mainmenu_get_prompt(void)
+{
+	return mainmenu_prompt;
+}
+
 void _menu_init(void)
 {
 	current_entry = current_menu = &rootmenu;
scripts/kconfig/zconf.y +8 -1
index 23dfd3b..18c9a28 100644
@@ -111,7 +111,7 @@ stmt_list:
 	| stmt_list common_stmt
 	| stmt_list choice_stmt
 	| stmt_list menu_stmt
-	| stmt_list T_MAINMENU prompt nl
+	| stmt_list mainmenu_stmt
 	| stmt_list end			{ zconf_error("unexpected end statement"); }
 	| stmt_list T_WORD error T_EOL	{ zconf_error("unknown statement \"%s\"", $2); }
 	| stmt_list option_name error T_EOL
@@ -342,6 +342,13 @@ if_block:
 	| if_block choice_stmt
 ;
 
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU prompt nl
+{
+	mainmenu_set_prompt($2);
+};
+
 /* menu entry */
 
 menu: T_MENU prompt T_EOL
Signature · 1 line
1.7.2.30.gc37d7.dirty
#14 lore raw

PATCH 1/1 kbuild: delay rootmenu prompt initialization

In order to be able to get the mainmenu prompt, the rootmenu's prompt need to be deferred after zconfparse(), but still before menu_finalize().

---
 scripts/kconfig/zconf.y |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
scripts/kconfig/zconf.y +3 -1
index 18c9a28..8788d77 100644
@@ -486,7 +486,6 @@ void conf_parse(const char *name)
 	modules_sym = sym_lookup(NULL, 0);
 	modules_sym->type = S_BOOLEAN;
 	modules_sym->flags |= SYMBOL_AUTO;
-	rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
 
 #if YYDEBUG
 	if (getenv("ZCONF_DEBUG"))
@@ -501,6 +500,9 @@ void conf_parse(const char *name)
 		prop = prop_alloc(P_DEFAULT, modules_sym);
 		prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
 	}
+
+	rootmenu.prompt = menu_add_prompt(P_MENU, mainmenu_get_prompt(), NULL);
+
 	menu_finalize(&rootmenu);
 	for_all_symbols(i, sym) {
 		if (sym_check_deps(sym))
Signature · 1 line
1.7.2.30.gc37d7.dirty
#15 lore raw

Re: [PATCH] kbuild: implement the `mainmenu' directive

In reply to Arnaud Lacombe

Hi,

Quoted 11 lines · Arnaud Lacombe

note: the prompt is voluntarily still a bare const char *'. It may need to be represented in a more detailled way, say a struct property'.

---
 scripts/kconfig/lkc.h   |    2 ++ scripts/kconfig/menu.c  |   23 +++++++++++++++++++++++ scripts/kconfig/zconf.y |    9 ++++++++-

 3 files changed, 33 insertions(+), 1 deletions(-)

this does not change any *_shipped files on purpose. You may have to LKC_GENPARSER=1 for the change to be in effect.

- Arnaud

#22 lore raw
In reply to Sam Ravnborg

Hi,

Quoted 12 lines · Sam Ravnborg

1) "Kernel" appear in diverse feedback texts
 - Re-phrase this to refer to the configuration.
   You know that you change the configuration
   of kernel/buildroot/ptxdist/whatever and
   there is no value of repeating this info in
   the feedback texts.
 - Re-phrasing have the benefit that once the
   translators pick up the new version the
   translated text is valied for all users.
   This would not be the case if you replace
   the project name.

will do tomorrow.

Quoted 11 lines

2) References to kernel + version in title in frontends
 - Use the (today unused) mainmenu entry to pick up the title.
   Consider following example:

mainmenu "Linux kernel configuration v$KERNELVERSION"

config KERNELVERSION
       string
       option env=KERNELVERSION

Quoted 11 lines

  With the above exampe we no longer hardcode
  the title and we use already existing features
  to get the version from the environment.
  The expansion of "$KERNELVERSION" to the value
  of the symbol is something I only see supported
  by "mainmenu".
 - This should also address the cases where we
  referer to the project name/version in the
  .config file (see confdata.c).

a first half has been posted here, the another one is written and has been sent privately (for now, it still needs improvement).

Quoted 10 lines

3) Do not hardcode "CONFIG_"
 - I suggest to introduce a single define named "CONFIG_". All the places that hardcode the length should be replaced by strlen(CONFIG_).
 - The define should be conditional like this:
#if !defined(CONFIG_)
#define CONFIG_ "CONFIG_"
#endif
   In this way other users can just use -DCONFIG_=BR2_ as they prefer.

will do tomorrow.

Beside that, the hardcoded string will need to be removed from {g,m,n,q}conf.c, that should be trivial.

- Arnaud

#16 lore raw

Re: [PATCH] kbuild: implement the `mainmenu' directive

In reply to Arnaud Lacombe
Quoted 29 lines · Arnaud Lacombe

note: the prompt is voluntarily still a bare const char *'. It may need to be represented in a more detailled way, say a struct property'.

---
 scripts/kconfig/lkc.h   |    2 ++
 scripts/kconfig/menu.c  |   23 +++++++++++++++++++++++
 scripts/kconfig/zconf.y |    9 ++++++++-
 3 files changed, 33 insertions(+), 1 deletions(-)
scripts/kconfig/lkc.h +2 -0
index bdf71bd..f00854f 100644
@@ -94,6 +94,8 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
 void kconfig_load(void);
 
 /* menu.c */
+void mainmenu_set_prompt(char *);
+const char *mainmenu_get_prompt(void);
 void _menu_init(void);
 void menu_warn(struct menu *menu, const char *fmt, ...);
 struct menu *menu_add_menu(void);
scripts/kconfig/menu.c +0 -0
index 4fb5902..6aa219e 100644

scripts/kconfig/menu.c static void prop_warn(struct property *prop, const char *fmt, ...) · line 41

Quoted 4 lines
scripts/kconfig/menu.c +1 -0
@@ -38,6 +38,29 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
 	va_end(ap);
 }
 
+static const char *mainmenu_prompt = NULL;

Keep the "Linux Kernel Configuration" default here.

scripts/kconfig/menu.c static void prop_warn(struct property *prop, const char *fmt, ...) · line 47

Quoted 6 lines
scripts/kconfig/menu.c +6 -0
+
+void mainmenu_set_prompt(char *prompt)
+{
+	if (mainmenu_prompt != NULL)
+		fprintf(stderr, "%s:%d:warning: mainmenu redefined\n",
+		    current_file->name, zconf_lineno());

... and do not warn here.

scripts/kconfig/menu.c static void prop_warn(struct property *prop, const char *fmt, ...) · line 54

Quoted 7 lines
scripts/kconfig/menu.c +7 -0
+
+	if (isspace(*prompt)) {
+		fprintf(stderr, "%s:%d:warning: leading whitespace ignored\n",
+		    current_file->name, zconf_lineno());
+		while (isspace(*prompt))
+			prompt++;
+	}

The lexer already eats whitespace I think, so this might not be necessary.

Michal

Quoted 39 lines
scripts/kconfig/menu.c +9 -0
+
+	mainmenu_prompt = prompt;
+}
+
+const char *mainmenu_get_prompt(void)
+{
+	return mainmenu_prompt;
+}
+
 void _menu_init(void)
 {
 	current_entry = current_menu = &rootmenu;
scripts/kconfig/zconf.y +8 -1
index 23dfd3b..18c9a28 100644
@@ -111,7 +111,7 @@ stmt_list:
 	| stmt_list common_stmt
 	| stmt_list choice_stmt
 	| stmt_list menu_stmt
-	| stmt_list T_MAINMENU prompt nl
+	| stmt_list mainmenu_stmt
 	| stmt_list end			{ zconf_error("unexpected end statement"); }
 	| stmt_list T_WORD error T_EOL	{ zconf_error("unknown statement \"%s\"", $2); }
 	| stmt_list option_name error T_EOL
@@ -342,6 +342,13 @@ if_block:
 	| if_block choice_stmt
 ;
 
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU prompt nl
+{
+	mainmenu_set_prompt($2);
+};
+
 /* menu entry */
 
 menu: T_MENU prompt T_EOL
#17 lore raw

Re: [PATCH] kbuild: implement the `mainmenu' directive

Quoted 33 lines · Michal Marek
Quoted 32 lines · Arnaud Lacombe

note: the prompt is voluntarily still a bare const char *'. It may need to be represented in a more detailled way, say a struct property'.

---
 scripts/kconfig/lkc.h   |    2 ++
 scripts/kconfig/menu.c  |   23 +++++++++++++++++++++++
 scripts/kconfig/zconf.y |    9 ++++++++-
 3 files changed, 33 insertions(+), 1 deletions(-)
scripts/kconfig/lkc.h +2 -0
index bdf71bd..f00854f 100644
@@ -94,6 +94,8 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
 void kconfig_load(void);
 
 /* menu.c */
+void mainmenu_set_prompt(char *);
+const char *mainmenu_get_prompt(void);
 void _menu_init(void);
 void menu_warn(struct menu *menu, const char *fmt, ...);
 struct menu *menu_add_menu(void);
scripts/kconfig/menu.c +0 -0
index 4fb5902..6aa219e 100644
@@ -38,6 +38,29 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
 	va_end(ap);
 }
 
Quoted 3 lines

scripts/kconfig/menu.c static void prop_warn(struct property *prop, const char *fmt, ...) · line 41

Quoted 1 line
scripts/kconfig/menu.c +1 -0
+static const char *mainmenu_prompt = NULL;

Keep the "Linux Kernel Configuration" default here.

Or alternative named it "mainmenu" - to give user a hint what this is about.

Quoted 10 lines

scripts/kconfig/menu.c static void prop_warn(struct property *prop, const char *fmt, ...) · line 47

Quoted 7 lines
scripts/kconfig/menu.c +6 -0
+
+void mainmenu_set_prompt(char *prompt)
+{
+	if (mainmenu_prompt != NULL)
+		fprintf(stderr, "%s:%d:warning: mainmenu redefined\n",
+		    current_file->name, zconf_lineno());

... and do not warn here.

Quoted 9 lines

scripts/kconfig/menu.c static void prop_warn(struct property *prop, const char *fmt, ...) · line 54

Quoted 7 lines
scripts/kconfig/menu.c +7 -0
+
+	if (isspace(*prompt)) {
+		fprintf(stderr, "%s:%d:warning: leading whitespace ignored\n",
+		    current_file->name, zconf_lineno());
+		while (isspace(*prompt))
+			prompt++;
+	}

The lexer already eats whitespace I think, so this might not be necessary.

menu_add_prop() does something similar so I think not. But I did not check.

Sam

#19 lore raw

Re: [PATCH] kbuild: implement the `mainmenu' directive

In reply to Arnaud Lacombe
Quoted 2 lines · Arnaud Lacombe

note: the prompt is voluntarily still a bare const char *'. It may need to be represented in a more detailled way, say a struct property'.

I actually attempted to go the "struct property" way. This looks much simpler and I like how straight forward it is.

Quoted 33 lines
---
 scripts/kconfig/lkc.h   |    2 ++
 scripts/kconfig/menu.c  |   23 +++++++++++++++++++++++
 scripts/kconfig/zconf.y |    9 ++++++++-
 3 files changed, 33 insertions(+), 1 deletions(-)
scripts/kconfig/lkc.h +2 -0
index bdf71bd..f00854f 100644
@@ -94,6 +94,8 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
 void kconfig_load(void);
 
 /* menu.c */
+void mainmenu_set_prompt(char *);
+const char *mainmenu_get_prompt(void);
 void _menu_init(void);
 void menu_warn(struct menu *menu, const char *fmt, ...);
 struct menu *menu_add_menu(void);
scripts/kconfig/menu.c +3 -0
index 4fb5902..6aa219e 100644
@@ -38,6 +38,29 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
 	va_end(ap);
 }
 
+static const char *mainmenu_prompt = NULL;
+
+void mainmenu_set_prompt(char *prompt)

scripts/kconfig/menu.c static void prop_warn(struct property *prop, const char *fmt, ...) · line 53

Quoted 10 lines
scripts/kconfig/menu.c +10 -0
+{
+	if (mainmenu_prompt != NULL)
+		fprintf(stderr, "%s:%d:warning: mainmenu redefined\n",
+		    current_file->name, zconf_lineno());
+
+	if (isspace(*prompt)) {
+		fprintf(stderr, "%s:%d:warning: leading whitespace ignored\n",
+		    current_file->name, zconf_lineno());
+		while (isspace(*prompt))
+			prompt++;

Any particular reason not to use menu_warn() ?

Quoted 15 lines
scripts/kconfig/zconf.y +1 -1
@@ -111,7 +111,7 @@ stmt_list:
 	| stmt_list common_stmt
 	| stmt_list choice_stmt
 	| stmt_list menu_stmt
-	| stmt_list T_MAINMENU prompt nl
+	| stmt_list mainmenu_stmt
 	| stmt_list end			{ zconf_error("unexpected end statement"); }
 	| stmt_list T_WORD error T_EOL	{ zconf_error("unknown statement \"%s\"", $2); }
 	| stmt_list option_name error T_EOL
@@ -342,6 +342,13 @@ if_block:
 	| if_block choice_stmt
 ;
 

scripts/kconfig/zconf.y if_block: · line 354

Quoted 10 lines
scripts/kconfig/zconf.y +7 -0
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU prompt nl
+{
+	mainmenu_set_prompt($2);
+};
+
 /* menu entry */
 
 menu: T_MENU prompt T_EOL

When you submit the final patch then please divide it in two. One patch that contains the zconf.y changes (like you do here), and then a subsequent patch that updates the relevant _shipped files. This makes review so much easier.

Sam

#20 lore raw

Re: [PATCH] kbuild: implement the `mainmenu' directive

Hi,

Quoted 2 lines · Sam Ravnborg

Any particular reason not to use menu_warn() ?

I would need a valid `struct menu *' ? same argument for prop_warn() :)

Quoted 5 lines

When you submit the final patch then please divide it in two. One patch that contains the zconf.y changes (like you do here), and then a subsequent patch that updates the relevant _shipped files. This makes review so much easier.

It seemed you were saying you had a patch, quoting what you said in the beginning:

Quoted 3 lines

I actually attempted to go the "struct property" way. This looks much simpler and I like how straight forward it is.

or did I wrongly understood ?

- Arnaud

#21 lore raw

Re: [PATCH] kbuild: implement the `mainmenu' directive

Quoted 12 lines · Arnaud Lacombe

Hi,

Quoted 2 lines · Sam Ravnborg

Any particular reason not to use menu_warn() ?

I would need a valid `struct menu *' ? same argument for prop_warn() :)

Quoted 5 lines

When you submit the final patch then please divide it in two. One patch that contains the zconf.y changes (like you do here), and then a subsequent patch that updates the relevant _shipped files. This makes review so much easier.

Quoted 8 lines

It seemed you were saying you had a patch, quoting what you said in the beginning:

Quoted 3 lines

I actually attempted to go the "struct property" way. This looks much simpler and I like how straight forward it is.

or did I wrongly understood ?

I had a patch but I lost it (read: git reset --hard in the wrong tree). It would be simple to redo.

Sam

#18 lore raw

Re: [PATCH] kbuild: implement the `mainmenu' directive

In reply to Sam Ravnborg

Hi,

Quoted 9 lines · Sam Ravnborg
Quoted 8 lines · Michal Marek
Quoted 6 lines · Arnaud Lacombe

+   if (isspace(*prompt)) {
+           fprintf(stderr, "%s:%d:warning: leading whitespace ignored\n",
+               current_file->name, zconf_lineno());
+           while (isspace(*prompt))
+                   prompt++;
+   }

Quoted 5 lines
Quoted 1 line

The lexer already eats whitespace I think, so this might not be necessary.

menu_add_prop() does something similar so I think not. But I did not check.

The leading whitespace removal have been added explicitly by Roman Zippel:

commit f001f7f89689d3226678ab3986f3a486f54aa069

Author: Roman Zippel <[email protected]>
Date:   Thu Jun 8 22:12:48 2006 -0700

kconfig: warn about leading whitespace for menu prompts

Kconfig does its own indentation of menu prompts, so warn about and ignore leading whitespace. Remove also a few unnecessary newlines after other warning prints.

Not sure if that would still apply for the mainmenu.

- Arnaud