Skip to contentSkip to conversation

codeparser: Improve handling of data.expand() dependencies

PATCH New Richard Purdie 1 participant 1 message Feb 2, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 codeparser: Improve handling of data.expand() dependencies

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.

bitbake/lib/bb/codeparser.py +12 -0
index 577b427..2094f13 100644
@@ -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()