[1/5] kconfig: add an option to determine a menu's visibility

Message ID 1289079027-3037-2-git-send-email-lacombar@gmail.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Arnaud Lacombe Nov. 6, 2010, 9:30 p.m. UTC
  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(-)
  

Comments

Arnaud Lacombe Nov. 15, 2010, 4:57 p.m. UTC | #1
Hi all

On Sat, Nov 6, 2010 at 5:30 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> 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(-)
>
Michal, I don't think you commented on this ? Mauro, has it been
worked around differently ?

Thanks,
 - Arnaud
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Mauro Carvalho Chehab Nov. 16, 2010, 5:44 p.m. UTC | #2
Em 15-11-2010 14:57, Arnaud Lacombe escreveu:
> Hi all
> 
> On Sat, Nov 6, 2010 at 5:30 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
>> 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(-)
>>
> Michal, I don't think you commented on this ? Mauro, has it been
> worked around differently ?

Those patches worked fine, and solved all problems we had (I just had to touch
on two other menus that are used, as I answered upstream).

I prefer if Michal could forward those patches upstream, so, there's my ack:

Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Arnaud Lacombe Nov. 16, 2010, 9:41 p.m. UTC | #3
Hi,

On Tue, Nov 16, 2010 at 12:44 PM, Mauro Carvalho Chehab
<mchehab@redhat.com> wrote:
> Em 15-11-2010 14:57, Arnaud Lacombe escreveu:
>> Hi all
>>
>> On Sat, Nov 6, 2010 at 5:30 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
>>> 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(-)
>>>
>> Michal, I don't think you commented on this ? Mauro, has it been
>> worked around differently ?
>
> Those patches worked fine, and solved all problems we had (I just had to touch
> on two other menus that are used, as I answered upstream).
>
> I prefer if Michal could forward those patches upstream, so, there's my ack:
>
> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
>
It would seem Michal is not around lately, his only passage on
linux-kbuild@ is nearly a week old.

Sam, by any chance, could you comment on these patches so that we
could keep moving forward ?

Thanks,
 - Arnaud

ps: yes, I know, I did not upgrade the documentation.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Sam Ravnborg Nov. 16, 2010, 9:52 p.m. UTC | #4
On Tue, Nov 16, 2010 at 04:41:06PM -0500, Arnaud Lacombe wrote:
> Hi,
> 
> On Tue, Nov 16, 2010 at 12:44 PM, Mauro Carvalho Chehab
> <mchehab@redhat.com> wrote:
> > Em 15-11-2010 14:57, Arnaud Lacombe escreveu:
> >> Hi all
> >>
> >> On Sat, Nov 6, 2010 at 5:30 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> >>> 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(-)
> >>>
> >> Michal, I don't think you commented on this ? Mauro, has it been
> >> worked around differently ?
> >
> > Those patches worked fine, and solved all problems we had (I just had to touch
> > on two other menus that are used, as I answered upstream).
> >
> > I prefer if Michal could forward those patches upstream, so, there's my ack:
> >
> > Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> > Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> >
> It would seem Michal is not around lately, his only passage on
> linux-kbuild@ is nearly a week old.
> 
> Sam, by any chance, could you comment on these patches so that we
> could keep moving forward ?
I will try to take a look in the weekend - daytime job keeps me busy as usual.

> 
> Thanks,
>  - Arnaud
> 
> ps: yes, I know, I did not upgrade the documentation.
And I will toast you for that when I look at the patches :-)

	Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Randy Dunlap April 28, 2011, 5:38 p.m. UTC | #5
On Fri, 26 Nov 2010 08:17:36 -0800 Randy Dunlap wrote:

