@@ -1052,6 +1052,9 @@ bitbake will treat that as direct value assignment in its configuration::
SOMEVARIABLE = "somevalue"
+``addfragments`` can be called more than once with the same arguments.
+Fragments that have already been applied are not applied again.
+
Locating Include Files
----------------------
@@ -228,6 +228,22 @@ def findTopdir():
return os.path.abspath(os.getcwd())
+
+def check_fragment_recommendations(d):
+ """
+ Warn about recommended fragments which aren't enabled or opted out.
+ """
+ enabled = d.getVar("_BB_FRAGMENTS_ENABLED")
+ if enabled is None:
+ return
+ enabled = set(enabled.split())
+ layerdata = d.getVar("layerdata", expand=False) or {}
+ optedout = set((d.getVar("LAYER_FRAGMENTS_OPTED_OUT") or "").split())
+ for layer in layerdata:
+ wanted = layerdata[layer].fragment_recommends_any - optedout
+ if wanted and not (wanted & enabled):
+ bb.warn("Layer %s recommends one of the fragments %s to be enabled but none are" % (layer, str(wanted)))
+
@dataclasses.dataclass(repr=False)
class Layer:
path: str
@@ -663,6 +679,8 @@ class CookerDataBuilder(object):
for p in postfiles:
data = parse_config_file(p, data)
+ check_fragment_recommendations(data)
+
# Handle any INHERITs and inherit the base class
bbclasses = ["base"] + (data.getVar('INHERIT') or "").split()
for bbclass in bbclasses:
@@ -394,11 +394,11 @@ class AddFragmentsNode(AstNode):
builtin_fragments = {f[0]:f[1] for f in [f.split(':') for f in data.getVar(self.builtin_fragments_variable).split()] }
layerdata = data.getVar("layerdata", expand=False)
- optedout = set((data.getVar("LAYER_FRAGMENTS_OPTED_OUT") or "").split())
- for layer in layerdata:
- wanted = layerdata[layer].fragment_recommends_any - optedout
- if wanted and not (wanted & set(fragments)):
- bb.warn("Layer %s recommends one of the fragments %s to be enabled but none are" % (layer, str(wanted)))
+
+ # addfragments can be called more than once, only apply fragments once
+ enabled = (data.getVar("_BB_FRAGMENTS_ENABLED") or "").split()
+ fragments = [f for f in fragments if f not in enabled]
+ data.setVar("_BB_FRAGMENTS_ENABLED", " ".join(enabled + fragments))
if not fragments:
return
Since it was implemented, one probably that has been tricky is that distros can't enable fragments since the distro itself can be selected by a fragment. Work around this by allowing the addfragments call to be called more than once. Fragments are only applied the first time they are seen. This means the recommends checks have to happen after bitbake.conf is parsed. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- .../bitbake-user-manual-metadata.rst | 3 +++ lib/bb/cookerdata.py | 18 ++++++++++++++++++ lib/bb/parse/ast.py | 10 +++++----- 3 files changed, 26 insertions(+), 5 deletions(-)