diff mbox series

update-alternatives: Simplfy variable dependency logic

Message ID 20250605100814.3973430-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit bd8fc4c59a137a37bd7a54f398949617982d447e
Headers show
Series update-alternatives: Simplfy variable dependency logic | expand

Commit Message

Richard Purdie June 5, 2025, 10:08 a.m. UTC
When looking at bitbake parsing speed issues, I noticed a lot of weird looking
variables from the update-alternatives class. It is possible this was written
before variable dependencies could handle flags. It can handle flags now so
simplfy the code to take advantage of that and avoid the indirection variables.

The win here is a significant reduction in the number of variables, which
in turn significantly reduces the looping bitbake's taskhash calculation code
needs to do.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 .../update-alternatives.bbclass               | 34 ++++++-------------
 1 file changed, 10 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/update-alternatives.bbclass b/meta/classes-recipe/update-alternatives.bbclass
index b153e1b2973..5f40dc23ea3 100644
--- a/meta/classes-recipe/update-alternatives.bbclass
+++ b/meta/classes-recipe/update-alternatives.bbclass
@@ -73,24 +73,6 @@  UPDALTVARS  = "ALTERNATIVE ALTERNATIVE_LINK_NAME ALTERNATIVE_TARGET ALTERNATIVE_
 
 PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
 
-def gen_updatealternativesvardeps(d):
-    pkgs = (d.getVar("PACKAGES") or "").split()
-    vars = (d.getVar("UPDALTVARS") or "").split()
-
-    # First compute them for non_pkg versions
-    for v in vars:
-        for flag in sorted((d.getVarFlags(v) or {}).keys()):
-            if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
-                continue
-            d.appendVar('%s_VARDEPS' % (v), ' %s:%s' % (flag, d.getVarFlag(v, flag, False)))
-
-    for p in pkgs:
-        for v in vars:
-            for flag in sorted((d.getVarFlags("%s:%s" % (v,p)) or {}).keys()):
-                if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
-                    continue
-                d.appendVar('%s_VARDEPS_%s' % (v,p), ' %s:%s' % (flag, d.getVarFlag('%s:%s' % (v,p), flag, False)))
-
 def ua_extend_depends(d):
     if not 'virtual/update-alternatives' in d.getVar('PROVIDES'):
         d.appendVar('DEPENDS', ' virtual/${MLPREFIX}update-alternatives')
@@ -112,9 +94,6 @@  python __anonymous() {
     if not update_alternatives_enabled(d):
         return
 
-    # compute special vardeps
-    gen_updatealternativesvardeps(d)
-
     # extend the depends to include virtual/update-alternatives
     ua_extend_depends(d)
 }
@@ -124,13 +103,20 @@  def gen_updatealternativesvars(d):
     pkgs = (d.getVar("PACKAGES") or "").split()
     vars = (d.getVar("UPDALTVARS") or "").split()
 
+    # First compute them for non_pkg versions
     for v in vars:
-        ret.append(v + "_VARDEPS")
+        for flag in sorted((d.getVarFlags(v) or {}).keys()):
+            if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
+                continue
+            ret.append(v + "[" + flag + "]")
 
     for p in pkgs:
         for v in vars:
-            ret.append(v + ":" + p)
-            ret.append(v + "_VARDEPS_" + p)
+            for flag in sorted((d.getVarFlags("%s:%s" % (v,p)) or {}).keys()):
+                if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
+                    continue
+                ret.append('%s:%s' % (v,p) + "[" + flag + "]")
+
     return " ".join(ret)
 
 # Now the new stuff, we use a custom function to generate the right values