diff --git a/Tools/kconfig/loadconfig.py b/Tools/kconfig/loadconfig.py index 657e5cd9d4e..23a541d4c3f 100644 --- a/Tools/kconfig/loadconfig.py +++ b/Tools/kconfig/loadconfig.py @@ -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.