public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Lacombe <lacombar@gmail.com>
To: linux-kbuild@vger.kernel.org
Cc: Michal Marek <mmarek@suse.cz>, Arnaud Lacombe <lacombar@gmail.com>
Subject: [RFC] kconfig: zconfdump() clean-up
Date: Mon, 16 May 2011 00:06:35 -0400	[thread overview]
Message-ID: <1305518795-9360-1-git-send-email-lacombar@gmail.com> (raw)

Hi Michal,

The following patch is a summarize of changes I made in zconfdump() last week
when debugging Yann's multiple choice issue. This might help debugging a bit,
espectially by exposing the tree depth.

Considering the following Kconfig:

config A
   bool "A"
if A
choice C
   bool "C"
config C1
   bool "C1"
config C2
   bool "C2"
endchoice
endif # A

config B
   bool "B"
   depends on ! A
if B
choice C
   bool "C"
config C1
   bool "C1"
config C2
   bool "C2"
endchoice
endif # A

It generates the following output, after menu_finalize():

config A
  boolean
  symbol 
  prompt "A"

        choice C
          boolean
          symbol 
          #choice 
          prompt "C" if A

                config C1
                  boolean
                  symbol 
                  prompt "C1" if C
                  #choice 

                config C2
                  boolean
                  symbol 
                  prompt "C2" if C
                  #choice 

        endchoice

        config B
          boolean
          symbol 
          prompt "B" if !A

                choice C
                  boolean
                  symbol 
                  #choice 
                  prompt "C" if B

                        config C1
                          boolean
                          symbol 
                          prompt "C1" if C

                        config C2
                          boolean
                          symbol 
                          prompt "C2" if C

                endchoice

instead of:

config A
  boolean
  unknown prop 9!
  prompt "A"

choice
  boolean
  unknown prop 9!
  #choice value
  prompt "C" if A

config C1
  boolean
  unknown prop 9!
  prompt "C1" if C
  #choice value

config C2
  boolean
  unknown prop 9!
  prompt "C2" if C
  #choice value

config B
  boolean
  unknown prop 9!
  prompt "B" if !A

choice
  boolean
  unknown prop 9!
  #choice value
  prompt "C" if B

config C1
  boolean
  unknown prop 9!
  prompt "C1" if C

config C2
  boolean
  unknown prop 9!
  prompt "C2" if C

endmenu

Broken down patches are available at:

https://github.com/lacombar/linux-2.6/tree/kconfig-zconfdump

Not for merge for now, even if it merges fine with your kbuild/kconfig's tip.

Regards,
 - Arnaud

---
 scripts/kconfig/zconf.y |  161 +++++++++++++++++++----------------------------
 1 files changed, 66 insertions(+), 95 deletions(-)

diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 237ae2a..f18bc5a 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -612,129 +612,100 @@ static void print_quoted_string(FILE *out, const char *str)
 	putc('"', out);
 }
 
