[OE-core] can i use bitbake to run an arbitrary python routine in a class file?

Chris Larson clarson at kergoth.com
Mon Jul 2 13:44:38 UTC 2012


On Mon, Jul 2, 2012 at 6:40 AM, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
>   i'm not even remotely a python expert (working on that, though) so
> there may be a trivial and documented answer to this -- can i use
> bitbake to run an arbitrary python routine to see what the output
> would be?
>
>   for example, here's qemu.bbclass:
>
> def qemu_target_binary(data):
>         import bb
>
>         target_arch = data.getVar("TARGET_ARCH", True)
>         if target_arch in ("i486", "i586", "i686"):
>                 target_arch = "i386"
>         elif target_arch == "powerpc":
>                 target_arch = "ppc"
>
>         return "qemu-" + target_arch
>
> what if i wanted to see what that would return given a current build?
> can i do that?  does that question even make sense?

An anonymous python function is one which is automatically run at the
end of the parsing process. Alternatively, you can register an event
handler which can be run at any number of points where bitbake events
are fired, including the end of the recipe parse.

python () {
    bb.warn("qemu_target_binary: %s" % qemu_target_binary(d))
}

python print_some_value () {
    if not isinstance(e, bb.event.RecipeParsed):
        return
    bb.warn("qemu_target_binary: %s" % qemu_target_binary(e.data))
}
addhandler print_some_value

Alternatively, just do:

FOO = "${@qemu_target_binary(d)}"

And then: bitbake -e | grep \^FOO=
-- 
Christopher Larson




More information about the Openembedded-core mailing list