[RFC PATCH 4/4] linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED
Tom Rini
trini at konsulko.com
Fri Jul 3 20:21:37 CEST 2020
On Fri, Jul 03, 2020 at 10:22:17AM -0600, Simon Glass wrote:
> Hi,
>
> On Tue, 16 Jun 2020 at 17:31, Simon Glass <sjg at google.com> wrote:
> >
> > Hi Rasmus,
> >
> > On Fri, 12 Jun 2020 at 05:02, Rasmus Villemoes
> > <rasmus.villemoes at prevas.dk> wrote:
> > >
> > > This adds a bunch of preprocessor magic to extend the capabilities of
> > > CONFIG_IS_ENABLED. The existing semantics of
> > >
> > > CONFIG_IS_ENABLED(FOO)
> > >
> > > expanding to a 1 or 0 (depending on build context and the defined-ness
> > > or not of the appropriate CONFIG_FOO/CONFIG_SPL_FOO/CONFIG_TPL_FOO)
> > > are of course preserved. With this, one is also allowed a two-argument
> > > form
> > >
> > > CONFIG_IS_ENABLED(FOO, (something))
> > >
> > > which expands to something precisely when CONFIG_IS_ENABLED(FOO) would
> > > expand to 1, and expands to nothing otherwise. It is, in other words,
> > > completely equivalent to the three lines
> > >
> > > #if CONFIG_IS_ENABLED(FOO)
> > > something
> > > #endif
> > >
> > > The second argument must be parenthesized in order to allow any
> > > tokens, including a trailing comma, to appear - one use case for this
> > > is precisely to make it a bit more ergonomic to build an array and
> > > only include certain items depending on .config. That should increase
> > > both readability and not least "git grep"ability.
> > >
> > > A third variant is also introduced,
> > >
> > > CONFIG_IS_ENABLED(FOO, (xxx), (yyy))
> > >
> > > which corresponds to
> > >
> > > #if CONFIG_IS_ENABLED(FOO)
> > > xxx
> > > #else
> > > yyy
> > > #endif
> > >
> > > Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
> > > ---
> > > include/linux/kconfig.h | 48 ++++++++++++++++++++++++++++++++++++++---
> > > 1 file changed, 45 insertions(+), 3 deletions(-)
> >
> > Reviewed-by: Simon Glass <sjg at chromium.org>
> >
> > See also this:
> >
> > http://patchwork.ozlabs.org/project/uboot/patch/20200522020223.230834-2-sjg@chromium.org/
> >
> > but I think your idea is a lot nicer.
>
> I'd like to pick up these three Kconfig patches for dm/next. Any objection?
I'll take them through master soon.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200703/51e0e83d/attachment.sig>
More information about the U-Boot
mailing list