diff options
author | Masahiro Yamada | 2018-05-28 18:21:50 +0900 |
---|---|---|
committer | Masahiro Yamada | 2018-05-29 03:31:19 +0900 |
commit | 1175c02506ffc9cef9f3c520249d8740a3174b1f (patch) | |
tree | 4d95574d080570461e3483ec3b916b867463c6f3 /scripts/kconfig/preprocess.c | |
parent | 9ced3bddec080e974e910bf887715540a8d9d96b (diff) |
kconfig: support simply expanded variable
The previous commit added variable and user-defined function. They
work similarly in the sense that the evaluation is deferred until
they are used.
This commit adds another type of variable, simply expanded variable,
as we see in Make.
The := operator defines a simply expanded variable, expanding the
righthand side immediately. This works like traditional programming
language variables.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig/preprocess.c')
-rw-r--r-- | scripts/kconfig/preprocess.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 46487fe6b36c..d103683b386e 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -185,6 +185,7 @@ static LIST_HEAD(variable_list); struct variable { char *name; char *value; + enum variable_flavor flavor; struct list_head node; }; @@ -203,15 +204,22 @@ static struct variable *variable_lookup(const char *name) static char *variable_expand(const char *name, int argc, char *argv[]) { struct variable *v; + char *res; v = variable_lookup(name); if (!v) return NULL; - return expand_string_with_args(v->value, argc, argv); + if (v->flavor == VAR_RECURSIVE) + res = expand_string_with_args(v->value, argc, argv); + else + res = xstrdup(v->value); + + return res; } -void variable_add(const char *name, const char *value) +void variable_add(const char *name, const char *value, + enum variable_flavor flavor) { struct variable *v; @@ -224,7 +232,12 @@ void variable_add(const char *name, const char *value) list_add_tail(&v->node, &variable_list); } - v->value = xstrdup(value); + v->flavor = flavor; + + if (flavor == VAR_SIMPLE) + v->value = expand_string(value); + else + v->value = xstrdup(value); } static void variable_del(struct variable *v) |