kconfig: Allow KCONFIG_STRICT outside of confdata.c

To catch dependency errors in symbol.c (such as the ones
fixed by I51b4ee326f082c6a656a813ee5772e9c34f5c343) we need
to check for global kconfig warnings before saving config
files.

This patch will produce errors for wrong dependencies and
add catching of errors to conf, nconf and mconf. Sorry,
gconf users, you will have to wait.

Change-Id: Idf7ee406ce3869941af319219aea16fab826df84
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: http://review.coreboot.org/11291
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Stefan Reinauer 2015-08-20 11:19:34 -07:00 committed by Patrick Georgi
parent 588ad7b5db
commit 57a31317a2
6 changed files with 34 additions and 5 deletions

View File

@ -17,6 +17,8 @@
#include "lkc.h" #include "lkc.h"
int kconfig_warnings = 0;
static void conf(struct menu *menu); static void conf(struct menu *menu);
static void check_conf(struct menu *menu); static void check_conf(struct menu *menu);
static void xfgets(char *str, int size, FILE *in); static void xfgets(char *str, int size, FILE *in);
@ -493,6 +495,7 @@ int main(int ac, char **av)
const char *progname = av[0]; const char *progname = av[0];
int opt; int opt;
const char *name, *defconfig_file = NULL /* gcc uninit */; const char *name, *defconfig_file = NULL /* gcc uninit */;
char *env;
struct stat tmpstat; struct stat tmpstat;
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
@ -681,6 +684,13 @@ int main(int ac, char **av)
break; break;
} }
env = getenv("KCONFIG_STRICT");
if (env && *env && kconfig_warnings) {
fprintf(stderr, _("\n*** ERROR: %d warnings encountered, and "
"warnings are errors.\n\n"), kconfig_warnings);
exit(1);
}
if (sync_kconfig) { if (sync_kconfig) {
/* silentoldconfig is used during the build so we shall update autoconf. /* silentoldconfig is used during the build so we shall update autoconf.
* All other commands are only used to generate a config. * All other commands are only used to generate a config.

View File

@ -404,11 +404,7 @@ setsym:
if (modules_sym) if (modules_sym)
sym_calc_value(modules_sym); sym_calc_value(modules_sym);
name = getenv("KCONFIG_STRICT"); kconfig_warnings += conf_warnings;
if (name && *name && conf_warnings) {
fprintf(stderr, "\nERROR: %d warnings encountered, and warnings are errors.\n\n", conf_warnings);
return 1;
}
return 0; return 0;
} }

View File

@ -82,6 +82,9 @@ void zconf_nextfiles(const char *name);
int zconf_lineno(void); int zconf_lineno(void);
const char *zconf_curname(void); const char *zconf_curname(void);
/* conf.c */
extern int kconfig_warnings;
/* confdata.c */ /* confdata.c */
const char *conf_get_configname(void); const char *conf_get_configname(void);
const char *conf_get_autoconfig_name(void); const char *conf_get_autoconfig_name(void);

View File

@ -952,6 +952,7 @@ static void conf_save(void)
static int handle_exit(void) static int handle_exit(void)
{ {
int res; int res;
char *env;
save_and_exit = 1; save_and_exit = 1;
reset_subtitle(); reset_subtitle();
@ -966,6 +967,13 @@ static int handle_exit(void)
end_dialog(saved_x, saved_y); end_dialog(saved_x, saved_y);
env = getenv("KCONFIG_STRICT");
if (env && *env && kconfig_warnings) {
fprintf(stderr, _("\n*** ERROR: %d warnings encountered, and "
"warnings are errors.\n\n"), kconfig_warnings);
res = 2;
}
switch (res) { switch (res) {
case 0: case 0:
if (conf_write(filename)) { if (conf_write(filename)) {

View File

@ -646,6 +646,8 @@ static const char *set_config_filename(const char *config_filename)
static int do_exit(void) static int do_exit(void)
{ {
int res; int res;
char *env;
if (!conf_get_changed()) { if (!conf_get_changed()) {
global_exit = 1; global_exit = 1;
return 0; return 0;
@ -661,6 +663,15 @@ static int do_exit(void)
return -1; return -1;
} }
env = getenv("KCONFIG_STRICT");
if (env && *env && kconfig_warnings) {
btn_dialog(main_window,
_("\nWarnings encountered, and warnings are errors.\n\n"),
1,
"<OK>");
res = 2;
}
/* if we got here, the user really wants to exit */ /* if we got here, the user really wants to exit */
switch (res) { switch (res) {
case 0: case 0:

View File

@ -375,6 +375,7 @@ void sym_calc_value(struct symbol *sym)
sym->name); sym->name);
expr_fprint(sym->dir_dep.expr, stderr); expr_fprint(sym->dir_dep.expr, stderr);
fprintf(stderr, ")\n"); fprintf(stderr, ")\n");
kconfig_warnings++;
expr_free(e); expr_free(e);
} }
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);