-static void print_symbol(FILE *out, struct menu *menu)
+static int indent;
+
+static void print_property(FILE *out, struct property *prop)
 {
-	struct symbol *sym = menu->sym;
-	struct property *prop;
+	const char *prop_string;
 
-	if (sym_is_choice(sym))
-		fprintf(out, "\nchoice\n");
-	else
-		fprintf(out, "\nconfig %s\n", sym->name);
-	switch (sym->type) {
-	case S_BOOLEAN:
-		fputs("  boolean\n", out);
-		break;
-	case S_TRISTATE:
-		fputs("  tristate\n", out);
+	prop_string = prop_get_type_name(prop->type);
+	if (prop_string == NULL)
+		return;
+
+	fprintf(out, "%*s  %s%s ", indent * 8, "",
+	    (prop->type == P_CHOICE) ? "#" : "",
+	    prop_string);
+
+	switch (prop->type) {
+	case P_PROMPT:
+		print_quoted_string(out, prop->text);
+		if (!expr_is_yes(prop->visible.expr)) {
+			fputs(" if ", out);
+			expr_fprint(prop->visible.expr, out);
+		}
 		break;
-	case S_STRING:
-		fputs("  string\n", out);
+	case P_DEFAULT:
+		expr_fprint(prop->expr, out);
+		if (!expr_is_yes(prop->visible.expr)) {
+			fputs(" if ", out);
+			expr_fprint(prop->visible.expr, out);
+		}
 		break;
-	case S_INT:
-		fputs("  integer\n", out);
+	case P_SELECT:
+	case P_RANGE:
+		expr_fprint(prop->expr, out);
 		break;
-	case S_HEX:
-		fputs("  hex\n", out);
+	case P_MENU:
+	case P_COMMENT:
+		print_quoted_string(out, prop->text);
 		break;
 	default:
-		fputs("  ???\n", out);
 		break;
 	}
+	fprintf(out, "\n");
+}
+
+static void print_symbol(FILE *out, struct menu *menu)
+{
+	struct symbol *sym = menu->sym;
+	struct property *prop;
+
+	fprintf(out, "%*s%s %s\n", indent * 8, "",
+	    (sym_is_choice(sym)) ? "choice" : "config",
+	    (sym->name) ? sym->name: "");
+	fprintf(out, "%*s  %s\n", indent * 8, "",
+	    sym_type_name(sym->type));
+
 	for (prop = sym->prop; prop; prop = prop->next) {
 		if (prop->menu != menu)
 			continue;
-		switch (prop->type) {
-		case P_PROMPT:
-			fputs("  prompt ", out);
-			print_quoted_string(out, prop->text);
-			if (!expr_is_yes(prop->visible.expr)) {
-				fputs(" if ", out);
-				expr_fprint(prop->visible.expr, out);
-			}
-			fputc('\n', out);
-			break;
-		case P_DEFAULT:
-			fputs( "  default ", out);
-			expr_fprint(prop->expr, out);
-			if (!expr_is_yes(prop->visible.expr)) {
-				fputs(" if ", out);
-				expr_fprint(prop->visible.expr, out);
-			}
-			fputc('\n', out);
-			break;
-		case P_CHOICE:
-			fputs("  #choice value\n", out);
-			break;
-		case P_SELECT:
-			fputs( "  select ", out);
-			expr_fprint(prop->expr, out);
-			fputc('\n', out);
-			break;
-		case P_RANGE:
-			fputs( "  range ", out);
-			expr_fprint(prop->expr, out);
-			fputc('\n', out);
-			break;
-		case P_MENU:
-			fputs( "  menu ", out);
-			print_quoted_string(out, prop->text);
-			fputc('\n', out);
-			break;
-		case P_SYMBOL:
-			break;
-		default:
-			fprintf(out, "  unknown prop %d!\n", prop->type);
-			break;
-		}
-	}
-	if (menu->help) {
-		int len = strlen(menu->help);
-		while (menu->help[--len] == '\n')
-			menu->help[len] = 0;
-		fprintf(out, "  help\n%s\n", menu->help);
+		print_property(out, prop);
 	}
+	fprintf(out, "\n");
 }
 
 void zconfdump(FILE *out)
 {
-	struct property *prop;
-	struct symbol *sym;
 	struct menu *menu;
 
 	menu = rootmenu.list;
 	while (menu) {
-		if ((sym = menu->sym))
+		if (menu->sym)
 			print_symbol(out, menu);
-		else if ((prop = menu->prompt)) {
-			switch (prop->type) {
-			case P_COMMENT:
-				fputs("\ncomment ", out);
-				print_quoted_string(out, prop->text);
-				fputs("\n", out);
-				break;
-			case P_MENU:
-				fputs("\nmenu ", out);
-				print_quoted_string(out, prop->text);
-				fputs("\n", out);
-				break;
-			default:
-				;
-			}
-			if (!expr_is_yes(prop->visible.expr)) {
-				fputs("  depends ", out);
-				expr_fprint(prop->visible.expr, out);
-				fputc('\n', out);
-			}
+
+		if (menu->help) {
+			int len = strlen(menu->help);
+			while (menu->help[--len] == '\n')
+				menu->help[len] = 0;
+			fprintf(out, "%*s  help\n%s\n", indent * 8, "",
+			    menu->help);
 		}
 
-		if (menu->list)
+		if (menu->list) {
+			indent++;
 			menu = menu->list;
+		}
 		else if (menu->next)
 			menu = menu->next;
 		else while ((menu = menu->parent)) {
-			if (menu->prompt && menu->prompt->type == P_MENU)
-				fputs("\nendmenu\n", out);
+			if (menu != &rootmenu)
+				indent--;
+			fprintf(out, "%*s", indent * 8, "");
+			if (menu->sym && sym_is_choice(menu->sym))
+				fprintf(out, "endchoice\n\n");
+			if (menu->prompt && menu->prompt->type == P_MENU &&
+			    menu != &rootmenu)
+				fprintf(out, "endmenu\n\n");
 			if (menu->next) {
 				menu = menu->next;
 				break;
-- 
1.7.3.4.574.g608b.dirty


             reply	other threads:[~2011-05-16  4:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-16  4:06 Arnaud Lacombe [this message]
2011-05-16  4:07 ` [RFC] kconfig: zconfdump() clean-up Arnaud Lacombe
2011-05-31  1:24 ` Arnaud Lacombe
2011-06-08  5:05   ` Arnaud Lacombe
2011-06-24 14:08 ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305518795-9360-1-git-send-email-lacombar@gmail.com \
    --to=lacombar@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=mmarek@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox