Skip to content

Commit

Permalink
util/kconfig: Uprev to Linux 6.1's kconfig
Browse files Browse the repository at this point in the history
This also cleans up our patch queue.

TEST=`util/abuild/abuild -C` output (config.h and config.build) remains
the same

Change-Id: I79159130ba3515ede59e9fb9fbf087e2ed76257a
Signed-off-by: Patrick Georgi <patrick@coreboot.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79203
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
  • Loading branch information
Patrick Georgi committed Nov 24, 2023
1 parent f47e85f commit 7f93aa4
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 70 deletions.
2 changes: 1 addition & 1 deletion util/kconfig/conf.c
Expand Up @@ -553,7 +553,7 @@ static int conf_choice(struct menu *menu)
print_help(child);
continue;
}
sym_set_choice_value(sym, child->sym);
sym_set_tristate_value(child->sym, yes);
for (child = child->list; child; child = child->next) {
indent += 2;
conf(child);
Expand Down
75 changes: 75 additions & 0 deletions util/kconfig/confdata.c
Expand Up @@ -230,6 +230,13 @@ static const char *conf_get_autoheader_name(void)
return name ? name : "include/generated/autoconf.h";
}

static const char *conf_get_rustccfg_name(void)
{
char *name = getenv("KCONFIG_RUSTCCFG");

return name ? name : "include/generated/rustc_cfg";
}

static const char *conf_get_autobase_name(void)
{
char *name = getenv("KCONFIG_SPLITCONFIG");
Expand Down Expand Up @@ -632,6 +639,9 @@ static const struct comment_style comment_style_c = {

static void conf_write_heading(FILE *fp, const struct comment_style *cs)
{
if (!cs)
return;

fprintf(fp, "%s\n", cs->prefix);

fprintf(fp, "%s Automatically generated file; DO NOT EDIT.\n",
Expand Down Expand Up @@ -787,6 +797,65 @@ static void print_symbol_for_c(FILE *fp, struct symbol *sym)
free(escaped);
}

static void print_symbol_for_rustccfg(FILE *fp, struct symbol *sym)
{
const char *val;
const char *val_prefix = "";
char *val_prefixed = NULL;
size_t val_prefixed_len;
char *escaped = NULL;

if (sym->type == S_UNKNOWN)
return;

val = sym_get_string_value(sym);

switch (sym->type) {
case S_BOOLEAN:
case S_TRISTATE:
/*
* We do not care about disabled ones, i.e. no need for
* what otherwise are "comments" in other printers.
*/
if (*val == 'n')
return;

/*
* To have similar functionality to the C macro `IS_ENABLED()`
* we provide an empty `--cfg CONFIG_X` here in both `y`
* and `m` cases.
*
* Then, the common `fprintf()` below will also give us
* a `--cfg CONFIG_X="y"` or `--cfg CONFIG_X="m"`, which can
* be used as the equivalent of `IS_BUILTIN()`/`IS_MODULE()`.
*/
fprintf(fp, "--cfg=%s%s\n", CONFIG_, sym->name);
break;
case S_HEX:
if (val[0] != '0' || (val[1] != 'x' && val[1] != 'X'))
val_prefix = "0x";
break;
default:
break;
}

if (strlen(val_prefix) > 0) {
val_prefixed_len = strlen(val) + strlen(val_prefix) + 1;
val_prefixed = xmalloc(val_prefixed_len);
snprintf(val_prefixed, val_prefixed_len, "%s%s", val_prefix, val);
val = val_prefixed;
}

/* All values get escaped: the `--cfg` option only takes strings */
escaped = escape_string_value(val);
val = escaped;

fprintf(fp, "--cfg=%s%s=%s\n", CONFIG_, sym->name, val);

free(escaped);
free(val_prefixed);
}

/*
* Write out a minimal config.
* All values that has default values are skipped as this is redundant.
Expand Down Expand Up @@ -1175,6 +1244,12 @@ int conf_write_autoconf(int overwrite)
if (ret)
return ret;

ret = __conf_write_autoconf(conf_get_rustccfg_name(),
print_symbol_for_rustccfg,
NULL);
if (ret)
return ret;

/*
* Create include/config/auto.conf. This must be the last step because
* Kbuild has a dependency on auto.conf and this marks the successful
Expand Down
5 changes: 0 additions & 5 deletions util/kconfig/lkc.h
Expand Up @@ -127,11 +127,6 @@ static inline struct symbol *sym_get_choice_value(struct symbol *sym)
return (struct symbol *)sym->curr.val;
}

static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
{
return sym_set_tristate_value(chval, yes);
}

static inline bool sym_is_choice(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICE ? true : false;
Expand Down
23 changes: 4 additions & 19 deletions util/kconfig/menu.c
Expand Up @@ -722,8 +722,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
if (!expr_eq(prop->menu->dep, prop->visible.expr))
get_dep_str(r, prop->visible.expr, " Visible if: ");

menu = prop->menu->parent;
for (i = 0; menu && i < 8; menu = menu->parent) {
menu = prop->menu;
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
bool accessible = menu_is_visible(menu);

submenu[i++] = menu;
Expand All @@ -733,16 +733,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
if (head && location) {
jump = xmalloc(sizeof(struct jump_key));

if (menu_is_visible(prop->menu)) {
/*
* There is not enough room to put the hint at the
* beginning of the "Prompt" line. Put the hint on the
* last "Location" line even when it would belong on
* the former.
*/
jump->target = prop->menu;
} else
jump->target = location;
jump->target = location;

if (list_empty(head))
jump->index = 0;
Expand All @@ -758,13 +749,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
menu = submenu[i];
if (jump && menu == location)
jump->offset = strlen(r->s);

if (menu == &rootmenu)
/* The real rootmenu prompt is ugly */
str_printf(r, "%*cMain menu", j, ' ');
else
str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));

