summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/ast.py
diff options
context:
space:
mode:
authorAlexander Kanavin <alex@linutronix.de>2024-12-05 18:13:38 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-12-08 22:36:11 +0000
commit3de3bda4c4b72ca21ad91c81db57bf07760e0a3b (patch)
treed742a3ffe51cd6d703f22b15335aba6214b032aa /bitbake/lib/bb/parse/ast.py
parent186b7c58d5b183228289976336a67db874e07ef5 (diff)
downloadpoky-3de3bda4c4b72ca21ad91c81db57bf07760e0a3b.tar.gz
bitbake: parse: add support for 'addfragments' directive
It takes two parameters: - location prefix for fragments - name of variable that holds the list of enabled fragments, each of them prefixed by layer id Implementation of this directive essentially expands the fragment list obtained from the variable into absolute fragment paths and hands them to the implementation of 'require'. (Bitbake rev: f687746703e7b096c5480668fd4f49bd4951182b) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse/ast.py')
-rw-r--r--bitbake/lib/bb/parse/ast.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index 001ba8d289..7abefab2c2 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -326,6 +326,37 @@ class InheritDeferredNode(AstNode):
326 inherits.append(self.inherit) 326 inherits.append(self.inherit)
327 data.setVar('__BBDEFINHERITS', inherits) 327 data.setVar('__BBDEFINHERITS', inherits)
328 328
329class AddFragmentsNode(AstNode):
330 def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable):
331 AstNode.__init__(self, filename, lineno)
332 self.fragments_path_prefix = fragments_path_prefix
333 self.fragments_variable = fragments_variable
334
335 def eval(self, data):
336 # No need to use mark_dependency since we would only match a fragment
337 # from a specific layer and there can only be a single layer with a
338 # given namespace.
339 def find_fragment(layers, layerid, full_fragment_name):
340 for layerpath in layers.split():
341 candidate_fragment_path = os.path.join(layerpath, full_fragment_name)
342 if os.path.exists(candidate_fragment_path) and bb.utils.get_file_layer(candidate_fragment_path, data) == layerid:
343 return candidate_fragment_path
344 return None
345
346 fragments = data.getVar(self.fragments_variable)
347 layers = data.getVar('BBLAYERS')
348
349 if not fragments:
350 return
351 for f in fragments.split():
352 layerid, fragment_name = f.split('/', 1)
353 full_fragment_name = data.expand("{}/{}.conf".format(self.fragments_path_prefix, fragment_name))
354 fragment_path = find_fragment(layers, layerid, full_fragment_name)
355 if fragment_path:
356 bb.parse.ConfHandler.include(self.filename, fragment_path, self.lineno, data, "include fragment")
357 else:
358 bb.error("Could not find fragment {} in enabled layers: {}".format(f, layers))
359
329def handleInclude(statements, filename, lineno, m, force): 360def handleInclude(statements, filename, lineno, m, force):
330 statements.append(IncludeNode(filename, lineno, m.group(1), force)) 361 statements.append(IncludeNode(filename, lineno, m.group(1), force))
331 362
@@ -370,6 +401,11 @@ def handleInheritDeferred(statements, filename, lineno, m):
370 classes = m.group(1) 401 classes = m.group(1)
371 statements.append(InheritDeferredNode(filename, lineno, classes)) 402 statements.append(InheritDeferredNode(filename, lineno, classes))
372 403
404def handleAddFragments(statements, filename, lineno, m):
405 fragments_path_prefix = m.group(1)
406 fragments_variable = m.group(2)
407 statements.append(AddFragmentsNode(filename, lineno, fragments_path_prefix, fragments_variable))
408
373def runAnonFuncs(d): 409def runAnonFuncs(d):
374 code = [] 410 code = []
375 for funcname in d.getVar("__BBANONFUNCS", False) or []: 411 for funcname in d.getVar("__BBANONFUNCS", False) or []: