summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/codeparser.py
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2025-04-07 15:52:44 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-04-10 11:07:38 +0100
commit820824f5fe33f2a3bb84f46a33056cf1c995af32 (patch)
tree3e9688f24a15584e9b27e773208169a9a5f516a1 /bitbake/lib/bb/codeparser.py
parentaf91ed1691bfa5b0cdaa680a60042faaf0022aef (diff)
downloadpoky-820824f5fe33f2a3bb84f46a33056cf1c995af32.tar.gz
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>
Diffstat (limited to 'bitbake/lib/bb/codeparser.py')
-rw-r--r--bitbake/lib/bb/codeparser.py10
1 files changed, 7 insertions, 3 deletions
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):
69 name = "%s.%s" % (namespace, f) 69 name = "%s.%s" % (namespace, f)
70 parser = PythonParser(name, logger) 70 parser = PythonParser(name, logger)
71 try: 71 try:
72 parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f) 72 parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f, func=functions[f])
73 #bb.warn("Cached %s" % f) 73 #bb.warn("Cached %s" % f)
74 except KeyError: 74 except KeyError:
75 try: 75 try:
@@ -87,7 +87,7 @@ def add_module_functions(fn, functions, namespace):
87 # Builtin 87 # Builtin
88 continue 88 continue
89 src = "".join(lines) 89 src = "".join(lines)
90 parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f) 90 parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f, func=functions[f])
91 #bb.warn("Not cached %s" % f) 91 #bb.warn("Not cached %s" % f)
92 execs = parser.execs.copy() 92 execs = parser.execs.copy()
93 # Expand internal module exec references 93 # Expand internal module exec references
@@ -348,7 +348,7 @@ class PythonParser():
348 # For the python module code it is expensive to have the function text so it is 348 # For the python module code it is expensive to have the function text so it is
349 # uses a different fixedhash to cache against. We can take the hit on obtaining the 349 # uses a different fixedhash to cache against. We can take the hit on obtaining the
350 # text if it isn't in the cache. 350 # text if it isn't in the cache.
351 def parse_python(self, node, lineno=0, filename="<string>", fixedhash=None): 351 def parse_python(self, node, lineno=0, filename="<string>", fixedhash=None, func=None):
352 if not fixedhash and (not node or not node.strip()): 352 if not fixedhash and (not node or not node.strip()):
353 return 353 return
354 354
@@ -390,6 +390,10 @@ class PythonParser():
390 if n.__class__.__name__ == "Call": 390 if n.__class__.__name__ == "Call":
391 self.visit_Call(n) 391 self.visit_Call(n)
392 392
393 if func is not None:
394 self.references |= getattr(func, "bb_vardeps", set())
395 self.references -= getattr(func, "bb_vardepsexclude", set())
396
393 self.execs.update(self.var_execs) 397 self.execs.update(self.var_execs)
394 self.extra = None 398 self.extra = None
395 if fixedhash: 399 if fixedhash: