diff mbox series

[4/5] parse: Make include_all support empty variable expansions

Message ID 20250916000648.1182372-4-pkj@axis.com
State New
Headers show
Series [1/5] tests/parse: Use with statement to avoid ResourceWarning | expand

Commit Message

Peter Kjellerstedt Sept. 16, 2025, 12:06 a.m. UTC
include and require support empty variable expansions, typically used
with conditional expansions. However, include_all does not, and instead
reports an error for the first path in BBPATH.

Rewrite include_all so that its behavior matches include and require.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 bitbake/lib/bb/parse/ast.py                  | 5 ++---
 bitbake/lib/bb/parse/parse_py/ConfHandler.py | 8 ++++++--
 bitbake/lib/bb/tests/parse.py                | 1 +
 3 files changed, 9 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index 49a0788038..3250211e60 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -53,10 +53,9 @@  class IncludeAllNode(AstNode):
         Include the file and evaluate the statements
         """
         s = data.expand(self.what_file)
-        logger.debug2("CONF %s:%s: including %s", self.filename, self.lineno, s)
+        logger.debug2("CONF %s:%s: including all %s", self.filename, self.lineno, s)
 
-        for path in data.getVar("BBPATH").split(":"):
-            bb.parse.ConfHandler.include(self.filename, os.path.join(path, s), self.lineno, data, False)
+        bb.parse.ConfHandler.include(self.filename, s, self.lineno, data, False, all=True)
 
 class ExportNode(AstNode):
     def __init__(self, filename, lineno, var):
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
index 9ddbae123d..af3af2ccee 100644
--- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
@@ -56,7 +56,7 @@  def init(data):
 def supports(fn, d):
     return fn[-5:] == ".conf"
 
-def include(parentfn, fns, lineno, data, error_out):
+def include(parentfn, fns, lineno, data, error_out, all=False):
     """
     error_out: A string indicating the verb (e.g. "include", "inherit") to be
     used in a ParseError that will be raised if the file to be included could
@@ -67,7 +67,11 @@  def include(parentfn, fns, lineno, data, error_out):
 
     # "include" or "require" accept zero to n space-separated file names to include.
     for fn in fns.split():
-        include_single_file(parentfn, fn, lineno, data, error_out)
+        if all:
+            for path in data.getVar("BBPATH").split(":"):
+                include_single_file(parentfn, os.path.join(path, fn), lineno, data, error_out)
+        else:
+            include_single_file(parentfn, fn, lineno, data, error_out)
 
 def include_single_file(parentfn, fn, lineno, data, error_out):
     """
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py
index d3867ece98..2f77c90f60 100644
--- a/bitbake/lib/bb/tests/parse.py
+++ b/bitbake/lib/bb/tests/parse.py
@@ -499,6 +499,7 @@  EXTRA_OECONF:append = " foobar"
             test_helper("include_all some.conf", " foo bar")
             test_helper("include_all someother.conf", None)
             test_helper("include_all some3.conf", " foobar")
+            test_helper("include_all ${@''}", None)
 
             self.d.setVar("BBPATH", tempdir + "/conf2" + ":" + tempdir + "/conf1")