Skip to content

Commit

Permalink
kconfig: WERROR unmet symbol dependency
Browse files Browse the repository at this point in the history
When KCONFIG_WERROR env variable is set treat unmet direct
symbol dependency as a terminal condition (error).

Suggested-by: Stefan Reinauer <reinauer@google.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Sergey Senozhatsky authored and Masahiro Yamada committed Dec 29, 2023
1 parent 5a602de commit 15d3f76
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions scripts/kconfig/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,9 @@ int main(int ac, char **av)
break;
}

if (conf_errors())
exit(1);

if (sync_kconfig) {
name = getenv("KCONFIG_NOSILENTUPDATE");
if (name && *name) {
Expand Down Expand Up @@ -890,6 +893,9 @@ int main(int ac, char **av)
break;
}

if (sym_dep_errors())
exit(1);

if (input_mode == savedefconfig) {
if (conf_write_defconfig(defconfig_file)) {
fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
Expand Down
13 changes: 8 additions & 5 deletions scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ static void conf_message(const char *fmt, ...)
static const char *conf_filename;
static int conf_lineno, conf_warnings;

bool conf_errors(void)
{
if (conf_warnings)
return getenv("KCONFIG_WERROR");
return false;
}

static void conf_warning(const char *fmt, ...)
{
va_list ap;
Expand Down Expand Up @@ -365,10 +372,9 @@ int conf_read_simple(const char *name, int def)
char *p, *val;
struct symbol *sym;
int i, def_flags;
const char *warn_unknown, *werror, *sym_name;
const char *warn_unknown, *sym_name;

warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS");
werror = getenv("KCONFIG_WERROR");
if (name) {
in = zconf_fopen(name);
} else {
Expand Down Expand Up @@ -525,9 +531,6 @@ int conf_read_simple(const char *name, int def)
free(line);
fclose(in);

if (conf_warnings && werror)
exit(1);

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions scripts/kconfig/lkc_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void conf_set_changed(bool val);
bool conf_get_changed(void);
void conf_set_changed_callback(void (*fn)(void));
void conf_set_message_callback(void (*fn)(const char *s));
bool conf_errors(void);

/* symbol.c */
extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
Expand All @@ -25,6 +26,7 @@ void print_symbol_for_listconfig(struct symbol *sym);
struct symbol ** sym_re_search(const char *pattern);
const char * sym_type_name(enum symbol_type type);
void sym_calc_value(struct symbol *sym);
bool sym_dep_errors(void);
enum symbol_type sym_get_type(struct symbol *sym);
bool sym_tristate_within_range(struct symbol *sym,tristate tri);
bool sym_set_tristate_value(struct symbol *sym,tristate tri);
Expand Down
9 changes: 9 additions & 0 deletions scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct symbol symbol_no = {

struct symbol *modules_sym;
static tristate modules_val;
static int sym_warnings;

enum symbol_type sym_get_type(struct symbol *sym)
{
Expand Down Expand Up @@ -311,6 +312,14 @@ static void sym_warn_unmet_dep(struct symbol *sym)
" Selected by [m]:\n");

fputs(str_get(&gs), stderr);
sym_warnings++;
}

bool sym_dep_errors(void)
{
if (sym_warnings)
return getenv("KCONFIG_WERROR");
return false;
}

void sym_calc_value(struct symbol *sym)
Expand Down

0 comments on commit 15d3f76

Please sign in to comment.