From a092257a49ed7850913cf53e474f4c8dd175c94b Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 4 Sep 2018 18:05:28 +0200 Subject: Allow macro expansion within symbol names The C implementation supports this (though it's undocumented, and unused to far). This can be used e.g. to dynamically instatiate symbols from template files: Kconfig.template: config $(subsys)_LOG bool "Enable logging for $(subsys)" depends on $(subsys)_HAS_LOG ... other stuff dependent on $(subsys) Elsewhere: subsys = FOO source "Kconfig.template" subsys = BAR source "Kconfig.template" Pretty sure this can easily be abused, but it should be supported at least. --- tests/Kpreprocess | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/Kpreprocess') diff --git a/tests/Kpreprocess b/tests/Kpreprocess index 2ebf6e6..e30b389 100644 --- a/tests/Kpreprocess +++ b/tests/Kpreprocess @@ -67,11 +67,17 @@ special-chars-fn-res = $(fn,$(comma)$(dollar)$(left-paren)foo$(right-paren)) qaz = QAZ echo = $(1) +ignore-first = $(2) config PRINT_ME string "$(ENV_1)" if ($(echo,FOO) && $(echo,BAR)) || !$(echo,BAZ) || !(($(qaz))) default "$(echo,"foo")" if "foo $(echo,"bar") baz" = "$(undefined)" +# Expansion within a symbol token, with deliberate sloppiness +config PRINT_$(ignore-first, ,ME)_TOO + bool "foo" + default FOO$(ignore-first, ,BAR)BAZ$(qaz) if $(qaz)&&$(qaz)FOO&&x$(ignore-first, ,xx) + # Recursive expansion (throws an exception) -- cgit v1.2.3