Commit 5447d34b authored by Sam Ravnborg's avatar Sam Ravnborg

kconfig: error out if recursive dependencies are found

Sample:
config FOO
	bool "This is foo"
	depends on BAR

config BAR
	bool "This is bar"
	depends on FOO

This will result in following error message:
error: found recursive dependency: FOO -> BAR -> FOO

And will then exit with exit code equal 1 so make will stop.
Inspired by patch from: Adrian Bunk <bunk@stusta.de>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Cc: Adrian Bunk <bunk@stusta.de>
Cc: Roman Zippel <zippel@linux-m68k.org>
parent 04c58f81
...@@ -786,13 +786,15 @@ static struct symbol *sym_check_expr_deps(struct expr *e) ...@@ -786,13 +786,15 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
return NULL; return NULL;
} }
/* return NULL when dependencies are OK */
struct symbol *sym_check_deps(struct symbol *sym) struct symbol *sym_check_deps(struct symbol *sym)
{ {
struct symbol *sym2; struct symbol *sym2;
struct property *prop; struct property *prop;
if (sym->flags & SYMBOL_CHECK) { if (sym->flags & SYMBOL_CHECK) {
printf("Warning! Found recursive dependency: %s", sym->name); fprintf(stderr, "%s:%d:error: found recursive dependency: %s",
sym->prop->file->name, sym->prop->lineno, sym->name);
return sym; return sym;
} }
if (sym->flags & SYMBOL_CHECKED) if (sym->flags & SYMBOL_CHECKED)
...@@ -816,13 +818,8 @@ struct symbol *sym_check_deps(struct symbol *sym) ...@@ -816,13 +818,8 @@ struct symbol *sym_check_deps(struct symbol *sym)
goto out; goto out;
} }
out: out:
if (sym2) { if (sym2)
printf(" %s", sym->name); fprintf(stderr, " -> %s%s", sym->name, sym2 == sym? "\n": "");
if (sym2 == sym) {
printf("\n");
sym2 = NULL;
}
}
sym->flags &= ~SYMBOL_CHECK; sym->flags &= ~SYMBOL_CHECK;
return sym2; return sym2;
} }
......
...@@ -2132,9 +2132,11 @@ void conf_parse(const char *name) ...@@ -2132,9 +2132,11 @@ void conf_parse(const char *name)
} }
menu_finalize(&rootmenu); menu_finalize(&rootmenu);
for_all_symbols(i, sym) { for_all_symbols(i, sym) {
sym_check_deps(sym); if (sym_check_deps(sym))
zconfnerrs++;
} }
if (zconfnerrs)
exit(1);
sym_set_change_count(1); sym_set_change_count(1);
} }
......
...@@ -501,9 +501,11 @@ void conf_parse(const char *name) ...@@ -501,9 +501,11 @@ void conf_parse(const char *name)
} }
menu_finalize(&rootmenu); menu_finalize(&rootmenu);
for_all_symbols(i, sym) { for_all_symbols(i, sym) {
sym_check_deps(sym); if (sym_check_deps(sym))
zconfnerrs++;
} }
if (zconfnerrs)
exit(1);
sym_set_change_count(1); sym_set_change_count(1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment