Skip to contentSkip to conversation

codeparser/data: Add vardepsexclude support to module dependency code

PATCH New Richard Purdie 1 participant 1 message Dec 17, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 codeparser/data: Add vardepsexclude support to module dependency code

We need to be able to exclude dependencies from the python module dependency code. Add support for the vardepexclude flag for these. It only works from the configuration namespace rather than per recipe for efficiency.

---
 lib/bb/codeparser.py | 6 ++++++
 lib/bb/cookerdata.py | 1 +
 2 files changed, 7 insertions(+)
lib/bb/codeparser.py +6 -0
index c0b1d7966f..ecae7b0808 100644
@@ -84,6 +84,12 @@ def add_module_functions(fn, functions, namespace):
         modulecode_deps[name] = [parser.references.copy(), execs, parser.var_execs.copy(), parser.contains.copy()]
         #bb.warn("%s: %s\nRefs:%s Execs: %s %s %s" % (name, src, parser.references, parser.execs, parser.var_execs, parser.contains))
 
+def update_module_dependencies(d):
+    for mod in modulecode_deps:
+        excludes = set((d.getVarFlag(mod, "vardepsexclude") or "").split())
+        if excludes:
+            modulecode_deps[mod] = [modulecode_deps[mod][0] - excludes, modulecode_deps[mod][1] - excludes, modulecode_deps[mod][2] - excludes, modulecode_deps[mod][3]]
+
 # A custom getstate/setstate using tuples is actually worth 15% cachesize by
 # avoiding duplication of the attribute names!
 class SetCache(object):
lib/bb/cookerdata.py +1 -0
index 59ecbec69d..650ae05ec9 100644
@@ -311,6 +311,7 @@ class CookerDataBuilder(object):
             logger.exception("Error parsing configuration files")
             raise bb.BBHandledException()
 
+        bb.codeparser.update_module_dependencies(self.data)
 
         # Handle obsolete variable names
         d = self.data
Signature · 1 line
2.37.2