@@ -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
@@ -354,7 +354,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
@@ -396,6 +396,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:
@@ -176,4 +176,41 @@ def get_file_depends(d):
dep_files.append(os.path.abspath(fn))
return " ".join(dep_files)
+def vardeps(*varnames):
+ """
+ Function decorator that can be used to instruct the bitbake dependency
+ parsing to add a dependency on the specified variables names
+
+ Example:
+
+ @bb.parse.vardeps("FOO", "BAR")
+ def my_function():
+ ...
+
+ """
+ def inner(f):
+ if not hasattr(f, "bb_vardeps"):
+ f.bb_vardeps = set()
+ f.bb_vardeps |= set(varnames)
+ return f
+ return inner
+
+def vardepsexclude(*varnames):
+ """
+ Function decorator that can be used to instruct the bitbake dependency
+ parsing to ignore dependencies on the specified variable names in the code
+
+ Example:
+
+ @bb.parse.vardepsexclude("FOO", "BAR")
+ def my_function():
+ ...
+ """
+ def inner(f):
+ if not hasattr(f, "bb_vardepsexclude"):
+ f.bb_vardepsexclude = set()
+ f.bb_vardepsexclude |= set(varnames)
+ return f
+ return inner
+
from bb.parse.parse_py import __version__, ConfHandler, BBHandler
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 Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- bitbake/lib/bb/codeparser.py | 10 ++++++--- bitbake/lib/bb/parse/__init__.py | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-)