[bitbake-devel] [PATCH 3/3] data.py: sort variables being output by emit_func()
Richard Purdie
richard.purdie at linuxfoundation.org
Fri Jan 29 00:01:05 UTC 2016
On Wed, 2016-01-27 at 16:43 -0800, Andre McCurdy wrote:
> Sorting variables and separating those being exported from those
> being
> unset greatly improves the readability of OE run.do_configure, etc,
> shell scripts.
>
> Signed-off-by: Andre McCurdy <armccurdy at gmail.com>
> ---
> lib/bb/data.py | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/lib/bb/data.py b/lib/bb/data.py
> index 70ba56b..07f4bba 100644
> --- a/lib/bb/data.py
> +++ b/lib/bb/data.py
> @@ -270,7 +270,13 @@ def exported_vars(d):
> def emit_func(func, o=sys.__stdout__, d = init()):
> """Emits all items in the data store in a format such that it
> can be sourced by a shell."""
>
> - keys = (key for key in d.keys() if not key.startswith("__") and
> not d.getVarFlag(key, "func"))
> + o.write('\n')
> + keys = sorted(key for key in d.keys() if not
> key.startswith("__") and not d.getVarFlag(key, "func") and not
> d.getVarFlag(key, 'unexport'))
> + for key in keys:
> + emit_var(key, o, d, False)
> +
> + o.write('\n')
> + keys = sorted(key for key in d.keys() if not
> key.startswith("__") and not d.getVarFlag(key, "func") and
> d.getVarFlag(key, 'unexport'))
> for key in keys:
> emit_var(key, o, d, False)
FWIW d.keys() is very slow and best avoided if we can.
Since this code only generally runs at execution time rather than
parsing, its probably not a big deal but thought I'd mention it.
Cheers,
Richard
More information about the bitbake-devel
mailing list