diff options
-rw-r--r-- | scripts/kconfig/lkc_proto.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/preprocess.c | 28 | ||||
-rw-r--r-- | scripts/kconfig/zconf.l | 1 |
3 files changed, 27 insertions, 3 deletions
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 6303193f43f2..a8b7a330587e 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -52,6 +52,7 @@ const char * prop_get_type_name(enum prop_type type); | |||
52 | enum variable_flavor { | 52 | enum variable_flavor { |
53 | VAR_SIMPLE, | 53 | VAR_SIMPLE, |
54 | VAR_RECURSIVE, | 54 | VAR_RECURSIVE, |
55 | VAR_APPEND, | ||
55 | }; | 56 | }; |
56 | void env_write_dep(FILE *f, const char *auto_conf_name); | 57 | void env_write_dep(FILE *f, const char *auto_conf_name); |
57 | void variable_add(const char *name, const char *value, | 58 | void variable_add(const char *name, const char *value, |
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index d103683b386e..56aa1f0bad04 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c | |||
@@ -222,11 +222,23 @@ void variable_add(const char *name, const char *value, | |||
222 | enum variable_flavor flavor) | 222 | enum variable_flavor flavor) |
223 | { | 223 | { |
224 | struct variable *v; | 224 | struct variable *v; |
225 | char *new_value; | ||
226 | bool append = false; | ||
225 | 227 | ||
226 | v = variable_lookup(name); | 228 | v = variable_lookup(name); |
227 | if (v) { | 229 | if (v) { |
228 | free(v->value); | 230 | /* For defined variables, += inherits the existing flavor */ |
231 | if (flavor == VAR_APPEND) { | ||
232 | flavor = v->flavor; | ||
233 | append = true; | ||
234 | } else { | ||
235 | free(v->value); | ||
236 | } | ||
229 | } else { | 237 | } else { |
238 | /* For undefined variables, += assumes the recursive flavor */ | ||
239 | if (flavor == VAR_APPEND) | ||
240 | flavor = VAR_RECURSIVE; | ||
241 | |||
230 | v = xmalloc(sizeof(*v)); | 242 | v = xmalloc(sizeof(*v)); |
231 | v->name = xstrdup(name); | 243 | v->name = xstrdup(name); |
232 | list_add_tail(&v->node, &variable_list); | 244 | list_add_tail(&v->node, &variable_list); |
@@ -235,9 +247,19 @@ void variable_add(const char *name, const char *value, | |||
235 | v->flavor = flavor; | 247 | v->flavor = flavor; |
236 | 248 | ||
237 | if (flavor == VAR_SIMPLE) | 249 | if (flavor == VAR_SIMPLE) |
238 | v->value = expand_string(value); | 250 | new_value = expand_string(value); |
239 | else | 251 | else |
240 | v->value = xstrdup(value); | 252 | new_value = xstrdup(value); |
253 | |||
254 | if (append) { | ||
255 | v->value = xrealloc(v->value, | ||
256 | strlen(v->value) + strlen(new_value) + 2); | ||
257 | strcat(v->value, " "); | ||
258 | strcat(v->value, new_value); | ||
259 | free(new_value); | ||
260 | } else { | ||
261 | v->value = new_value; | ||
262 | } | ||
241 | } | 263 | } |
242 | 264 | ||
243 | static void variable_del(struct variable *v) | 265 | static void variable_del(struct variable *v) |
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 376af6cf2f65..a6cbe2d06d01 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -116,6 +116,7 @@ n [A-Za-z0-9_-] | |||
116 | } | 116 | } |
117 | "=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_RECURSIVE; return T_ASSIGN; } | 117 | "=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_RECURSIVE; return T_ASSIGN; } |
118 | ":=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_SIMPLE; return T_ASSIGN; } | 118 | ":=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_SIMPLE; return T_ASSIGN; } |
119 | "+=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_APPEND; return T_ASSIGN; } | ||
119 | [[:blank:]]+ | 120 | [[:blank:]]+ |
120 | . warn_ignored_character(*yytext); | 121 | . warn_ignored_character(*yytext); |
121 | \n { | 122 | \n { |