From patchwork Sat Nov 6 21:30:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Lacombe X-Patchwork-Id: 4804 Return-path: Envelope-to: mchehab@gaivota Delivery-date: Sat, 06 Nov 2010 17:34:31 -0400 Received: from mchehab by gaivota with local (Exim 4.72) (envelope-from ) id 1PEqP9-0004LD-4t for mchehab@gaivota; Sat, 06 Nov 2010 17:34:31 -0400 Received: from casper.infradead.org [85.118.1.10] by gaivota with IMAP (fetchmail-6.3.17) for (single-drop); Sat, 06 Nov 2010 17:34:31 -0400 (EDT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PEqOL-00031d-Cu; Sat, 06 Nov 2010 21:33:41 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753700Ab0KFVdh (ORCPT + 1 other); Sat, 6 Nov 2010 17:33:37 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:44901 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866Ab0KFVdg (ORCPT ); Sat, 6 Nov 2010 17:33:36 -0400 Received: by mail-yw0-f46.google.com with SMTP id 21so2768458ywc.19 for ; Sat, 06 Nov 2010 14:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=L/z7eDKTngwU93I8VvJ2HqAkAty/TAoSm5BJX0T8qGw=; b=XcggKpE3fCSHDPDQW764XtJpsjaGusLsWcPk7ztGXBHj0PvsQ5b7Dzp9WNocF2NbCd N85fditalkx+Bf8WBImcQRQwxRx2dWTt6qP1zv117ZP7BZHC3OEdhK9gC98RmlEmXp+V UDuqTqUhygGGZzxhOqTpxIfQnzfaxyVykYVVI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=mXuovlrrn+0cgWwbtqbTDrgptRd/S4e0euTbi9BkFEIt3rAqUHgc4xrXG6QEwaxET1 ibcQ+m4lclF/aePP4Ul6DINsuAEZnMh/NfSP5LeSEngF6M1J/OQUxkvP4NUo6wGvByYY ia5y6QFSmWGpb2LORBaFoQhl2IjojliOptyr8= Received: by 10.150.58.3 with SMTP id g3mr5814573yba.391.1289079216422; Sat, 06 Nov 2010 14:33:36 -0700 (PDT) Received: from localhost.localdomain (76-10-183-171.dsl.teksavvy.com [76.10.183.171]) by mx.google.com with ESMTPS id l66sm2200877yhd.20.2010.11.06.14.33.33 (version=SSLv3 cipher=RC4-MD5); Sat, 06 Nov 2010 14:33:35 -0700 (PDT) From: Arnaud Lacombe To: linux-kbuild@vger.kernel.org, linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Michal Marek , Arnaud Lacombe Subject: [PATCH 1/5] kconfig: add an option to determine a menu's visibility Date: Sat, 6 Nov 2010 17:30:23 -0400 Message-Id: <1289079027-3037-2-git-send-email-lacombar@gmail.com> X-Mailer: git-send-email 1.7.2.30.gc37d7.dirty In-Reply-To: <4CD300AC.3010708@redhat.com> References: <4CD300AC.3010708@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Mauro Carvalho Chehab This option is aimed to add the possibility to control a menu's visibility without adding dependency to the expression to all the submenu. Signed-off-by: Arnaud Lacombe Acked-by: Mauro Carvalho Chehab Tested-by: Mauro Carvalho Chehab --- scripts/kconfig/expr.h | 1 + scripts/kconfig/lkc.h | 1 + scripts/kconfig/menu.c | 11 +++++++++++ scripts/kconfig/zconf.gperf | 1 + scripts/kconfig/zconf.y | 21 ++++++++++++++++++--- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 184eb6a..e57826c 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -164,6 +164,7 @@ struct menu { struct menu *list; struct symbol *sym; struct property *prompt; + struct expr *visibility; struct expr *dep; unsigned int flags; char *help; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 753cdbd..3f7240d 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -107,6 +107,7 @@ void menu_end_menu(void); void menu_add_entry(struct symbol *sym); void menu_end_entry(void); void menu_add_dep(struct expr *dep); +void menu_add_visibility(struct expr *dep); struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 7e83aef..b9d9aa1 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -152,6 +152,12 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr return menu_add_prop(type, prompt, NULL, dep); } +void menu_add_visibility(struct expr *expr) +{ + current_entry->visibility = expr_alloc_and(current_entry->visibility, + expr); +} + void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) { menu_add_prop(type, NULL, expr, dep); @@ -410,6 +416,11 @@ bool menu_is_visible(struct menu *menu) if (!menu->prompt) return false; + if (menu->visibility) { + if (expr_calc_value(menu->visibility) == no) + return no; + } + sym = menu->sym; if (sym) { sym_calc_value(sym); diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf index d8bc742..c9e690e 100644 --- a/scripts/kconfig/zconf.gperf +++ b/scripts/kconfig/zconf.gperf @@ -38,6 +38,7 @@ hex, T_TYPE, TF_COMMAND, S_HEX string, T_TYPE, TF_COMMAND, S_STRING select, T_SELECT, TF_COMMAND range, T_RANGE, TF_COMMAND +visible, T_VISIBLE, TF_COMMAND option, T_OPTION, TF_COMMAND on, T_ON, TF_PARAM modules, T_OPT_MODULES, TF_OPTION diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 2abd3c7..49fb4ab 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -36,7 +36,7 @@ static struct menu *current_menu, *current_entry; #define YYERROR_VERBOSE #endif %} -%expect 28 +%expect 30 %union { @@ -68,6 +68,7 @@ static struct menu *current_menu, *current_entry; %token T_DEFAULT %token T_SELECT %token T_RANGE +%token T_VISIBLE %token T_OPTION %token T_ON %token T_WORD @@ -123,7 +124,7 @@ stmt_list: ; option_name: - T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT + T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE ; common_stmt: @@ -359,7 +360,7 @@ menu: T_MENU prompt T_EOL printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); }; -menu_entry: menu depends_list +menu_entry: menu visibility_list depends_list { $$ = menu_add_menu(); }; @@ -430,6 +431,19 @@ depends: T_DEPENDS T_ON expr T_EOL printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); }; +/* visibility option */ + +visibility_list: + /* empty */ + | visibility_list visible + | visibility_list T_EOL +; + +visible: T_VISIBLE if_expr +{ + menu_add_visibility($2); +}; + /* prompt statement */ prompt_stmt_opt: @@ -526,6 +540,7 @@ static const char *zconf_tokenname(int token) case T_IF: return "if"; case T_ENDIF: return "endif"; case T_DEPENDS: return "depends"; + case T_VISIBLE: return "visible"; } return ""; }