util/kconfig: Uprev to Linux 5.16's kconfig
Linux 5.16 saw a significant rewrite in the boolean handling which reduces our change set. On the other hand, it's all new code. Comparing the config.build and config.h files generated by `util/abuild/abuild -C`, only a few lines of comment in the header changed. Change-Id: I52984e15a48236ddf228707aec85e90f71aa4382 Signed-off-by: Patrick Georgi <patrick@coreboot.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/66045 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
committed by
Patrick Georgi
parent
14cedd97a5
commit
4c9b9e9709
@@ -19,7 +19,7 @@ Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -439,6 +439,7 @@ load:
|
||||
@@ -428,6 +428,7 @@ load:
|
||||
if (def == S_DEF_USER) {
|
||||
sym = sym_find(line + 2 + strlen(CONFIG_));
|
||||
if (!sym) {
|
||||
@@ -27,7 +27,7 @@ Index: kconfig/confdata.c
|
||||
conf_set_changed(true);
|
||||
continue;
|
||||
}
|
||||
@@ -521,6 +522,13 @@ load:
|
||||
@@ -510,6 +511,13 @@ load:
|
||||
}
|
||||
free(line);
|
||||
fclose(in);
|
||||
|
@@ -23,7 +23,7 @@ Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -184,6 +184,16 @@ static void conf_warning(const char *fmt
|
||||
@@ -166,6 +166,16 @@ static void conf_warning(const char *fmt
|
||||
conf_warnings++;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ Index: kconfig/confdata.c
|
||||
static void conf_default_message_callback(const char *s)
|
||||
{
|
||||
printf("#\n# ");
|
||||
@@ -449,7 +459,7 @@ load:
|
||||
@@ -438,7 +448,7 @@ load:
|
||||
sym->type = S_BOOLEAN;
|
||||
}
|
||||
if (sym->flags & def_flags) {
|
||||
@@ -49,7 +49,7 @@ Index: kconfig/confdata.c
|
||||
}
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
@@ -488,7 +498,7 @@ load:
|
||||
@@ -477,7 +487,7 @@ load:
|
||||
}
|
||||
|
||||
if (sym->flags & def_flags) {
|
||||
@@ -58,7 +58,7 @@ Index: kconfig/confdata.c
|
||||
}
|
||||
if (conf_set_sym_val(sym, def, def_flags, p))
|
||||
continue;
|
||||
@@ -513,7 +523,7 @@ load:
|
||||
@@ -502,7 +512,7 @@ load:
|
||||
break;
|
||||
case yes:
|
||||
if (cs->def[def].tri != no)
|
||||
|
@@ -14,7 +14,7 @@ Index: kconfig/conf.c
|
||||
===================================================================
|
||||
--- kconfig.orig/conf.c
|
||||
+++ kconfig/conf.c
|
||||
@@ -900,7 +900,7 @@ int main(int ac, char **av)
|
||||
@@ -889,7 +889,7 @@ int main(int ac, char **av)
|
||||
|
||||
if (input_mode == savedefconfig) {
|
||||
if (conf_write_defconfig(defconfig_file)) {
|
||||
|
@@ -24,7 +24,7 @@ Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -449,7 +449,9 @@ load:
|
||||
@@ -438,7 +438,9 @@ load:
|
||||
if (def == S_DEF_USER) {
|
||||
sym = sym_find(line + 2 + strlen(CONFIG_));
|
||||
if (!sym) {
|
||||
|
@@ -15,14 +15,14 @@ Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -164,6 +164,10 @@ struct conf_printer {
|
||||
void (*print_comment)(FILE *, const char *, void *);
|
||||
};
|
||||
@@ -155,6 +155,10 @@ static void conf_message(const char *fmt
|
||||
static const char *conf_filename;
|
||||
static int conf_lineno, conf_warnings;
|
||||
|
||||
+#ifdef __MINGW32__
|
||||
+#define mkdir(_n,_p) mkdir((_n))
|
||||
+#endif
|
||||
+
|
||||
static void conf_warning(const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
{
|
||||
va_list ap;
|
||||
|
@@ -36,7 +36,7 @@ Index: kconfig/conf.c
|
||||
static void conf(struct menu *menu);
|
||||
static void check_conf(struct menu *menu);
|
||||
|
||||
@@ -732,6 +734,7 @@ int main(int ac, char **av)
|
||||
@@ -721,6 +723,7 @@ int main(int ac, char **av)
|
||||
const char *progname = av[0];
|
||||
int opt;
|
||||
const char *name, *defconfig_file = NULL /* gcc uninit */;
|
||||
@@ -44,7 +44,7 @@ Index: kconfig/conf.c
|
||||
int no_conf_write = 0;
|
||||
|
||||
tty_stdio = isatty(0) && isatty(1);
|
||||
@@ -838,6 +841,13 @@ int main(int ac, char **av)
|
||||
@@ -827,6 +830,13 @@ int main(int ac, char **av)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -539,11 +539,7 @@ load:
|
||||
@@ -528,11 +528,7 @@ load:
|
||||
free(line);
|
||||
fclose(in);
|
||||
|
||||
|
@@ -34,7 +34,7 @@ Index: kconfig/lexer.l
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -438,6 +439,32 @@ void zconf_nextfile(const char *name)
|
||||
@@ -439,6 +440,32 @@ void zconf_nextfile(const char *name)
|
||||
current_file = file;
|
||||
}
|
||||
|
||||
|
@@ -10,74 +10,6 @@ Date: Fri Nov 22 22:08:15 2019 +0100
|
||||
Change-Id: I9e62b05e45709f1539e455e2eed37308609be15e
|
||||
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
|
||||
|
||||
Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -687,6 +687,9 @@ header_print_symbol(FILE *fp, struct sym
|
||||
|
||||
switch (*value) {
|
||||
case 'n':
|
||||
+ if (getenv("KCONFIG_NEGATIVES") != NULL)
|
||||
+ fprintf(fp, "#define %s%s%s 0\n",
|
||||
+ CONFIG_, sym->name, suffix);
|
||||
break;
|
||||
case 'm':
|
||||
suffix = "_MODULE";
|
||||
@@ -702,14 +705,28 @@ header_print_symbol(FILE *fp, struct sym
|
||||
|
||||
if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
|
||||
prefix = "0x";
|
||||
+ if (value[0] == '\0') {
|
||||
+ /*
|
||||
+ * prefix is reset to remain closer to the older
|
||||
+ * coreboot patch. No need to keep this once kconfig
|
||||
+ * is fully upreved
|
||||
+ */
|
||||
+ prefix = "";
|
||||
+ value = "0";
|
||||
+ }
|
||||
fprintf(fp, "#define %s%s %s%s\n",
|
||||
CONFIG_, sym->name, prefix, value);
|
||||
break;
|
||||
}
|
||||
case S_STRING:
|
||||
+ if (value[0] == '\0')
|
||||
+ break;
|
||||
+ if (!(sym->flags & SYMBOL_WRITE))
|
||||
+ break;
|
||||
+ /* fall through */
|
||||
case S_INT:
|
||||
fprintf(fp, "#define %s%s %s\n",
|
||||
- CONFIG_, sym->name, value);
|
||||
+ CONFIG_, sym->name, value[0]?value:"0");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1080,6 +1097,7 @@ int conf_write_autoconf(int overwrite)
|
||||
const char *autoconf_name = conf_get_autoconfig_name();
|
||||
FILE *out, *out_h;
|
||||
int i;
|
||||
+ int print_negatives = getenv("KCONFIG_NEGATIVES") != NULL;
|
||||
|
||||
if (!overwrite && is_present(autoconf_name))
|
||||
return 0;
|
||||
@@ -1104,11 +1122,13 @@ int conf_write_autoconf(int overwrite)
|
||||
|
||||
for_all_symbols(i, sym) {
|
||||
sym_calc_value(sym);
|
||||
- if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
|
||||
+ if (!(sym->flags & SYMBOL_WRITE) && !print_negatives)
|
||||
+ continue;
|
||||
+ if (!sym->name)
|
||||
continue;
|
||||
|
||||
/* write symbols to auto.conf and autoconf.h */
|
||||
- conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
|
||||
+ conf_write_symbol(out, sym, &kconfig_printer_cb, print_negatives?NULL:(void *)1);
|
||||
conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
|
||||
}
|
||||
fclose(out);
|
||||
Index: kconfig/symbol.c
|
||||
===================================================================
|
||||
--- kconfig.orig/symbol.c
|
||||
@@ -91,3 +23,56 @@ Index: kconfig/symbol.c
|
||||
case S_STRING:
|
||||
return str;
|
||||
case S_UNKNOWN:
|
||||
Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -720,7 +720,12 @@ static void print_symbol_for_dotconfig(F
|
||||
|
||||
static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
|
||||
{
|
||||
- __print_symbol(fp, sym, OUTPUT_N_NONE, true);
|
||||
+ int print_negatives = getenv("KCONFIG_NEGATIVES") != NULL;
|
||||
+ enum output_n out = OUTPUT_N_NONE;
|
||||
+ if (print_negatives) {
|
||||
+ out = OUTPUT_N;
|
||||
+ }
|
||||
+ __print_symbol(fp, sym, out, true);
|
||||
}
|
||||
|
||||
void print_symbol_for_listconfig(struct symbol *sym)
|
||||
@@ -745,6 +750,10 @@ static void print_symbol_for_c(FILE *fp,
|
||||
case S_TRISTATE:
|
||||
switch (*val) {
|
||||
case 'n':
|
||||
+ if (getenv("KCONFIG_NEGATIVES") != NULL) {
|
||||
+ val = "0";
|
||||
+ break;
|
||||
+ }
|
||||
return;
|
||||
case 'm':
|
||||
sym_suffix = "_MODULE";
|
||||
@@ -756,6 +765,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";
|
||||
+ /* fall through */
|
||||
+ case S_INT:
|
||||
+ if (val[0] == '\0') {
|
||||
+ val = "0";
|
||||
+ val_prefix = "";
|
||||
+ }
|
||||
break;
|
||||
case S_STRING:
|
||||
escaped = escape_string_value(val);
|
||||
@@ -1106,8 +1121,9 @@ static int __conf_write_autoconf(const c
|
||||
|
||||
conf_write_heading(file, comment_style);
|
||||
|
||||
+ int print_negatives = getenv("KCONFIG_NEGATIVES") != NULL;
|
||||
for_all_symbols(i, sym)
|
||||
- if ((sym->flags & SYMBOL_WRITE) && sym->name)
|
||||
+ if (((sym->flags & SYMBOL_WRITE) || (print_negatives && sym->type != S_STRING)) && sym->name)
|
||||
print_symbol(file, sym);
|
||||
|
||||
/* check possible errors in conf_write_heading() and print_symbol() */
|
||||
|
@@ -2,8 +2,8 @@ Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -241,6 +241,13 @@ static const char *conf_get_autoconfig_n
|
||||
return name ? name : "include/config/auto.conf";
|
||||
@@ -230,6 +230,13 @@ static const char *conf_get_autoheader_n
|
||||
return name ? name : "include/generated/autoconf.h";
|
||||
}
|
||||
|
||||
+static const char *conf_get_autobase_name(void)
|
||||
@@ -16,7 +16,7 @@ Index: kconfig/confdata.c
|
||||
static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
{
|
||||
char *p2;
|
||||
@@ -1024,7 +1031,7 @@ static int conf_touch_deps(void)
|
||||
@@ -1031,7 +1038,7 @@ static int conf_touch_deps(void)
|
||||
struct symbol *sym;
|
||||
int res, i;
|
||||
|
||||
@@ -25,15 +25,3 @@ Index: kconfig/confdata.c
|
||||
depfile_prefix_len = strlen(depfile_path);
|
||||
|
||||
name = conf_get_autoconfig_name();
|
||||
@@ -1102,7 +1109,10 @@ int conf_write_autoconf(int overwrite)
|
||||
if (!overwrite && is_present(autoconf_name))
|
||||
return 0;
|
||||
|
||||
- conf_write_dep("include/config/auto.conf.cmd");
|
||||
+ char autoconfcmd_path[PATH_MAX];
|
||||
+ snprintf(autoconfcmd_path, sizeof(autoconfcmd_path), "%s%s",
|
||||
+ conf_get_autobase_name(), "auto.conf.cmd");
|
||||
+ conf_write_dep(autoconfcmd_path);
|
||||
|
||||
if (conf_touch_deps())
|
||||
return 1;
|
||||
|
@@ -1,124 +0,0 @@
|
||||
commit 7b2deddbb0ef350e189fe42c025b07c943aedc4c
|
||||
Author: Raul E Rangel <rrangel@chromium.org>
|
||||
Date: Thu Jul 25 15:49:52 2019 -0600
|
||||
|
||||
Kconfig: Write tmp files into same directory as target files
|
||||
|
||||
This removes the need for COREBOOT_BUILD_DIR in Kconfig. Since the
|
||||
original files will be replaced with the tmp file, the parent directory
|
||||
already needs to be writable.
|
||||
|
||||
Before this change, the tmp files would be created in the CWD (src) if
|
||||
COREBOOT_BUILD_DIR was not specified.
|
||||
|
||||
BUG=b:112267918
|
||||
TEST=emerge-grunt coreboot and verified no tmp files were created in the
|
||||
src directory.
|
||||
|
||||
Change-Id: Icdaf2ff3dd1ec98813b75ef55b96e38e1ca19ec7
|
||||
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
|
||||
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34244
|
||||
Reviewed-by: Martin Roth <martinroth@google.com>
|
||||
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
|
||||
|
||||
Index: kconfig/confdata.c
|
||||
===================================================================
|
||||
--- kconfig.orig/confdata.c
|
||||
+++ kconfig/confdata.c
|
||||
@@ -880,6 +880,16 @@ next_menu:
|
||||
return 0;
|
||||
}
|
||||
|
||||
+
|
||||
+static int conf_mktemp(const char *path, char *tmpfile)
|
||||
+{
|
||||
+ if (snprintf(tmpfile, PATH_MAX, "%s.tmp.XXXXXX", path) >= PATH_MAX) {
|
||||
+ errno = EOVERFLOW;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ return mkstemp(tmpfile);
|
||||
+}
|
||||
+
|
||||
int conf_write(const char *name)
|
||||
{
|
||||
FILE *out;
|
||||
@@ -1001,7 +1011,14 @@ static int conf_write_dep(const char *na
|
||||
struct file *file;
|
||||
FILE *out;
|
||||
|
||||
- out = fopen("..config.tmp", "w");
|
||||
+ if (make_parent_dir(name))
|
||||
+ return 1;
|
||||
+ char filename[PATH_MAX];
|
||||
+ int fd = conf_mktemp(name, filename);
|
||||
+ if (fd == -1)
|
||||
+ return 1;
|
||||
+
|
||||
+ out = fdopen(fd, "w");
|
||||
if (!out)
|
||||
return 1;
|
||||
fprintf(out, "deps_config := \\\n");
|
||||
@@ -1019,9 +1036,7 @@ static int conf_write_dep(const char *na
|
||||
fprintf(out, "\n$(deps_config): ;\n");
|
||||
fclose(out);
|
||||
|
||||
- if (make_parent_dir(name))
|
||||
- return 1;
|
||||
- rename("..config.tmp", name);
|
||||
+ rename(filename, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1117,11 +1132,26 @@ int conf_write_autoconf(int overwrite)
|
||||
if (conf_touch_deps())
|
||||
return 1;
|
||||
|
||||
- out = fopen(".tmpconfig", "w");
|
||||
+ if (make_parent_dir(autoconf_name))
|
||||
+ return 1;
|
||||
+ char filename[PATH_MAX];
|
||||
+ int fd = conf_mktemp(autoconf_name, filename);
|
||||
+ if (fd == -1)
|
||||
+ return 1;
|
||||
+ out = fdopen(fd, "w");
|
||||
if (!out)
|
||||
return 1;
|
||||
|
||||
- out_h = fopen(".tmpconfig.h", "w");
|
||||
+ name = getenv("KCONFIG_AUTOHEADER");
|
||||
+ if (!name)
|
||||
+ name = "include/generated/autoconf.h";
|
||||
+ if (make_parent_dir(name))
|
||||
+ return 1;
|
||||
+ char filename_h[PATH_MAX];
|
||||
+ int fd_h = conf_mktemp(name, filename_h);
|
||||
+ if (fd_h == -1)
|
||||
+ return 1;
|
||||
+ out_h = fdopen(fd_h, "w");
|
||||
if (!out_h) {
|
||||
fclose(out);
|
||||
return 1;
|
||||
@@ -1144,21 +1174,14 @@ int conf_write_autoconf(int overwrite)
|
||||
fclose(out);
|
||||
fclose(out_h);
|
||||
|
||||
- name = getenv("KCONFIG_AUTOHEADER");
|
||||
- if (!name)
|
||||
- name = "include/generated/autoconf.h";
|
||||
- if (make_parent_dir(name))
|
||||
- return 1;
|
||||
- if (rename(".tmpconfig.h", name))
|
||||
+ if (rename(filename_h, name))
|
||||
return 1;
|
||||
|
||||
- if (make_parent_dir(autoconf_name))
|
||||
- return 1;
|
||||
/*
|
||||
* This must be the last step, kbuild has a dependency on auto.conf
|
||||
* and this marks the successful completion of the previous steps.
|
||||
*/
|
||||
- if (rename(".tmpconfig", autoconf_name))
|
||||
+ if (rename(filename, autoconf_name))
|
||||
return 1;
|
||||
|
||||
return 0;
|
@@ -9,5 +9,4 @@
|
||||
0009-util-kconfig-Allow-emitting-false-booleans-into-kconfig-output.patch
|
||||
0010-reenable-source-in-choice.patch
|
||||
0011-remove-include-config-hardcodes.patch
|
||||
0012-safer-tmpfiles.patch
|
||||
0013-util-kconfig-detect-ncurses-on-FreeBSD.patch
|
||||
|
Reference in New Issue
Block a user