fix(kconfig): fail when kconfig discards an assignment

A .px4board line whose value does not fit its symbol's type is not an error to
kconfiglib. It warns, drops the assignment, and leaves the symbol at its
default, so the loaded config quietly differs from the file and no consumer
downstream can tell. corvon 743v2 built with the wrong UAVCAN interface count
this way, and the only trace was a warning in a job that exited 0.

load_target_config() now compares kconf.warnings before and after the load and
exits on any "assignment ignored", naming the file and quoting the warning.

Checked against the whole tree: 293 targets load with none rejected, so this
does not fail existing boards. Reintroducing the quoted value makes it exit 1
with the file path and the reason.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
Ramon Roche
2026-08-20 12:10:30 -07:00
parent 8f44f9f1d3
commit 1fa6012d5d
+14 -1
View File
@@ -91,8 +91,15 @@ def enumerate_targets():
def load_target_config(kconf, px4board_path):
"""Load a target's config into kconf, replacing any previous state."""
"""Load a target's config into kconf, replacing any previous state.
Exits if the file assigns a value Kconfig cannot use. kconfiglib
downgrades that to a warning and keeps the symbol's default, so the
resulting config silently differs from what the file asks for and
nothing downstream can tell.
"""
label = os.path.basename(px4board_path)[:-len('.px4board')]
first_warning = len(kconf.warnings)
if label in STANDALONE_LABELS:
kconf.load_config(px4board_path, replace=True)
else:
@@ -100,6 +107,12 @@ def load_target_config(kconf, px4board_path):
kconf.load_config(default_config, replace=True)
kconf.load_config(px4board_path, replace=False)
ignored = [w for w in kconf.warnings[first_warning:] if 'assignment ignored' in w]
if ignored:
sys.exit('loadconfig: {}: kconfig discarded an assignment, so the config would '
'not match the file\n{}'.format(
px4board_path, '\n'.join(w.strip() for w in ignored)))
def chip_family(board_path):
"""Chip family of a board, from its NuttX defconfig.