diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-04-29 15:55:40 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-01 16:22:45 +0100 |
commit | c9639e6523ce8b0ce0cfa1ace9bfe8777ab07053 (patch) | |
tree | 9e1887931321063e971f3759db25d25a6d4ec6da | |
parent | 58643b74eef6acfe4099b9f722d2a3f873623acd (diff) | |
download | poky-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>
-rw-r--r-- | meta/lib/oeqa/utils/commands.py | 33 |
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): | |||
141 | else: | 141 | else: |
142 | return bitbake("-e", postconfig=postconfig).output | 142 | return bitbake("-e", postconfig=postconfig).output |
143 | 143 | ||
144 | def get_bb_vars(variables=None, target=None, postconfig=None): | ||
145 | """Get values of multiple bitbake variables""" | ||
146 | bbenv = get_bb_env(target, postconfig=postconfig) | ||
147 | |||
148 | var_re = re.compile(r'^(export )?(?P<var>[a-zA-Z]\w+)="(?P<value>.*)"$') | ||
149 | unset_re = re.compile(r'^unset (?P<var>[a-zA-Z]\w+)$') | ||
150 | lastline = None | ||
151 | values = {} | ||
152 | for line in bbenv.splitlines(): | ||
153 | match = var_re.match(line) | ||
154 | val = None | ||
155 | if match: | ||
156 | val = match.group('value') | ||
157 | else: | ||
158 | match = unset_re.match(line) | ||
159 | if match: | ||
160 | # Handle [unexport] variables | ||
161 | if lastline.startswith('# "'): | ||
162 | val = lastline.split('"')[1] | ||
163 | if val: | ||
164 | var = match.group('var') | ||
165 | if variables is None: | ||
166 | values[var] = val | ||
167 | else: | ||
168 | if var in variables: | ||
169 | values[var] = val | ||
170 | variables.remove(var) | ||
171 | # Stop after all required variables have been found | ||
172 | if not variables: | ||
173 | break | ||
174 | lastline = line | ||
175 | return values | ||
176 | |||
144 | def get_bb_var(var, target=None, postconfig=None): | 177 | def get_bb_var(var, target=None, postconfig=None): |
145 | val = None | 178 | val = None |
146 | bbenv = get_bb_env(target, postconfig=postconfig) | 179 | bbenv = get_bb_env(target, postconfig=postconfig) |