From patchwork Wed Mar 9 02:32:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 456 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:42:46 -0000 Delivered-To: patches@linaro.org Received: by 10.224.60.68 with SMTP id o4cs45644qah; Tue, 8 Mar 2011 18:33:02 -0800 (PST) Received: by 10.43.64.82 with SMTP id xh18mr7649485icb.65.1299637981841; Tue, 08 Mar 2011 18:33:01 -0800 (PST) Received: from e39.co.us.ibm.com (e39.co.us.ibm.com [32.97.110.160]) by mx.google.com with ESMTPS id vr10si3515864icb.84.2011.03.08.18.33.01 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Mar 2011 18:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.160 as permitted sender) client-ip=32.97.110.160; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.160 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e39.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p292K7T0011263; Tue, 8 Mar 2011 19:20:07 -0700 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id p292WvWW117002; Tue, 8 Mar 2011 19:32:57 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p292WvNx015212; Tue, 8 Mar 2011 19:32:57 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p292WvZG015206; Tue, 8 Mar 2011 19:32:57 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id E503E1E750E; Tue, 8 Mar 2011 18:32:56 -0800 (PST) From: John Stultz To: linaro-dev@lists.linaro.org Cc: John Stultz , Grant Likely , Jason Hui , patches@linaro.org Subject: [PATCH 01/12] kbuild: Allow configs from choice blocks to be selected. Date: Tue, 8 Mar 2011 18:32:35 -0800 Message-Id: <1299637966-18458-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1299637966-18458-1-git-send-email-john.stultz@linaro.org> References: <1299637966-18458-1-git-send-email-john.stultz@linaro.org> In looking at trying to replace defconfigs with kconfig fragments, one limitation identified is that config items in choice blocks cannot be selected by other config options. One way to doge this would be to create non-visible meta options that change the choice block's default, but that would require additional meta-configs per-choice config, plus a conditional default per meta-config. That just seemed too ugly. So I looked into how to allow the choice default to be overrided by a select statment, and the following patch is the result. I'm very new to kconfig code, so I expect that my changes are probably broken in some subtle way, but in my testing it seems to work. The select only chagnes the default, which can be overrided by the user via the menu. This allows kconfig fragments to work for make defconfig, while not restricting user customization. Thoughts and feedback (or alternate approaches) would be appreciated. thanks -john CC: Grant Likely CC: Jason Hui CC: patches@linaro.org Signed-off-by: John Stultz --- scripts/kconfig/symbol.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index af6e9f3..c4f3e49 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -203,8 +203,6 @@ static void sym_calc_visibility(struct symbol *sym) sym->visible = tri; sym_set_changed(sym); } - if (sym_is_choice_value(sym)) - return; /* defaulting to "yes" if no explicit "depends on" are given */ tri = yes; if (sym->dir_dep.expr) @@ -235,9 +233,22 @@ static void sym_calc_visibility(struct symbol *sym) struct symbol *sym_choice_default(struct symbol *sym) { struct symbol *def_sym; + struct symbol *ret = NULL; struct property *prop; struct expr *e; + /* check to see if any are selected */ + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, def_sym) + if (def_sym->rev_dep.tri != no) { + if (ret) + printf("Error! Conflicting selects! %s\n", def_sym->name); + else + ret = def_sym; + } + if (ret) + return ret; + /* any of the defaults visible? */ for_all_defaults(sym, prop) { prop->visible.tri = expr_calc_value(prop->visible.expr);