[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFkk2KQjBO=ck6i-L2h2XWehQrJotbzPv66JH+stZ7Q6M5YXTw@mail.gmail.com>
Date: Thu, 29 Mar 2018 04:42:42 +0200
From: Ulf Magnusson <ulfalizer@...il.com>
To: Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc: Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
Sam Ravnborg <sam@...nborg.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Arnd Bergmann <arnd@...db.de>,
Kees Cook <keescook@...omium.org>,
Thomas Gleixner <tglx@...utronix.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Randy Dunlap <rdunlap@...radead.org>,
"Luis R . Rodriguez" <mcgrof@...nel.org>,
Nicolas Pitre <nico@...aro.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 07/21] kconfig: add function support and implement
'shell' function
On Tue, Mar 27, 2018 at 7:29 AM, Masahiro Yamada
<yamada.masahiro@...ionext.com> wrote:
> This commit adds a new concept 'function' to do more text processing
> in Kconfig.
>
> A function call looks like this:
>
> $(function arg1, arg2, arg3, ...)
>
> (Actually, this syntax was inspired by make.)
>
> Real examples will look like this:
>
> $(shell echo hello world)
> $(cc-option -fstackprotector)
>
> This commit adds the basic infrastructure to add, delete, evaluate
> functions, and also the first built-in function $(shell ...). This
> accepts a single command to execute. It returns the standard output
> from it.
>
> [Example code]
>
> config HELLO
> string
> default "$(shell echo hello world)"
>
> config Y
> def_bool $(shell echo y)
>
> [Result]
>
> $ make -s alldefconfig && tail -n 2 .config
> CONFIG_HELLO="hello world"
> CONFIG_Y=y
>
> Caveat:
> Like environments, functions are expanded in the lexer. You cannot
> pass symbols to function arguments. This is a limitation to simplify
> the implementation. I want to avoid the dynamic function evaluation,
> which would introduce much more complexity.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
> ---
>
> Reminder for myself:
> Update Documentation/kbuild/kconfig-language.txt
>
>
> Changes in v2:
> - Use 'shell' for getting stdout from the comment.
> It was 'shell-stdout' in the previous version.
> - Symplify the implementation since the expansion has been moved to
> lexer.
>
> scripts/kconfig/function.c | 170 ++++++++++++++++++++++++++++++++++++++++++++
> scripts/kconfig/lkc_proto.h | 5 ++
> scripts/kconfig/util.c | 46 +++++++++---
> scripts/kconfig/zconf.y | 9 +++
> 4 files changed, 222 insertions(+), 8 deletions(-)
> create mode 100644 scripts/kconfig/function.c
>
The gotcha from 04/21 ("kconfig: reference environments directly and
remove 'option env=' syntax") applies here too. For example, the
following will work:
config A
bool "A"
default $(shell echo "B && C")
Some people might argue that that's a feature (I sense a mess down the
road if people start depending on it), but just in case you hadn't
thought of it.
Similarly, the following will only work as expected if 'cmd' outputs
the name of an undefined Kconfig symbol:
config A
string
default $(shell cmd)
You could argue that people should add quotes there though (though
that's broken at the moment if the output from 'cmd' includes a
quote).
Quotes in Kconfig speak just mean "constant value". Problem is it's
undocumented, and no one would intuitively expect it.
Cheers,
Ulf
Powered by blists - more mailing lists