From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: [PATCH 20/32] kconfig: Refactor code into separate writer functions
Date: Tue, 31 Jan 2023 08:26:50 -0700 [thread overview]
Message-ID: <20230131152702.249197-21-sjg@chromium.org> (raw)
In-Reply-To: <20230131152702.249197-1-sjg@chromium.org>
Separate out the code that writes the Makefile and headers so we can
reuse these functions when writing out SPL files.
This makes no functional change.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
scripts/kconfig/confdata.c | 65 ++++++++++++++++++++++----------------
scripts/kconfig/expr.h | 9 ++++++
scripts/kconfig/lkc.h | 9 ++++++
3 files changed, 56 insertions(+), 27 deletions(-)
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index d587b10d7f8..73bf43bcb95 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -509,27 +509,18 @@ int conf_read(const char *name)
return 0;
}
-/*
- * Kconfig configuration printer
- *
- * This printer is used when generating the resulting configuration after
- * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
- * passing a non-NULL argument to the printer.
- *
- */
-static void
-kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+/* Print a symbol for a Makefile */
+static void print_makefile_sym(FILE *fp, const char *name,
+ enum symbol_type type, const char *value,
+ bool skip_unset)
{
-
- switch (sym->type) {
+ switch (type) {
case S_BOOLEAN:
case S_TRISTATE:
if (*value == 'n') {
- bool skip_unset = (arg != NULL);
-
if (!skip_unset)
fprintf(fp, "# %s%s is not set\n",
- CONFIG_, sym->name);
+ CONFIG_, name);
return;
}
break;
@@ -537,7 +528,21 @@ kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
break;
}
- fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
+ fprintf(fp, "%s%s=%s\n", CONFIG_, name, value);
+}
+
+/*
+ * Kconfig configuration printer
+ *
+ * This printer is used when generating the resulting configuration after
+ * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
+ * passing a non-NULL argument to the printer.
+ *
+ */
+static void
+kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+ print_makefile_sym(fp, sym->name, sym->type, value, arg != NULL);
}
static void
@@ -566,16 +571,12 @@ static struct conf_printer kconfig_printer_cb =
.print_comment = kconfig_print_comment,
};
-/*
- * Header printer
- *
- * This printer is used when generating the `include/generated/autoconf.h' file.
- */
-static void
-header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+/* Print a symbol for a header file */
+static void print_header_sym(FILE *fp, const char *name, enum symbol_type type,
+ const char *value)
{
- switch (sym->type) {
+ switch (type) {
case S_BOOLEAN:
case S_TRISTATE: {
const char *suffix = "";
@@ -588,7 +589,7 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
/* fall through */
default:
fprintf(fp, "#define %s%s%s 1\n",
- CONFIG_, sym->name, suffix);
+ CONFIG_, name, suffix);
}
break;
}
@@ -598,18 +599,28 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
prefix = "0x";
fprintf(fp, "#define %s%s %s%s\n",
- CONFIG_, sym->name, prefix, value);
+ CONFIG_, name, prefix, value);
break;
}
case S_STRING:
case S_INT:
fprintf(fp, "#define %s%s %s\n",
- CONFIG_, sym->name, value);
+ CONFIG_, name, value);
break;
default:
break;
}
+}
+/*
+ * Header printer
+ *
+ * This printer is used when generating the `include/generated/autoconf.h' file.
+ */
+static void
+header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+ print_header_sym(fp, sym->name, sym->type, value);
}
static void
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 7c329e17900..656c87fb4f3 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -158,6 +158,15 @@ struct symbol {
/* Set symbol to y if allnoconfig; used for symbols that hide others */
#define SYMBOL_ALLNOCONFIG_Y 0x200000
+/* U-Boot: Marks an SPL symbol */
+#define SYMBOL_SPL 0x400000
+
+/* U-Boot: Marks a non-SPL symbol that also has an SPL version */
+#define SYMBOL_HAS_SPL 0x800000
+
+/* U-Boot: Marks an-SPL symbol that does not have a non-SPL version */
+#define SYMBOL_SPL_ONLY 0x1000000
+
#define SYMBOL_MAXLENGTH 256
#define SYMBOL_HASHSIZE 9973
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 9eb7c837cd8..dec03cc927a 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -71,6 +71,15 @@ void sym_add_change_count(int count);
bool conf_set_all_new_symbols(enum conf_def_mode mode);
void set_all_choice_values(struct symbol *csym);
+/**
+ * conf_mark_spl_symbols() - Mark SPL symbols
+ *
+ * Symbols which don't start with SPL_ (TPL_, etc.) but have an SPL version
+ * should be marked with the SYMBOL_SPL flag, so we know to avoid writing them
+ * in the SPL autoconf.h files.
+ */
+void conf_mark_spl_symbols(void);
+
/* confdata.c and expr.c */
static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
{
--
2.39.1.456.gfc5497dd1b-goog
next prev parent reply other threads:[~2023-01-31 15:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 15:26 [PATCH 00/32] RFC: Migrate to split config Simon Glass
2023-01-31 15:26 ` [PATCH 01/32] fixup: Bugfix for moveconfig Simon Glass
2023-01-31 15:26 ` [PATCH 02/32] event: Add Kconfig options for SPL Simon Glass
2023-01-31 15:26 ` [PATCH 03/32] bootstd: " Simon Glass
2023-01-31 15:26 ` [PATCH 04/32] cmd: Add an SPL Kconfig for CMDLINE and HUSH Simon Glass
2023-01-31 15:26 ` [PATCH 05/32] boot: Add a Kconfig for SPL_QCOM_PMIC_GPIO Simon Glass
2023-01-31 15:26 ` [PATCH 06/32] cros_ec: Add SPL Kconfigs for cros_ec features Simon Glass
2023-01-31 15:26 ` [PATCH 07/32] boot: Add a Kconfig for SPL_UT_COMPRESSION Simon Glass
2023-01-31 15:26 ` [PATCH 08/32] env: Avoid checking ENV_IS_IN when env disabled Simon Glass
2023-01-31 15:26 ` [PATCH 09/32] boot: Add a Kconfig for SPL_AVB_VERIFY Simon Glass
2023-01-31 15:26 ` [PATCH 10/32] env: Allow VPL environment to be nowhere Simon Glass
2023-01-31 15:26 ` [PATCH 11/32] lib: Add VPL options for SHA1 and SHA256 Simon Glass
2023-01-31 15:26 ` [PATCH 12/32] sandbox: Tidy up RTC options Simon Glass
2023-01-31 15:26 ` [PATCH 13/32] sandbox: Use the generic VPL option to enable VPL Simon Glass
2023-01-31 15:26 ` [PATCH 14/32] sandbox: Tidy up I2C options Simon Glass
2023-01-31 15:26 ` [PATCH 15/32] fixdep: Add support for VPL Simon Glass
2023-01-31 15:26 ` [PATCH 16/32] fixdep: Refactor to make testing easier Simon Glass
2023-01-31 15:26 ` [PATCH 17/32] fixdep: Add some tests for parse_config_line() Simon Glass
2023-01-31 15:26 ` [PATCH 18/32] test: Add SPL versions of the TEST_KCONFIG options Simon Glass
2023-01-31 15:26 ` [PATCH 19/32] kconfig: Add configuration files for noproper and nospl Simon Glass
2023-01-31 15:26 ` Simon Glass [this message]
2023-01-31 15:26 ` [PATCH 21/32] kconfig: Support writing separate SPL files Simon Glass
2023-01-31 15:26 ` [PATCH 22/32] Makefile: Include the config for the phase being built Simon Glass
2023-01-31 15:26 ` [PATCH 23/32] kconfig: Update CONFIG_IS_ENABLED() for split files Simon Glass
2023-01-31 15:26 ` [PATCH 24/32] Makefile: Use empty SPL_ and SPL_TPL_ vars Simon Glass
2023-01-31 15:26 ` [PATCH 25/32] Drop use of CONFIG_IS_ENABLED() Simon Glass
2023-01-31 15:26 ` [PATCH 26/32] kconfig: Adjust the meaning " Simon Glass
2023-01-31 15:26 ` [PATCH 27/32] kconfig: Drop CONFIG_IF_ENABLED_INT() Simon Glass
2023-01-31 15:26 ` [PATCH 28/32] kconfig: Drop CONFIG_IS_ENABLED() Simon Glass
2023-01-31 15:26 ` [PATCH 29/32] kconfig: drop config_opt_enabled() Simon Glass
2023-01-31 15:27 ` [PATCH 30/32] kconfig: Drop CONFIG_VAL() Simon Glass
2023-01-31 15:27 ` [PATCH 31/32] kconfig: Move closer to the Linux version Simon Glass
2023-01-31 15:27 ` [PATCH 32/32] Makefile: Drop SPL_ and SPL_TPL_ macros Simon Glass
2023-01-31 21:57 ` [PATCH 00/32] RFC: Migrate to split config Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230131152702.249197-21-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.