Skip to contentSkip to conversation

Add bb.data.flagAppend

DISCUSSION Richard Purdie 2 participants 2 messages Aug 5, 2010

lore
Share & tools
lore
#0 lore raw

I've been wondering what we could do to get rid of clutter in some of our class files. One thing we see a lot of is getting a flag, appending to it and saving it again. In normal syntax, =+ works great for this but that doesn't help in anonymous python. We see lots of things like:

deps = (bb.data.getVarFlag('do_package_write_ipk', 'depends', d) or "").split() deps.append('opkg-utils-native:do_populate_sysroot') deps.append('virtual/fakeroot-native:do_populate_sysroot') bb.data.setVarFlag('do_package_write_ipk', 'depends', " ".join(deps), d)

where as it would be nice just to be able to write:

bb.data.varFlagAppend('do_package_write_ipk', 'depends', "opkg-utils-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot", d)

or

deps = "opkg-utils-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot" bb.data.varFlagAppend('do_package_write_ipk', 'depends', deps, d)

if long lines make you uneasy.

Does anyone else feel such a function would be of use? It would assume space delimitation as the "=+" and "+=" operators work.

Cheers,

Richard

#1 lore raw
Quoted 19 lines · Richard Purdie

I've been wondering what we could do to get rid of clutter in some of our class files. One thing we see a lot of is getting a flag, appending to it and saving it again. In normal syntax, =+ works great for this but that doesn't help in anonymous python. We see lots of things like:

deps = (bb.data.getVarFlag('do_package_write_ipk', 'depends', d) or "").split() deps.append('opkg-utils-native:do_populate_sysroot') deps.append('virtual/fakeroot-native:do_populate_sysroot') bb.data.setVarFlag('do_package_write_ipk', 'depends', " ".join(deps), d)

where as it would be nice just to be able to write:

bb.data.varFlagAppend('do_package_write_ipk', 'depends', "opkg-utils-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot", d)

or

Quoted 9 lines

deps = "opkg-utils-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot" bb.data.varFlagAppend('do_package_write_ipk', 'depends', deps, d)

if long lines make you uneasy.

Does anyone else feel such a function would be of use? It would assume space delimitation as the "=+" and "+=" operators work.

This doesn't seem unreasonable to me. Of course, this sort of thing is quite common among variables, not just variable flags -- the fetch or "", split, modify, reset. Ideally, anything we can do from the metadata (.=, =., +=, =+, addtask, addhandler, etc) would also be just as easily done via the python API, to better facilitate testing, and to make things like this a bit easier.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics