summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2025-06-19 14:20:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-06-20 09:52:28 +0100
commit55c4f54106514cf3a34fdcb38eac9e08335bb087 (patch)
tree205eae7e2f12edbc1b65244a6bb5951291e940cd /meta/lib
parentd56b141a4eea831eca796ee4f7d9ea5ef92af7dd (diff)
downloadpoky-55c4f54106514cf3a34fdcb38eac9e08335bb087.tar.gz
oeqa/utils/command: fast-path get_bb_var()
get_bb_var() currently end up calling 'bitbake -e' and parsing the whole output. However if postconfig isn't set then we can speed this up by just calling bitbake-getvar. The complication with failing bitbake-getvar calls is because we need to be careful to return None instead of the empty string when the variable doesn't exist. (From OE-Core rev: fafe77879aa6225aa8b5187ff590bb4998cbf987) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/commands.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 2a47f90e32..b60a6e6c38 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -285,7 +285,20 @@ def get_bb_vars(variables=None, target=None, postconfig=None):
285 return values 285 return values
286 286
287def get_bb_var(var, target=None, postconfig=None): 287def get_bb_var(var, target=None, postconfig=None):
288 return get_bb_vars([var], target, postconfig)[var] 288 if postconfig:
289 return bitbake("-e %s" % target or "", postconfig=postconfig).output
290 else:
291 # Fast-path for the non-postconfig case
292 cmd = ["bitbake-getvar", "--quiet", "--value", var]
293 if target:
294 cmd.extend(["--recipe", target])
295 try:
296 return subprocess.run(cmd, check=True, text=True, stdout=subprocess.PIPE).stdout.strip()
297 except subprocess.CalledProcessError as e:
298 # We need to return None not the empty string if the variable hasn't been set.
299 if e.returncode == 1:
300 return None
301 raise
289 302
290def get_test_layer(bblayers=None): 303def get_test_layer(bblayers=None):
291 if bblayers is None: 304 if bblayers is None: