]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commit
data_smart/utils: Add 'd' to the context used for better_eval in python expansion
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 9 Jun 2016 21:33:33 +0000 (22:33 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 13 Jun 2016 11:15:55 +0000 (12:15 +0100)
commit8f74881037bb01013d3d439dc0c269909a198c1c
tree0747a3e7e3bcb5c3191fc8654182debb1e0730d4
parent6d1379c8818400e5cdc442e6142f08a110fd5b95
data_smart/utils: Add 'd' to the context used for better_eval in python expansion

If a line like:

foo=${@' '.join([d.getVar('D', True) + x for x in (' '.join([d.getVar('FILES_bash-' + p, True) or '' for p in ['lib', 'dev', 'staticdev', 'doc', 'locale', 'ptest']])).split()])}

is added to a function like do_install, it fails with Exception name 'd'
is not defined. This is due to a change of behaviour in python 3 compared
to python 2. Generator expressions, dict comprehensions  and set comprehensions
are executed in a new scope but list comprehensions in python 2.x are not. In
python 3 they all use a new scope.

To allow these kinds of expressions to work, the easiest approach is
to add 'd' to the global context. To do this, an extra optional parameter
is added to better_eval and we use that to add 'd'.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/data_smart.py
lib/bb/utils.py