Hello, [RFC]
When dealing with creating or maintaining a kernel configuration, one may have to describe why a certain option was set and it may be helpful to review the personal remark when revisiting the kernel configuration. To ease the paperwork for that, I've been working on enhancing the config tools keep and edit remarks entered by the user. The following minimalistic patch is intended to show the concept with a minimum amount of code. It: - adds a file ".config-remarks" in which the config infrastructure keeps user remarks and - extends "make config" and "make oldconfig" to show and edit these user remarks. make menuconfig, xconfig and gconfig are also extensible in the same way. I already enabled make xconfig (in a separate patch). Thanks, Bernhard Kaindl Applies against 2.6.32-rc5-git1: diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9960d1c..85b0333 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -160,6 +160,8 @@ static int conf_sym(struct menu *menu) tristate oldval, newval; while (1) { + if (sym->remark) + printf("Remark: %s\n", sym->remark); printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); if (sym->name) printf("(%s) ", sym->name); @@ -221,6 +223,22 @@ static int conf_sym(struct menu *menu) return 0; help: print_help(menu); + if (line[1] == '?') { + char *p; + + if (sym->remark) + printf("Current Remark: %s\n", sym->remark); + printf(" New remark: "); + fgets(line, sizeof(line), stdin); + + if ((p = strchr(line, '\n'))) // search for newline + *p = '\0'; // zero it + if (line[0]) { + if (sym->remark) + free(sym->remark); + sym->remark = strdup(line); + } + } } } diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index b55e72f..db30561 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -152,6 +152,43 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) return 0; } +int conf_read_remarks(const char *name) +{ + FILE *in; + char line[1024], *p, *p2; + struct symbol *sym; + + if (!name) + return 1; + in = zconf_fopen(name); // open the right file + if (!in) + return 1; + + conf_filename = name; // for conf_warning() + conf_lineno = 0; // for conf_warning() + + while (fgets(line, sizeof(line), in)) { + conf_lineno++; // for conf_warning() + if (!(p = strchr(line, ' '))) // search for space + continue; // ignore other lines + *p++ = 0; // zero it out + if ((p2 = strchr(p, '\n'))) // search for newline + *p2 = '\0'; // zero it out + sym = sym_find(line); // find the matching sym + if (!sym) { + conf_warning("unknown: %s %s", line, p); + continue; + } + printf("got: %s remark: %s\n", line, p); + sym->remark = strdup(p); + + } + fclose(in); + + return 0; +} + + int conf_read_simple(const char *name, int def) { FILE *in = NULL; @@ -393,12 +430,13 @@ int conf_read(const char *name) sym_add_change_count(conf_warnings || conf_unsaved); + conf_read_remarks(".config-remarks"); return 0; } int conf_write(const char *name) { - FILE *out; + FILE *out, *out_remarks; struct symbol *sym; struct menu *menu; const char *basename; @@ -443,6 +481,10 @@ int conf_write(const char *name) if (!out) return 1; + out_remarks = fopen(".config-remarks.tmp", "w"); // to be done like above + if (!out_remarks) + return 1; + sym = sym_lookup("KERNELVERSION", 0); sym_calc_value(sym); time(&now); @@ -526,6 +568,8 @@ int conf_write(const char *name) break; } } + if (sym && sym->remark) + fprintf(out_remarks, "%s %s\n", sym->name, sym->remark); next: if (menu->list) { @@ -550,6 +594,7 @@ int conf_write(const char *name) if (rename(tmpname, newname)) return 1; } + rename(".config-remarks.tmp", ".config-remarks"); printf(_("#\n" "# configuration written to %s\n" diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 6408fef..217e8cb 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -77,6 +77,7 @@ enum { struct symbol { struct symbol *next; char *name; + char *remark; enum symbol_type type; struct symbol_value curr; struct symbol_value def[S_DEF_COUNT]; ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) 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 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ kbuild-devel mailing list kbuild-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kbuild-devel