[PATCH 06/27] kconfig: write Kconfig files to autoconf.cmd in order

From: Masahiro Yamada
Date: Fri Feb 02 2024 - 11:00:32 EST


Currently, include/config/autoconf.cmd saves included Kconfig files in
reverse order. While this is not a big deal, it is inconsistent with
other *.cmd files generated by fixdep.

Output the included Kconfig files in the included order.

Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
---

scripts/kconfig/confdata.c | 7 +++----
scripts/kconfig/lkc.h | 1 +
scripts/kconfig/parser.y | 4 ++++
scripts/kconfig/util.c | 3 +++
4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 7f0aa39b68c1..f6a96fdddb7e 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -20,6 +20,8 @@

#include "lkc.h"

+struct gstr autoconf_cmd;
+
/* return true if 'path' exists, false otherwise */
static bool is_present(const char *path)
{
@@ -972,7 +974,6 @@ int conf_write(const char *name)
static int conf_write_autoconf_cmd(const char *autoconf_name)
{
char name[PATH_MAX], tmp[PATH_MAX];
- struct file *file;
FILE *out;
int ret;

@@ -993,9 +994,7 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
return -1;
}

- fprintf(out, "deps_config := \\\n");
- for (file = file_list; file; file = file->next)
- fprintf(out, "\t%s \\\n", file->name);
+ fputs(str_get(&autoconf_cmd), out);

fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name);

diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 5cdc8f5e6446..8616ad83be6d 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -40,6 +40,7 @@ int zconf_lineno(void);
const char *zconf_curname(void);

/* confdata.c */
+extern struct gstr autoconf_cmd;
const char *conf_get_configname(void);
void set_all_choice_values(struct symbol *csym);

diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index 625224973c51..611038c502fc 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -480,6 +480,10 @@ void conf_parse(const char *name)
struct symbol *sym;
int i;

+ autoconf_cmd = str_new();
+
+ str_printf(&autoconf_cmd, "deps_config := \\\n");
+
zconf_initscan(name);

_menu_init();
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 92e5b2b9761d..958543bb0a37 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -25,6 +25,9 @@ struct file *file_lookup(const char *name)
file->name = xstrdup(name);
file->next = file_list;
file_list = file;
+
+ str_printf(&autoconf_cmd, "\t%s \\\n", name);
+
return file;
}

--
2.40.1