linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Saeed Mahameed <saeedm@mellanox.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kconfig: allow for conditional dependencies
Date: Thu, 7 May 2020 01:43:08 +0900	[thread overview]
Message-ID: <CAK7LNARpRMZb18FFnX1WPV4Xzh2B_n2E+KLf5QXqiqkZEKhTbQ@mail.gmail.com> (raw)
In-Reply-To: <nycvar.YSQ.7.76.2004231155060.2671@knanqh.ubzr>

On Fri, Apr 24, 2020 at 1:05 AM Nicolas Pitre <nico@fluxnic.net> wrote:
>
> On Thu, 23 Apr 2020, Jani Nikula wrote:
>
> > On Thu, 23 Apr 2020, Nicolas Pitre <nico@fluxnic.net> wrote:
> > > This might appear to be a strange concept, but sometimes we want
> > > a dependency to be conditionally applied. One such case is currently
> > > expressed with:
> > >
> > >         depends on FOO || !FOO
> > >
> > > This pattern is strange enough to give one's pause. Given that it is
> > > also frequent, let's make the intent more obvious with some syntaxic
> > > sugar by effectively making dependencies optionally conditional.
> > >
> > > This also makes the kconfig language more uniform.
> >
> > Thanks, I prefer this over all the previous proposals. Versatile yet
> > self-explanatory.
> >
> > > Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
> > >
> > > diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst
> > > index d0111dd264..0f841e0037 100644
> > > --- a/Documentation/kbuild/kconfig-language.rst
> > > +++ b/Documentation/kbuild/kconfig-language.rst
> > > @@ -114,7 +114,7 @@ applicable everywhere (see syntax).
> > >    This is a shorthand notation for a type definition plus a value.
> > >    Optionally dependencies for this default value can be added with "if".
> > >
> > > -- dependencies: "depends on" <expr>
> > > +- dependencies: "depends on" <expr> ["if" <expr>]
> > >
> > >    This defines a dependency for this menu entry. If multiple
> > >    dependencies are defined, they are connected with '&&'. Dependencies
> > > @@ -130,6 +130,16 @@ applicable everywhere (see syntax).
> > >     bool "foo"
> > >     default y
> > >
> > > +  The dependency definition itself may be conditional by appending "if"
> > > +  followed by an expression. If such expression is false (n) then this
> > > +  dependency is ignored. One possible use case is:
> > > +
> > > +    config FOO
> > > +   tristate
> > > +   depends on BAZ if BAZ != n
> >
> > I presume this is the same as
> >
> >       depends on BAZ if BAZ
> >
> > which makes me wonder if that should be the example. At least current
> > usage for select is predominantly
> >
> >       select FOO if BAR
> >
> > without "!= n".
>
> Yes, it is the same thing. I prefer making the documentation a little
> more explicit than necessary so the explanation is really obvious.


For the case of 'select',

  select FOO if BAR != n

is NOT equivalent to:

  select FOO if BAR



I do not think "if <expr>" in Kconfig
is so easy to understand.
I tend to hesitate to extend it.

Sometimes, it means "the property is visible if <expr> != n".
Sometimes, not.




For the case of 'depends on',
the 'depends on' is effective if <expr> != n
because Nicolas implemented it in this way.



We can do:

    depends on X || X = n

instead of:

    depends on X || !X

        or

    depends on X if X






I guess the source of the complaint is
!X is difficult to understand
when X is tristate.

But, is there any confusion in 'X = n' ?
I think not.

-- 
Best Regards
Masahiro Yamada

      reply	other threads:[~2020-05-06 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 15:19 [PATCH] kconfig: allow for conditional dependencies Nicolas Pitre
2020-04-23 15:53 ` Jani Nikula
2020-04-23 16:05   ` Nicolas Pitre
2020-05-06 16:43     ` Masahiro Yamada [this message]

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=CAK7LNARpRMZb18FFnX1WPV4Xzh2B_n2E+KLf5QXqiqkZEKhTbQ@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=arnd@arndb.de \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@fluxnic.net \
    --cc=rdunlap@infradead.org \
    --cc=saeedm@mellanox.com \
    /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;
as well as URLs for NNTP newsgroup(s).