Commit 56e634b0 authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: call env_write_dep() right after yyparse()

This allows preprocess.c to free up all of its resources when the parse
stage is finished. It also ensures conf_write_autoconf_cmd() produces
consistent results even if called multiple times for any reason.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 526396b7
...@@ -994,13 +994,9 @@ static int conf_write_autoconf_cmd(const char *autoconf_name) ...@@ -994,13 +994,9 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
return -1; return -1;
} }
fputs(str_get(&autoconf_cmd), out); fprintf(out, "autoconfig := %s\n", autoconf_name);
fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name);
env_write_dep(out, autoconf_name); fputs(str_get(&autoconf_cmd), out);
fprintf(out, "\n$(deps_config): ;\n");
fflush(out); fflush(out);
ret = ferror(out); /* error check for all fprintf() calls */ ret = ferror(out); /* error check for all fprintf() calls */
......
...@@ -46,7 +46,7 @@ enum variable_flavor { ...@@ -46,7 +46,7 @@ enum variable_flavor {
VAR_RECURSIVE, VAR_RECURSIVE,
VAR_APPEND, VAR_APPEND,
}; };
void env_write_dep(FILE *f, const char *auto_conf_name); void env_write_dep(struct gstr *gs);
void variable_add(const char *name, const char *value, void variable_add(const char *name, const char *value,
enum variable_flavor flavor); enum variable_flavor flavor);
void variable_all_del(void); void variable_all_del(void);
......
...@@ -482,7 +482,7 @@ void conf_parse(const char *name) ...@@ -482,7 +482,7 @@ void conf_parse(const char *name)
autoconf_cmd = str_new(); autoconf_cmd = str_new();
str_printf(&autoconf_cmd, "deps_config := \\\n"); str_printf(&autoconf_cmd, "\ndeps_config := \\\n");
zconf_initscan(name); zconf_initscan(name);
...@@ -492,6 +492,13 @@ void conf_parse(const char *name) ...@@ -492,6 +492,13 @@ void conf_parse(const char *name)
yydebug = 1; yydebug = 1;
yyparse(); yyparse();
str_printf(&autoconf_cmd,
"\n"
"$(autoconfig): $(deps_config)\n"
"$(deps_config): ;\n");
env_write_dep(&autoconf_cmd);
/* Variables are expanded in the parse phase. We can free them here. */ /* Variables are expanded in the parse phase. We can free them here. */
variable_all_del(); variable_all_del();
......
...@@ -87,14 +87,17 @@ static char *env_expand(const char *name) ...@@ -87,14 +87,17 @@ static char *env_expand(const char *name)
return xstrdup(value); return xstrdup(value);
} }
void env_write_dep(FILE *f, const char *autoconfig_name) void env_write_dep(struct gstr *s)
{ {
struct env *e, *tmp; struct env *e, *tmp;
list_for_each_entry_safe(e, tmp, &env_list, node) { list_for_each_entry_safe(e, tmp, &env_list, node) {
fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value); str_printf(s,
fprintf(f, "%s: FORCE\n", autoconfig_name); "\n"
fprintf(f, "endif\n"); "ifneq \"$(%s)\" \"%s\"\n"
"$(autoconfig): FORCE\n"
"endif\n",
e->name, e->value);
env_del(e); env_del(e);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment