summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-02-03 00:58:05 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2024-02-19 18:20:40 +0900
commit56e634b06fd554b819ac9c45fc77a41500861ced (patch)
treeda7da38591efbae297cd7eb9baa6d279abbf3256
parent526396b723a38dbeed35cb9e80814084b9f56329 (diff)
downloadlwn-56e634b06fd554b819ac9c45fc77a41500861ced.tar.gz
lwn-56e634b06fd554b819ac9c45fc77a41500861ced.zip
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: Masahiro Yamada <masahiroy@kernel.org>
-rw-r--r--scripts/kconfig/confdata.c8
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/parser.y9
-rw-r--r--scripts/kconfig/preprocess.c11
4 files changed, 18 insertions, 12 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f6a96fdddb7e..dafc572e7b7e 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -994,13 +994,9 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
return -1;
}
- fputs(str_get(&autoconf_cmd), out);
-
- fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name);
+ fprintf(out, "autoconfig := %s\n", autoconf_name);
- env_write_dep(out, autoconf_name);
-
- fprintf(out, "\n$(deps_config): ;\n");
+ fputs(str_get(&autoconf_cmd), out);
fflush(out);
ret = ferror(out); /* error check for all fprintf() calls */
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index a4ae5e9eadad..85491d74a094 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -46,7 +46,7 @@ enum variable_flavor {
VAR_RECURSIVE,
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,
enum variable_flavor flavor);
void variable_all_del(void);
diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index 611038c502fc..cfb82ba09037 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -482,7 +482,7 @@ void conf_parse(const char *name)
autoconf_cmd = str_new();
- str_printf(&autoconf_cmd, "deps_config := \\\n");
+ str_printf(&autoconf_cmd, "\ndeps_config := \\\n");
zconf_initscan(name);
@@ -492,6 +492,13 @@ void conf_parse(const char *name)
yydebug = 1;
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. */
variable_all_del();
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index d1f5bcff4b62..b9853d4a891c 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -87,14 +87,17 @@ static char *env_expand(const char *name)
return xstrdup(value);
}
-void env_write_dep(FILE *f, const char *autoconfig_name)
+void env_write_dep(struct gstr *s)
{
struct env *e, *tmp;
list_for_each_entry_safe(e, tmp, &env_list, node) {
- fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value);
- fprintf(f, "%s: FORCE\n", autoconfig_name);
- fprintf(f, "endif\n");
+ str_printf(s,
+ "\n"
+ "ifneq \"$(%s)\" \"%s\"\n"
+ "$(autoconfig): FORCE\n"
+ "endif\n",
+ e->name, e->value);
env_del(e);
}
}