Hello,

I am seeking for comments for this topic:

When dealing with creating or maintaining a kernel configuration, one
may have to remember
or even describe why a certain decision for or against a specific
kernel option was taken or
one may just want so save a note about it.

Of course one could write his notes into any note-taking software and
look up the correct, latest, matching notes every time when one is
looking at a kernel configuration for a given kernel, but it's a lot
of paperwork to do this for lots of different configurations and a lot
of documented configuration option decisions or configuration option
notes.

To keep all the notes for all the configuration options of all the
kernel configurations together and allow for easy review of notes
taken, I extended the kernel configuration tools to keep and edit a
one-line comment for each configuration option directly in the .config
file and extended "make xconfig" to allow to embed a QLineEdit line
editor (same as used for editing strings like CONFIG_CMDLINE) for
editing comments.

Example lines of a resulting .config:

CONFIG_EXPERIMENTAL=y
# CONFIG_EXPERIMENTAL comment:Never turn that OFF! Required for kgdb
and NF transparent proxy!
...
CONFIG_MTD_PCMCIA=m
# CONFIG_MTD_PCMCIA comment:Needed for project xyz to access PCMCIA
flash cards as MTD
CONFIG_MTD_BLOCK=m
# CONFIG_MTD_BLOCK comment:Needed to mount filesystems on MTD,
requirement number SS-4711
...
CONFIG_SENSORS_LM87=m
# CONFIG_SENSORS_LM87 comment:TODO: May be useable for reading
temperature on board foo

I guess that gives you the idea. Linux Distributors may find that useful too.

For example, Ubuntu is documenting its kernel configuration decisions here

https://wiki.ubuntu.com/specs/KernelKarmicKernelConfig
https://wiki.ubuntu.com/KernelTeam/2.6.28-2-generic-config
 -> (some configuration setting remarks are included - of course it's
a tedious job to enter comments into a wiki, this page could be
generated from a .config with comments)
https://wiki.ubuntu.com/KernelTeam/2.6.30-5-generic-config (Remarks
column is emtpy though)

As this is not a official submission on lkml (which would forbid HTML
mail anyways), please find the patch attached.

This is for review only to get comments on whether people like to have
such feature in the upstream kernel configuration tools, and is of
course not meant to be complete.

However, it's already stable and used in production to save and review
config option remarks using make xconfig. I edited configuration
remarks heavily over the course of many many hours, resulting in 273
commented kernel configuration remarks for a project I am
collaborating on.

Please send your thoughts!

Thanks,
Bernhard Kaindl

PS: On the question of hidden config options:

The infrastructure keeps all comments it finds, targeted for hidden or
visible options. Of course, you can of course only edit comments for
shown config options.

To edit comments for hidden config options, you unhide the option by
either selecting "Show all" in make xconfig or by making the option
shown by changing the respective other config option which make the
commented config option visible.

Bernhard Kaindl
diff -up linux-2.6.31/scripts/kconfig/confdata.c linux-2.6.31.config/scripts/kconfig/confdata.c
--- linux-2.6.31/scripts/kconfig/confdata.c	2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.config/scripts/kconfig/confdata.c	2009-09-22 13:16:38.000000000 +0200
@@ -225,6 +225,19 @@ load:
 			if (!p)
 				continue;
 			*p++ = 0;
+			if (!strncmp(p, "comment:", 8)) {
+				sym = sym_find(line + 9);
+				if (!sym) {
+					conf_warning("comment for unknown symbol %s found: %s",
+						sym->name, p+8);
+					continue;
+				}
+				sym->comment = strdup(p+8);
+				if (*sym->comment)
+					sym->comment[strlen(sym->comment)-1] = '\0';
+				//fprintf(stderr,"comment for %s found: %s\n", sym->name, sym->comment);
+				continue;
+			}
 			if (strncmp(p, "is not set", 10))
 				continue;
 			if (def == S_DEF_USER) {
@@ -526,6 +539,10 @@ int conf_write(const char *name)
 				break;
 			}
 		}
+		if (sym && sym->comment) {
+			fprintf(stderr,"writing comment for %s: %s\n", sym->name, sym->comment);
+			fprintf(out, "# CONFIG_%s comment:%s\n", sym->name, sym->comment);
+		}
 
 	next:
 		if (menu->list) {
@@ -545,6 +562,8 @@ int conf_write(const char *name)
 
 	if (*tmpname) {
 		strcat(dirname, basename);
+		strcat(dirname, "-");
+		strcat(dirname, ctime(&now));
 		strcat(dirname, ".old");
 		rename(newname, dirname);
 		if (rename(tmpname, newname))
diff -up linux-2.6.31/scripts/kconfig/expr.h linux-2.6.31.config/scripts/kconfig/expr.h
--- linux-2.6.31/scripts/kconfig/expr.h	2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.config/scripts/kconfig/expr.h	2009-09-17 17:35:09.000000000 +0200
@@ -77,6 +77,7 @@ enum {
 struct symbol {
 	struct symbol *next;
 	char *name;
+	char *comment;
 	enum symbol_type type;
 	struct symbol_value curr;
 	struct symbol_value def[S_DEF_COUNT];
diff -up linux-2.6.31/scripts/kconfig/qconf.cc linux-2.6.31.config/scripts/kconfig/qconf.cc
--- linux-2.6.31/scripts/kconfig/qconf.cc	2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.config/scripts/kconfig/qconf.cc	2009-09-22 13:17:27.000000000 +0200
@@ -278,6 +278,62 @@ ConfigItem::~ConfigItem(void)
 	}
 }
 
+ConfigCommentEdit::ConfigCommentEdit(ConfigView* parent)
+	: Parent(parent)
+{
+}
+
+void ConfigCommentEdit::show(ConfigItem* i)
+{
+	item = i;
+	if (item->menu->sym->comment)
+		setText(QString::fromLocal8Bit(item->menu->sym->comment));
+	else
+		setText(QString::null);
+	Parent::show();
+	setFocus();
+}
+void ConfigCommentEdit::savecomment(ConfigItem* i) {
+	// Save String in comment field:
+	if (item && item->menu && item->menu->sym) {
+		if (item->menu->sym->comment)
+			free(item->menu->sym->comment);
+		item->menu->sym->comment = strdup(text().latin1());
+		sym_set_changed(item->menu->sym);
+		sym_add_change_count(1);
+		sym_clear_all_valid();
+	}
+}
+void ConfigCommentEdit::keyPressEvent(QKeyEvent* e)
+{
+	switch (e->key()) {
+	case Qt::Key_Escape:
+		break;
+	case Qt::Key_Return:
+	case Qt::Key_Enter:
+		savecomment(item);
+		parent()->updateList(item);
+		break;
+	case Qt::Key_F11:
+		setText(text() + QString::fromLocal8Bit("NOT USED"));
+		savecomment(item);
+		parent()->list->updateList(item);
+		return;
+	case Qt::Key_F12:
+		setText(text() + QString::fromLocal8Bit("DEFAULT TAKEN"));
+		savecomment(item);
+		parent()->list->updateList(item);
+		return;
+	default:
+		Parent::keyPressEvent(e);
+		savecomment(item);
+		return;
+	}
+	e->accept();
+	parent()->list->setFocus();
+	hide();
+}
+
 ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
 	: Parent(parent)
 {
@@ -668,6 +724,12 @@ void ConfigList::keyPressEvent(QKeyEvent
 			emit menuSelected(menu);
 			break;
 		}
+	case Qt::Key_F11:
+	case Qt::Key_F12:
+	case Qt::Key_C:
+		if (item && item->menu && item->menu->sym && !sym_is_choice(item->menu->sym))
+			parent()->lineEditComment->show(item);
+		break;
 	case Qt::Key_Space:
 		changeValue(item);
 		break;
@@ -682,6 +744,8 @@ void ConfigList::keyPressEvent(QKeyEvent
 		break;
 	default:
 		Parent::keyPressEvent(ev);
+		if (item && item->menu && item->menu->sym && !sym_is_choice(item->menu->sym))
+			parent()->lineEditComment->hide();
 		return;
 	}
 	ev->accept();
@@ -843,6 +907,8 @@ ConfigView::ConfigView(QWidget* parent, 
 	list = new ConfigList(this, name);
 	lineEdit = new ConfigLineEdit(this);
 	lineEdit->hide();
+	lineEditComment = new ConfigCommentEdit(this);
+	lineEditComment->hide();
 
 	this->nextView = viewList;
 	viewList = this;
@@ -1011,23 +1077,40 @@ void ConfigInfoView::symbolInfo(void)
 void ConfigInfoView::menuInfo(void)
 {
 	struct symbol* sym;
-	QString head, debug, help;
+	QString head, debug, help, comment;
 
 	sym = menu->sym;
 	if (sym) {
 		if (menu->prompt) {
-			head += "<big><b>";
-			head += print_filter(_(menu->prompt->text));
-			head += "</b></big>";
 			if (sym->name) {
-				head += " (";
 				if (showDebug())
 					head += QString().sprintf("<a href=\"s%p\">", sym);
+				head += "CONFIG_";
 				head += print_filter(sym->name);
 				if (showDebug())
 					head += "</a>";
-				head += ")";
+				head += " = ";
+				head += print_filter(sym_get_string_value(sym));
+				struct property *defprop = sym_get_default_prop(sym);
+				if (defprop) {
+					head += " - Default: ";
+					expr_print(defprop->expr, expr_print_help, &head, E_NONE);
+				}
+				head += "<br>";
 			}
+			head += "<big><b>";
+			head += print_filter(_(menu->prompt->text));
+			head += "</b></big>";
+				if (sym->comment) {
+					head += "<br>";
+					head += "<big>";
+					head += "<i>";
+					head += QString::fromLocal8Bit(sym->comment);
+					head += "</i>";
+					head += "</big>";
+					printf("New comment string for %s: %s\n",
+						sym->name, sym->comment);
+				}
 		} else if (sym->name) {
 			head += "<big><b>";
 			if (showDebug())
@@ -1063,7 +1146,7 @@ void ConfigInfoView::menuInfo(void)
 	if (showDebug())
 		debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
 
-	setText(head + debug + help);
+	setText(head + comment + debug + help);
 }
 
 QString ConfigInfoView::debug_info(struct symbol *sym)
diff -up linux-2.6.31/scripts/kconfig/qconf.h linux-2.6.31.config/scripts/kconfig/qconf.h
--- linux-2.6.31/scripts/kconfig/qconf.h	2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.config/scripts/kconfig/qconf.h	2009-09-22 13:12:01.000000000 +0200
@@ -29,6 +29,7 @@ class ConfigView;
 class ConfigList;
 class ConfigItem;
 class ConfigLineEdit;
+class ConfigCommentEdit;
 class ConfigMainWindow;
 
 
@@ -56,6 +57,7 @@ public:
 		return (ConfigView*)Parent::parent();
 	}
 	ConfigItem* findConfigItem(struct menu *);
+	void emitMenuChanged(struct menu *menu);
 
 protected:
 	void keyPressEvent(QKeyEvent *e);
@@ -197,6 +199,24 @@ public:
 	bool goParent;
 };
 
+class ConfigCommentEdit : public QLineEdit {
+	Q_OBJECT
+	typedef class QLineEdit Parent;
+public:
+	ConfigCommentEdit(ConfigView* parent);
+	ConfigView* parent(void) const
+	{
+		return (ConfigView*)Parent::parent();
+	}
+	void keyPressEvent(QKeyEvent *e);
+	void show(ConfigItem *i);
+	void update(ConfigItem *i);
+private:
+	void savecomment(ConfigItem *i);
+public:
+	ConfigItem *item;
+};
+
 class ConfigLineEdit : public QLineEdit {
 	Q_OBJECT
 	typedef class QLineEdit Parent;
@@ -239,6 +259,7 @@ signals:
 public:
 	ConfigList* list;
 	ConfigLineEdit* lineEdit;
+	ConfigCommentEdit* lineEditComment;
 
 	static ConfigView* viewList;
 	ConfigView* nextView;
diff -up linux-2.6.31/scripts/kconfig/symbol.c linux-2.6.31.config/scripts/kconfig/symbol.c
--- linux-2.6.31/scripts/kconfig/symbol.c	2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.config/scripts/kconfig/symbol.c	2009-09-18 16:41:01.000000000 +0200
@@ -685,6 +685,7 @@ struct symbol *sym_lookup(const char *na
 	symbol = malloc(sizeof(*symbol));
 	memset(symbol, 0, sizeof(*symbol));
 	symbol->name = new_name;
+	symbol->comment = NULL;
 	symbol->type = S_UNKNOWN;
 	symbol->flags |= flags;
 
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel

Reply via email to