diff options
| -rw-r--r-- | scripts/kconfig/lkc_proto.h | 7 | ||||
| -rw-r--r-- | scripts/kconfig/preprocess.c | 19 | ||||
| -rw-r--r-- | scripts/kconfig/zconf.l | 3 | ||||
| -rw-r--r-- | scripts/kconfig/zconf.y | 5 |
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); | |||
| 49 | const char * prop_get_type_name(enum prop_type type); | 49 | const char * prop_get_type_name(enum prop_type type); |
| 50 | 50 | ||
| 51 | /* preprocess.c */ | 51 | /* preprocess.c */ |
| 52 | enum variable_flavor { | ||
| 53 | VAR_SIMPLE, | ||
| 54 | VAR_RECURSIVE, | ||
| 55 | }; | ||
| 52 | void env_write_dep(FILE *f, const char *auto_conf_name); | 56 | void env_write_dep(FILE *f, const char *auto_conf_name); |
| 53 | void variable_add(const char *name, const char *value); | 57 | void variable_add(const char *name, const char *value, |
| 58 | enum variable_flavor flavor); | ||
| 54 | void variable_all_del(void); | 59 | void variable_all_del(void); |
| 55 | char *expand_string(const char *in); | 60 | char *expand_string(const char *in); |
| 56 | char *expand_dollar(const char **str); | 61 | char *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); | |||
| 185 | struct variable { | 185 | struct 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) | |||
| 203 | static char *variable_expand(const char *name, int argc, char *argv[]) | 204 | static 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 | ||
| 214 | void variable_add(const char *name, const char *value) | 221 | void 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 | ||
| 230 | static void variable_del(struct variable *v) | 243 | static 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 | ||
| 520 | assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3); free($1); free($3); } | 521 | assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } |
| 521 | 522 | ||
| 522 | assign_val: | 523 | assign_val: |
| 523 | /* empty */ { $$ = xstrdup(""); }; | 524 | /* empty */ { $$ = xstrdup(""); }; |
