Disclaimer: I am no Bitbake expert. I just put this together by rummaging
through the Bitbake code for a couple of minutes. I am reasonably confident
that what I am saying below is rather accurate but the Bitbake experts know

Indeed it is.  One of my first tasks will be to *remove* as much as
> possible from this until the only thing it does is print out "Hello,
> World!"  I'll be happy to share my results if anyone is interested.
> You can just do a recipe and overwrite do_build() in it e.g.

python do_build() {
    bb.note("Hello World")

> If I understand correctly, the name of the task is "build", and the name
> of the Python function that implements it is "do_build()".  So, it appears
> BitBake prefixes all task names with "do_" to derive the name of the
> function that implements the task.  Have I got that right?

Yes. All tasks defined in recipes or classes have to follow the naming
convention do_<taskname> when defining them. However, when adding them to
the queue you have to omit the do_ e.g. addtask <taskname>.

>  The "build" task is *required*, and it's the *only* one that's required?

No task is really required. The build task is only the default task if you
do not specify a specific task with -c. However, if you use -c Bitbake will
only execute that task and not check and run any task that this task is
depending on. But that's a whole different story.

>  I've been looking around in the BitBake source code a lot, so I'm
> *somewhat* familiar with it.  I tried to find the "hard" reference to
> "do_build" you described,  but I couldn't.  Can you give me a hint?
> In <bitbakedir>/lib/bb/cooker.py:

class BBCooker:
    Manages one bitbake build run

    def __init__(self, configuration, server_registration_cb):

        # stuff omitted

        if not self.configuration.cmd:
            self.configuration.cmd = bb.data.getVar("BB_DEFAULT_TASK",
self.configuration.data, True) or "build"

      # more stuff

Bitbake checks if the variable BB_DEFAULT_TASK is set and if not uses
"build" as default task. You could set BB_DEFAULT_TASK in a configuration
file e.g. bitbake.conf to any task you like (as long as it is defined).

>  I see here that you're creating the recipe-specific "do_fetch()"
> function, which seems intended to "override" the default "do_fetch()"
> provided by the base class.  This prompts some questions:

My  base.bbclass file does not have a do_fetch function. What am I missing?

>  1) Must a "task function" be a Python function?  Or will a bash function
> do?

Tasks must be Python functions.

>  2) Is it absolutely necessary to follow a recipe-specific task function
> with an "addtask"?  Based on experience from "real" object-oriented
> languages, a naive observer (like me) would guess the simple presence of
> "do_fetch()" in the recipe is all that's necessary.  Or is it the "addtask"
> that actually "slots" the new function in?
>   You have to use addtask to make your Python function, given it follows
the naming convention, known to Bitbake as a task. You can put addtask with
the tasks name anywhere in your recipe. It does not need to follow the task
but it makes it easier to read. If you just add a task using addtask it is
kind of standalone. If you use addtask with the before/after directives you
establish an execution order.

yocto mailing list

Reply via email to