public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Lacombe <lacombar@gmail.com>
To: linux-kbuild@vger.kernel.org, linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>,
	Michal Marek <mmarek@suse.cz>,
	Arnaud Lacombe <lacombar@gmail.com>
Subject: [PATCH 1/5] kconfig: add an option to determine a menu's visibility
Date: Sat,  6 Nov 2010 17:30:23 -0400	[thread overview]
Message-ID: <1289079027-3037-2-git-send-email-lacombar@gmail.com> (raw)
In-Reply-To: <4CD300AC.3010708@redhat.com>

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 <lacombar@gmail.com>
---
 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 <id>T_DEFAULT
 %token <id>T_SELECT
 %token <id>T_RANGE
+%token <id>T_VISIBLE
 %token <id>T_OPTION
 %token <id>T_ON
 %token <string> 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 "<token>";
 }
-- 
1.7.2.30.gc37d7.dirty


  parent reply	other threads:[~2010-11-06 21:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20101009224041.GA901@sepie.suse.cz>
2010-11-03 22:29 ` REGRESSION: Re: [GIT] kconfig rc fixes Mauro Carvalho Chehab
2010-11-03 22:47   ` Michal Marek
2010-11-03 23:02     ` Mauro Carvalho Chehab
2010-11-04  2:31   ` Arnaud Lacombe
2010-11-04  3:19     ` Mauro Carvalho Chehab
2010-11-04  4:02       ` Arnaud Lacombe
2010-11-04  4:15       ` Arnaud Lacombe
2010-11-04 11:10         ` Mauro Carvalho Chehab
2010-11-04 17:19           ` Randy Dunlap
2010-11-04 18:11             ` Mauro Carvalho Chehab
2010-11-04 18:32               ` Arnaud Lacombe
2010-11-04 18:51                 ` Mauro Carvalho Chehab
2010-11-05 12:02                   ` Jean Delvare
2010-11-06 21:30                   ` [PATCH 0/5] " Arnaud Lacombe
2010-11-06 22:28                     ` Mauro Carvalho Chehab
2010-11-09 17:32                     ` Mauro Carvalho Chehab
2010-11-06 21:30                   ` Arnaud Lacombe [this message]
2010-11-15 16:57                     ` [PATCH 1/5] kconfig: add an option to determine a menu's visibility Arnaud Lacombe
2010-11-16 17:44                       ` Mauro Carvalho Chehab
2010-11-16 21:41                         ` Arnaud Lacombe
2010-11-16 21:52                           ` Sam Ravnborg
     [not found]                     ` <AANLkTi=WS6cveqzxVmwC2wucaCpEJJLHXx0A8XbAChRb@mail.gmail.com>
     [not found]                       ` <4CEF8C74.8010600@suse.cz>
     [not found]                         ` <20101126161511.GD9418@sepie.suse.cz>
     [not found]                           ` <20101126081736.0ba8a90b.rdunlap@xenotime.net>
2011-04-28 17:38                             ` Randy Dunlap
2011-05-02 15:33                               ` Michal Marek
2010-11-06 21:30                   ` [PATCH 2/5] kconfig: regen parser Arnaud Lacombe
2010-11-06 21:30                   ` [PATCH 3/5] Revert "i2c: Fix Kconfig dependencies" Arnaud Lacombe
2010-11-06 21:30                   ` [PATCH 4/5] media/video: convert Kconfig to use the menu's `visible' keyword Arnaud Lacombe
2010-11-06 21:30                   ` [PATCH 5/5] i2c/algos: " Arnaud Lacombe
2010-11-04 18:34   ` REGRESSION: Re: [GIT] kconfig rc fixes Arnaud Lacombe
2010-11-04 18:43     ` Mauro Carvalho Chehab

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=1289079027-3037-2-git-send-email-lacombar@gmail.com \
    --to=lacombar@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --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