Skip to content

Commit 4765e6f

Browse files
STABL-SWjserv
authored andcommitted
Add check for ignored configs & exit on error
- Add warning for a config you try to set but cannot due to dependencies. - Make message prefix conditional on if warnings are treated as errors or not - Exit with error if `warn_to_stderr` enabled
1 parent 8ee8e31 commit 4765e6f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

kconfiglib.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,12 @@ def _load_config(self, filename, replace):
13531353

13541354
sym.set_value(val)
13551355

1356+
if val != sym.str_value:
1357+
self._warn("{} was assigned the value '{}', but got the "
1358+
"value '{}'. Check the symbol's dependencies, and make "
1359+
"sure that it has a prompt."
1360+
.format(name, val, sym.str_value))
1361+
13561362
if replace:
13571363
# If we're replacing the configuration, unset the symbols that
13581364
# didn't get set
@@ -3995,13 +4001,15 @@ def _warn(self, msg, filename=None, linenr=None):
39954001
if not self.warn:
39964002
return
39974003

3998-
msg = "warning: " + msg
4004+
prefix = "error: " if self.warn_to_stderr else "warning: "
4005+
msg = prefix + msg
39994006
if filename is not None:
40004007
msg = "{}:{}: {}".format(filename, linenr, msg)
40014008

40024009
self.warnings.append(msg)
40034010
if self.warn_to_stderr:
40044011
sys.stderr.write(msg + "\n")
4012+
sys.exit(1)
40054013

40064014

40074015
class Symbol(object):
@@ -4892,6 +4900,8 @@ def _rec_invalidate(self):
48924900
# Invalidating MODULES has wide-ranging effects
48934901
self.kconfig._invalidate_all()
48944902
else:
4903+
# print(self)
4904+
# print("invalidated")
48954905
self._invalidate()
48964906

48974907
for item in self._dependents:

0 commit comments

Comments
 (0)