bitbake: ast: Warn on multiple builtin config fragments for the same variable

Having multiple builtin config fragments for the same variable
(eg OE_FRAGMENTS = "... machine/A ... machine/B") is not supported.
Warn the user to make them fix this but continue with the normal
variable evaluation : the last affectation "wins".

Added warning looks like:
WARNING: Multiple builtin fragments are enabled for machine via variable OE_FRAGMENTS: machine/qemux86-64 machine/test machine/qemux86-64. This likely points to a mis-configuration in the metadata, as only one of them should be set. The build will use the last value.

(Bitbake rev: 1c12aa23f6678dc289fc0e0d8b4dad311bd39c35)

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Yoann Congal 2025-10-10 10:29:19 +02:00 committed by Richard Purdie
parent 34f0052af3
commit b203f9146e

View File

@ -376,6 +376,27 @@ class AddFragmentsNode(AstNode):
if not fragments:
return
# Check for multiple builtin fragments setting the same variable
for builtin_fragment_key in builtin_fragments.keys():
builtin_fragments_list = list(
filter(
lambda f: f.startswith(builtin_fragment_key + "/"),
fragments.split(),
)
)
if len(builtin_fragments_list) > 1:
bb.warn(
("Multiple builtin fragments are enabled for %s via variable %s: %s. "
"This likely points to a mis-configuration in the metadata, as only "
"one of them should be set. The build will use the last value.")
% (
builtin_fragment_key,
self.fragments_variable,
" ".join(builtin_fragments_list),
)
)
for f in fragments.split():
if check_and_set_builtin_fragment(f, data, builtin_fragments):
continue