[bitbake-devel] [PATCH] codeparser: Improve handling of data.expand() dependencies

Richard Purdie richard.purdie at linuxfoundation.org
Tue Feb 2 13:54:01 UTC 2016


Currently bitbake doesn't parse into data.expand() expressions,
relying on high level expansion of python code to handle this.

One of the tests does however test this works.

We don't really want to be doing string expansion on python code,
so specifically parse into expand() function calls so that when
the high level behaviour is tweaked, the self tests continue to
pass and that we do continue to handle expand() function calls as
best we can.

Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py
index 577b427..2094f13 100644
--- a/bitbake/lib/bb/codeparser.py
+++ b/bitbake/lib/bb/codeparser.py
@@ -221,6 +221,17 @@ class PythonParser():
                     self.references.add(node.args[0].s)
             else:
                 self.warn(node.func, node.args[0])
+        elif name and name.endswith(".expand"):
+            if isinstance(node.args[0], ast.Str):
+                value = node.args[0].s
+                d = bb.data.init()
+                parser = d.expandWithRefs(value, self.name)
+                self.references |= parser.references
+                self.execs |= parser.execs
+                for varname in parser.contains:
+                    if varname not in self.contains:
+                        self.contains[varname] = set()
+                    self.contains[varname] |= parser.contains[varname]
         elif name in self.execfuncs:
             if isinstance(node.args[0], ast.Str):
                 self.var_execs.add(node.args[0].s)
@@ -243,6 +254,7 @@ class PythonParser():
                 break
 
     def __init__(self, name, log):
+        self.name = name
         self.var_execs = set()
         self.contains = {}
         self.execs = set()





More information about the bitbake-devel mailing list