From e492016a7bf3932aa9f7181024a515f86618891a Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 4 Jun 2025 16:56:25 +0100 Subject: update-alternatives: Simplfy variable dependency logic 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. (From OE-Core rev: bd8fc4c59a137a37bd7a54f398949617982d447e) Signed-off-by: Richard Purdie --- meta/classes-recipe/update-alternatives.bbclass | 34 ++++++++----------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/meta/classes-recipe/update-alternatives.bbclass b/meta/classes-recipe/update-alternatives.bbclass index b153e1b297..5f40dc23ea 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 -- cgit v1.2.3-54-g00ecf