str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
if (menu->sym) {
str_printf(r, " (%s [=%s])", menu->sym->name ?
menu->sym->name : "<choice>",
Expand Down
Expand Up @@ -19,15 +19,15 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -430,6 +430,7 @@ load:
@@ -437,6 +437,7 @@ load:
if (def == S_DEF_USER) {
sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) {
+ conf_warning("trying to assign non-existent symbol %s", line + strlen(CONFIG_));
conf_set_changed(true);
continue;
}
@@ -512,6 +513,13 @@ load:
@@ -519,6 +520,13 @@ load:
}
free(line);
fclose(in);
Expand Down
Expand Up @@ -40,7 +40,7 @@ Index: kconfig/confdata.c
static void conf_default_message_callback(const char *s)
{
printf("#\n# ");
@@ -440,7 +450,7 @@ load:
@@ -447,7 +457,7 @@ load:
sym->type = S_BOOLEAN;
}
if (sym->flags & def_flags) {
Expand All @@ -49,7 +49,7 @@ Index: kconfig/confdata.c
}
switch (sym->type) {
case S_BOOLEAN:
@@ -479,7 +489,7 @@ load:
@@ -486,7 +496,7 @@ load:
}

if (sym->flags & def_flags) {
Expand All @@ -58,7 +58,7 @@ Index: kconfig/confdata.c
}
if (conf_set_sym_val(sym, def, def_flags, p))
continue;
@@ -504,7 +514,7 @@ load:
@@ -511,7 +521,7 @@ load:
break;
case yes:
if (cs->def[def].tri != no)
Expand Down
Expand Up @@ -24,7 +24,7 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -440,7 +440,9 @@ load:
@@ -447,7 +447,9 @@ load:
if (def == S_DEF_USER) {
sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) {
Expand Down
Expand Up @@ -62,7 +62,7 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -530,11 +530,7 @@ load:
@@ -537,11 +537,7 @@ load:
free(line);
fclose(in);

Expand Down
Expand Up @@ -14,7 +14,7 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -715,7 +715,12 @@ static void print_symbol_for_dotconfig(F
@@ -725,7 +725,12 @@ static void print_symbol_for_dotconfig(F

static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
{
Expand All @@ -28,7 +28,7 @@ Index: kconfig/confdata.c
}

void print_symbol_for_listconfig(struct symbol *sym)
@@ -740,6 +745,10 @@ static void print_symbol_for_c(FILE *fp,
@@ -750,6 +755,10 @@ static void print_symbol_for_c(FILE *fp,
case S_TRISTATE:
switch (*val) {
case 'n':
Expand All @@ -39,7 +39,7 @@ Index: kconfig/confdata.c
return;
case 'm':
sym_suffix = "_MODULE";
@@ -751,6 +760,12 @@ static void print_symbol_for_c(FILE *fp,
@@ -761,6 +770,12 @@ static void print_symbol_for_c(FILE *fp,
case S_HEX:
if (val[0] != '0' || (val[1] != 'x' && val[1] != 'X'))
val_prefix = "0x";
Expand All @@ -52,7 +52,7 @@ Index: kconfig/confdata.c
break;
case S_STRING:
escaped = escape_string_value(val);
@@ -1108,8 +1123,9 @@ static int __conf_write_autoconf(const c
@@ -1177,8 +1192,9 @@ static int __conf_write_autoconf(const c

conf_write_heading(file, comment_style);

Expand Down
Expand Up @@ -21,8 +21,8 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -230,6 +230,13 @@ static const char *conf_get_autoheader_n
return name ? name : "include/generated/autoconf.h";
@@ -237,6 +237,13 @@ static const char *conf_get_rustccfg_nam
return name ? name : "include/generated/rustc_cfg";
}

+static const char *conf_get_autobase_name(void)
Expand All @@ -35,7 +35,7 @@ Index: kconfig/confdata.c
static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
{
char *p2;
@@ -1024,19 +1031,19 @@ static int conf_write_autoconf_cmd(const
@@ -1093,19 +1100,19 @@ static int conf_write_autoconf_cmd(const

static int conf_touch_deps(void)
{
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion util/kconfig/patches/series
Expand Up @@ -10,4 +10,3 @@
0010-reenable-source-in-choice.patch
0013-util-kconfig-detect-ncurses-on-FreeBSD.patch
0014-util-kconfig-Move-Kconfig-deps-back-into-build-confi.patch
0015-util-kconfig-chmod-w-before-savedefconfig.patch

0 comments on commit 7f93aa4

Please sign in to comment.