> On Fri, 26 Nov 2010 17:15:11 +0100 Michal Marek wrote:
> 
> > On Fri, Nov 26, 2010 at 11:31:16AM +0100, Michal Marek wrote:
> > > On 25.11.2010 18:06, Arnaud Lacombe wrote:
> > > > Hi folks,
> > > > 
> > > > On Sat, Nov 6, 2010 at 5:30 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> > > >> 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(-)
> > > >>
> > > > As there seem to be no interested from Michal to either, ACK, NACK, or
> > > > even comment this series, please let me withdraw these patches. If
> > > > this mail is not enough to void the patch, I hope to still be able to
> > > > withdraw my Signed-off-by from this particular series, and thus no
> > > > longer be able to certify the origin of the patches to prevent their
> > > > merge.
> > > 
> > > Hi Arnaud,
> > > 
> > > I'm sorry, I was sick for longer time and am now going through the
> > > patches that accumulated during that time. I understand your
> > > frustration, but the fact that I commented / applied some other patches
> > > yesterday and not this one does not mean that I'm ignoring it. Please
> > > accept my apologies, I'm looking at your patch right now...
> > 
> > So the patches look OK to me, I added your patches to
> > kbuild-2.6.git#menu-visibility and merged the branch to for-next. The
> > new syntax should be documented in
> > Documentation/kbuild/kconfig-language.txt, below is a first attempt at
> > it. If the patches work fine in linux-next _and_ you give me permission
> > to push them to Linus, I'll move them to rc-fixes and send a pull
> > request.
> > 
> > Michal
> > 
> > 
> > Subject: [PATCH] kconfig: Document the new "visible if" syntax

Hi,

Can we get this kconfig-language.txt patch added to the kernel source tree, please?


> > Signed-off-by: Michal Marek <mmarek@suse.cz>
> > 
> > diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
> > index 2fe93ca..2522cca 100644
> > --- a/Documentation/kbuild/kconfig-language.txt
> > +++ b/Documentation/kbuild/kconfig-language.txt
> > @@ -114,6 +114,13 @@ applicable everywhere (see syntax).
> >  	the illegal configurations all over.
> >  	kconfig should one day warn about such things.
> >  
> > +- limiting menu display: "visible if" <expr>
> > +  This attribute is only applicable to menu blocks, if the condition is
> > +  false, the menu block is not displayed to the user (the symbols
> > +  contained there can still be selected by other symbols, though). It is
> > +  similar to a conditional "prompt" attribude for individual menu
> > +  entries.
> > +
> 
> Default value of "visible" is true ??
> 
> >  - numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
> >    This allows to limit the range of possible input values for int
> >    and hex symbols. The user can only input a value which is larger than
> > @@ -300,7 +307,8 @@ menu:
> >  	"endmenu"
> >  
> >  This defines a menu block, see "Menu structure" above for more
> > -information. The only possible options are dependencies.
> > +information. The only possible options are dependencies and "visible"
> > +attributes.
> >  
> >  if:
> >  
> > --


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Michal Marek May 2, 2011, 3:33 p.m. UTC | #6
On Thu, Apr 28, 2011 at 10:38:02AM -0700, Randy Dunlap wrote:
> On Fri, 26 Nov 2010 08:17:36 -0800 Randy Dunlap wrote:
> 
> > On Fri, 26 Nov 2010 17:15:11 +0100 Michal Marek wrote:
> > > Subject: [PATCH] kconfig: Document the new "visible if" syntax
> 
> Hi,
> 
> Can we get this kconfig-language.txt patch added to the kernel source tree, please?

Thanks for the reminder, I pushed it to kbuild-2.6.git#kconfig now.

Michal
> 
> 
> > > Signed-off-by: Michal Marek <mmarek@suse.cz>
> > > 
> > > diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
> > > index 2fe93ca..2522cca 100644
> > > --- a/Documentation/kbuild/kconfig-language.txt
> > > +++ b/Documentation/kbuild/kconfig-language.txt
> > > @@ -114,6 +114,13 @@ applicable everywhere (see syntax).
> > >  	the illegal configurations all over.
> > >  	kconfig should one day warn about such things.
> > >  
> > > +- limiting menu display: "visible if" <expr>
> > > +  This attribute is only applicable to menu blocks, if the condition is
> > > +  false, the menu block is not displayed to the user (the symbols
> > > +  contained there can still be selected by other symbols, though). It is
> > > +  similar to a conditional "prompt" attribude for individual menu
> > > +  entries.
> > > +
> > 
> > Default value of "visible" is true ??
> > 
> > >  - numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
> > >    This allows to limit the range of possible input values for int
> > >    and hex symbols. The user can only input a value which is larger than
> > > @@ -300,7 +307,8 @@ menu:
> > >  	"endmenu"
> > >  
> > >  This defines a menu block, see "Menu structure" above for more
> > > -information. The only possible options are dependencies.
> > > +information. The only possible options are dependencies and "visible"
> > > +attributes.
> > >  
> > >  if:
> > >  
> > > --
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

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>";
 }