From: Tom Rini Date: Fri, 3 Jul 2020 14:21:37 -0400 Subject: [RFC PATCH 4/4] linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED In-Reply-To: References: <20200612110216.10355-1-rasmus.villemoes@prevas.dk> <20200612110216.10355-5-rasmus.villemoes@prevas.dk> Message-ID: <20200703182137.GK1306@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, Jul 03, 2020 at 10:22:17AM -0600, Simon Glass wrote: > Hi, > > On Tue, 16 Jun 2020 at 17:31, Simon Glass wrote: > > > > Hi Rasmus, > > > > On Fri, 12 Jun 2020 at 05:02, Rasmus Villemoes > > 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 > > > --- > > > include/linux/kconfig.h | 48 ++++++++++++++++++++++++++++++++++++++--- > > > 1 file changed, 45 insertions(+), 3 deletions(-) > > > > Reviewed-by: Simon Glass > > > > See also this: > > > > http://patchwork.ozlabs.org/project/uboot/patch/20200522020223.230834-2-sjg at 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: