aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2010-06-08 12:25:57 -0400
committerMichal Marek <mmarek@suse.cz>2010-07-02 08:53:09 -0400
commit246cf9c26bf11f2bffbecea6e5bd222eee7b1df8 (patch)
tree29ddd2eaa165dbad9e8760866d782f122f579118 /scripts
parent60c8eca69f7fb2820677a635d921866f66727fcb (diff)
kbuild: Warn on selecting symbols with unmet direct dependencies
The "select" statement in Kconfig files allows the enabling of options even if they have unmet direct dependencies (i.e. "depends on" expands to "no"). Currently, the "depends on" clauses are used in calculating the visibility but they do not affect the reverse dependencies in any way. The patch introduces additional tracking of the "depends on" statements and prints a warning on selecting an option if its direct dependencies are not met. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/expr.h2
-rw-r--r--scripts/kconfig/menu.c5
-rw-r--r--scripts/kconfig/symbol.c18
3 files changed, 25 insertions, 0 deletions
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 891cd9ce9ba2..75a31e4552f3 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -83,6 +83,7 @@ struct symbol {
83 tristate visible; 83 tristate visible;
84 int flags; 84 int flags;
85 struct property *prop; 85 struct property *prop;
86 struct expr_value dir_dep;
86 struct expr_value rev_dep; 87 struct expr_value rev_dep;
87}; 88};
88 89
@@ -163,6 +164,7 @@ struct menu {
163 struct symbol *sym; 164 struct symbol *sym;
164 struct property *prompt; 165 struct property *prompt;
165 struct expr *dep; 166 struct expr *dep;
167 struct expr *dir_dep;
166 unsigned int flags; 168 unsigned int flags;
167 char *help; 169 char *help;
168 struct file *file; 170 struct file *file;
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index eef17bacb6bc..11799894f3bd 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -105,6 +105,7 @@ static struct expr *menu_check_dep(struct expr *e)
105void menu_add_dep(struct expr *dep) 105void menu_add_dep(struct expr *dep)
106{ 106{
107 current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); 107 current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep));
108 current_entry->dir_dep = current_entry->dep;
108} 109}
109 110
110void menu_set_type(int type) 111void menu_set_type(int type)
@@ -288,6 +289,10 @@ void menu_finalize(struct menu *parent)
288 for (menu = parent->list; menu; menu = menu->next) 289 for (menu = parent->list; menu; menu = menu->next)
289 menu_finalize(menu); 290 menu_finalize(menu);
290 } else if (sym) { 291 } else if (sym) {
292 /* ignore inherited dependencies for dir_dep */
293 sym->dir_dep.expr = expr_transform(expr_copy(parent->dir_dep));
294 sym->dir_dep.expr = expr_eliminate_dups(sym->dir_dep.expr);
295
291 basedep = parent->prompt ? parent->prompt->visible.expr : NULL; 296 basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
292 basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); 297 basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
293 basedep = expr_eliminate_dups(expr_transform(basedep)); 298 basedep = expr_eliminate_dups(expr_transform(basedep));
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 2e7a048e0cfc..174b230a52b0 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -205,6 +205,16 @@ static void sym_calc_visibility(struct symbol *sym)
205 } 205 }
206 if (sym_is_choice_value(sym)) 206 if (sym_is_choice_value(sym))
207 return; 207 return;
208 /* defaulting to "yes" if no explicit "depends on" are given */
209 tri = yes;
210 if (sym->dir_dep.expr)
211 tri = expr_calc_value(sym->dir_dep.expr);
212 if (tri == mod)
213 tri = yes;
214 if (sym->dir_dep.tri != tri) {
215 sym->dir_dep.tri = tri;
216 sym_set_changed(sym);
217 }
208 tri = no; 218 tri = no;
209 if (sym->rev_dep.expr) 219 if (sym->rev_dep.expr)
210 tri = expr_calc_value(sym->rev_dep.expr); 220 tri = expr_calc_value(sym->rev_dep.expr);
@@ -321,6 +331,14 @@ void sym_calc_value(struct symbol *sym)
321 } 331 }
322 } 332 }
323 calc_newval: 333 calc_newval:
334 if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
335 fprintf(stderr, "warning: (");
336 expr_fprint(sym->rev_dep.expr, stderr);
337 fprintf(stderr, ") selects %s which has unmet direct dependencies (",
338 sym->name);
339 expr_fprint(sym->dir_dep.expr, stderr);
340 fprintf(stderr, ")\n");
341 }
324 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); 342 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
325 } 343 }
326 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) 344 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)