1
0
mirror of https://git.yoctoproject.org/poky synced 2026-07-15 15:37:03 +00:00

bitbake: codeparser: Add function decorators for vardeps

Adds bb.parse.vardeps bb.parse.excludevardeps function decorators that
can be used to explicitly add or exclude variables from a python
function parsed by bitbake

(Bitbake rev: 030fb3dee067640a3a50f24a53d200bdb5048376)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt
2025-04-07 15:52:44 -06:00
committed by Richard Purdie
parent af91ed1691
commit 820824f5fe
2 changed files with 44 additions and 3 deletions
+7 -3
View File
@@ -69,7 +69,7 @@ def add_module_functions(fn, functions, namespace):
name = "%s.%s" % (namespace, f)
parser = PythonParser(name, logger)
try:
parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f)
parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f, func=functions[f])
#bb.warn("Cached %s" % f)
except KeyError:
try:
@@ -87,7 +87,7 @@ def add_module_functions(fn, functions, namespace):
# Builtin
continue
src = "".join(lines)
parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f)
parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f, func=functions[f])
#bb.warn("Not cached %s" % f)
execs = parser.execs.copy()
# Expand internal module exec references
@@ -348,7 +348,7 @@ class PythonParser():
# For the python module code it is expensive to have the function text so it is
# uses a different fixedhash to cache against. We can take the hit on obtaining the
# text if it isn't in the cache.
def parse_python(self, node, lineno=0, filename="<string>", fixedhash=None):
def parse_python(self, node, lineno=0, filename="<string>", fixedhash=None, func=None):
if not fixedhash and (not node or not node.strip()):
return
@@ -390,6 +390,10 @@ class PythonParser():
if n.__class__.__name__ == "Call":
self.visit_Call(n)
if func is not None:
self.references |= getattr(func, "bb_vardeps", set())
self.references -= getattr(func, "bb_vardepsexclude", set())
self.execs.update(self.var_execs)
self.extra = None
if fixedhash: