diff mbox series

ast: Fix fragment behaviour with overrides

Message ID 20251003151425.487245-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series ast: Fix fragment behaviour with overrides | expand

Commit Message

Richard Purdie Oct. 3, 2025, 3:14 p.m. UTC
Imagine a machine fragment machine/A and a configuration which sets:

MACHINE = "B"
MACHINE:forcevariable = "C"

As I understand it, the fragment behaviour was intended to replace the
MACHINE = "B", so the override would still be active. The current code
replaces all variable overrides.

parsing=True, switches to the other behaviour, which I believe was the
design intent and the behaviour users would expect.

This is useful to allow test configurations to override a MACHINE setting
without change the fragments which would complicate the test code.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/parse/ast.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py
index 3250211e607..2a98809fa5b 100644
--- a/lib/bb/parse/ast.py
+++ b/lib/bb/parse/ast.py
@@ -363,7 +363,8 @@  class AddFragmentsNode(AstNode):
         def check_and_set_builtin_fragment(fragment, data, builtin_fragments):
             prefix, value = fragment.split('/', 1)
             if prefix in builtin_fragments.keys():
-                data.setVar(builtin_fragments[prefix], value)
+                # parsing=True since we want to emulate X=Y and allow X:override=Z to continue to exist
+                data.setVar(builtin_fragments[prefix], value, parsing=True)
                 return True
             return False