From 820824f5fe33f2a3bb84f46a33056cf1c995af32 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Mon, 7 Apr 2025 15:52:44 -0600 Subject: 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 Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- bitbake/lib/bb/codeparser.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bitbake/lib/bb/codeparser.py') diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index 4bc6adbe45..4f70cf7fe7 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py @@ -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="", fixedhash=None): + def parse_python(self, node, lineno=0, filename="", 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: -- cgit v1.2.3-54-g00ecf