aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/kconfig/lkc_proto.h7
-rw-r--r--scripts/kconfig/preprocess.c19
-rw-r--r--scripts/kconfig/zconf.l3
-rw-r--r--scripts/kconfig/zconf.y5
4 files changed, 27 insertions, 7 deletions
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 2b16d6e1b2db..6303193f43f2 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -49,8 +49,13 @@ const char * sym_get_string_value(struct symbol *sym);
49const char * prop_get_type_name(enum prop_type type); 49const char * prop_get_type_name(enum prop_type type);
50 50
51/* preprocess.c */ 51/* preprocess.c */
52enum variable_flavor {
53 VAR_SIMPLE,
54 VAR_RECURSIVE,
55};
52void env_write_dep(FILE *f, const char *auto_conf_name); 56void env_write_dep(FILE *f, const char *auto_conf_name);
53void variable_add(const char *name, const char *value); 57void variable_add(const char *name, const char *value,
58 enum variable_flavor flavor);
54void variable_all_del(void); 59void variable_all_del(void);
55char *expand_string(const char *in); 60char *expand_string(const char *in);
56char *expand_dollar(const char **str); 61char *expand_dollar(const char **str);
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);
185struct variable { 185struct variable {
186 char *name; 186 char *name;
187 char *value; 187 char *value;
188 enum variable_flavor flavor;
188 struct list_head node; 189 struct list_head node;
189}; 190};
190 191
@@ -203,15 +204,22 @@ static struct variable *variable_lookup(const char *name)
203static char *variable_expand(const char *name, int argc, char *argv[]) 204static char *variable_expand(const char *name, int argc, char *argv[])
204{ 205{
205 struct variable *v; 206 struct variable *v;
207 char *res;
206 208
207 v = variable_lookup(name); 209 v = variable_lookup(name);
208 if (!v) 210 if (!v)
209 return NULL; 211 return NULL;
210 212
211 return expand_string_with_args(v->value, argc, argv); 213 if (v->flavor == VAR_RECURSIVE)
214 res = expand_string_with_args(v->value, argc, argv);
215 else
216 res = xstrdup(v->value);
217
218 return res;
212} 219}
213 220
214void variable_add(const char *name, const char *value) 221void variable_add(const char *name, const char *value,
222 enum variable_flavor flavor)
215{ 223{
216 struct variable *v; 224 struct variable *v;
217 225
@@ -224,7 +232,12 @@ void variable_add(const char *name, const char *value)
224 list_add_tail(&v->node, &variable_list); 232 list_add_tail(&v->node, &variable_list);
225 } 233 }
226 234
227 v->value = xstrdup(value); 235 v->flavor = flavor;
236
237 if (flavor == VAR_SIMPLE)
238 v->value = expand_string(value);
239 else
240 v->value = xstrdup(value);
228} 241}
229 242
230static void variable_del(struct variable *v) 243static void variable_del(struct variable *v)
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index dd08f7a38ccd..376af6cf2f65 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -114,7 +114,8 @@ n [A-Za-z0-9_-]
114 yylval.string = text; 114 yylval.string = text;
115 return T_VARIABLE; 115 return T_VARIABLE;
116 } 116 }
117 "=" { BEGIN(ASSIGN_VAL); 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 [[:blank:]]+ 119 [[:blank:]]+
119 . warn_ignored_character(*yytext); 120 . warn_ignored_character(*yytext);
120 \n { 121 \n {
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index e15e8c7063e0..6f9b0aa32a82 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -41,6 +41,7 @@ static struct menu *current_menu, *current_entry;
41 struct expr *expr; 41 struct expr *expr;
42 struct menu *menu; 42 struct menu *menu;
43 const struct kconf_id *id; 43 const struct kconf_id *id;
44 enum variable_flavor flavor;
44} 45}
45 46
46%token <id>T_MAINMENU 47%token <id>T_MAINMENU
@@ -78,7 +79,7 @@ static struct menu *current_menu, *current_entry;
78%token T_OPEN_PAREN 79%token T_OPEN_PAREN
79%token T_EOL 80%token T_EOL
80%token <string> T_VARIABLE 81%token <string> T_VARIABLE
81%token T_ASSIGN 82%token <flavor> T_ASSIGN
82%token <string> T_ASSIGN_VAL 83%token <string> T_ASSIGN_VAL
83 84
84%left T_OR 85%left T_OR
@@ -517,7 +518,7 @@ word_opt: /* empty */ { $$ = NULL; }
517 518
518/* assignment statement */ 519/* assignment statement */
519 520
520assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3); free($1); free($3); } 521assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }
521 522
522assign_val: 523assign_val:
523 /* empty */ { $$ = xstrdup(""); }; 524 /* empty */ { $$ = xstrdup(""); };