aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/commands.py
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2016-04-29 15:55:40 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-01 16:22:45 +0100
commitc9639e6523ce8b0ce0cfa1ace9bfe8777ab07053 (patch)
tree9e1887931321063e971f3759db25d25a6d4ec6da /meta/lib/oeqa/utils/commands.py
parent58643b74eef6acfe4099b9f722d2a3f873623acd (diff)
downloadopenembedded-core-contrib-c9639e6523ce8b0ce0cfa1ace9bfe8777ab07053.tar.gz
oeqa.utils.commands: Introduce get_bb_vars()
A new function for getting values of multiple bitbake variables at the same time. (From OE-Core rev: fe3039322e2f846b336ac5af5177e9da27d79695) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/commands.py')
-rw-r--r--meta/lib/oeqa/utils/commands.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 18fe39ecfe..0297e53dcc 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -141,6 +141,39 @@ def get_bb_env(target=None, postconfig=None):
else:
return bitbake("-e", postconfig=postconfig).output
+def get_bb_vars(variables=None, target=None, postconfig=None):
+ """Get values of multiple bitbake variables"""
+ bbenv = get_bb_env(target, postconfig=postconfig)
+
+ var_re = re.compile(r'^(export )?(?P<var>[a-zA-Z]\w+)="(?P<value>.*)"$')
+ unset_re = re.compile(r'^unset (?P<var>[a-zA-Z]\w+)$')
+ lastline = None
+ values = {}
+ for line in bbenv.splitlines():
+ match = var_re.match(line)
+ val = None
+ if match:
+ val = match.group('value')
+ else:
+ match = unset_re.match(line)
+ if match:
+ # Handle [unexport] variables
+ if lastline.startswith('# "'):
+ val = lastline.split('"')[1]
+ if val:
+ var = match.group('var')
+ if variables is None:
+ values[var] = val
+ else:
+ if var in variables:
+ values[var] = val
+ variables.remove(var)
+ # Stop after all required variables have been found
+ if not variables:
+ break
+ lastline = line
+ return values
+
def get_bb_var(var, target=None, postconfig=None):
val = None
bbenv = get_bb_env(target, postconfig=postconfig)