Skip to contentSkip to conversation

looking for feedback on writeup about class/task inheritance

DISCUSSION Robert P. J. Day 1 participant 1 message May 5, 2020

lore
Share & tools
lore
#0 lore raw

i wanted to write a tutorial on basic class/task inheritance WRT
bitbake and OE, and pull some actual examples from the OE code base in, so i threw together the following and am interested in feedback as to whether it's clear. this is just the first part -- i'm leaving out the additional usage of EXPORT_FUNCTIONS for the time being until i decide what i want it to say. (and, yes, what follows is incredibly basic ... that's the point.)

to start with, quick intro to most common tasks one will normally
inherit (initially from base.bbclass):

do_configure()
do_compile()
do_install()
do_package()

first thing to mention -- if you inherit these tasks and make absolutely no changes to them, then you get them as is. so far, so good?

next observation, you can modify inherited tasks in a couple ways.
first way is to override it in its entirety -- plenty of examples of that:

meta/recipes-core/newlib/newlib.inc:do_install() { meta/recipes-core/musl/musl_git.bb:do_install() { meta/recipes-core/musl/bsd-headers.bb:do_install() { meta/recipes-core/musl/libucontext_git.bb:do_install() { meta/recipes-core/musl/libssp-nonshared.bb:do_install() { meta/recipes-core/dropbear/dropbear.inc:do_install() { ... etc etc ...

on the other hand, you can *adjust* the inherited task with either
_append or _prepend -- once again, plenty of examples (i'll pick one to display):

meta/recipes-extended/watchdog/watchdog_5.15.bb:do_install_append() { meta/recipes-extended/iptables/iptables_1.8.4.bb:do_install_append() { meta/recipes-extended/lighttpd/lighttpd_1.4.55.bb:do_install_append() { meta/recipes-extended/libtirpc/libtirpc_1.2.6.bb:do_install_append() { meta/recipes-extended/bash/bash.inc:do_install_append () {

and, finally, one can add overrides to any and all of the above,
either for simple overriding, or combining overriding with appending or prepending:

meta/recipes-core/glibc/glibc-package.inc:do_install_armmultilib () {
...
meta/recipes-core/glibc/glibc-package.inc:do_install_append_aarch64 () { meta/recipes-core/glibc/glibc-package.inc:do_install_append_arm () { meta/recipes-core/glibc/glibc-package.inc:do_install_append_armeb () {
...

and, finally, a point i think gets very little attention, and that
is that all of this applies to non-tasks as well, like this example:

meta-environment.bb:create_sdk_files() { meta-environment-extsdk.bb:create_sdk_files_append() {

admittedly, not a lot of those, but still worth being complete in mentioning it.

that's all i'd start with, other than adding one more point -- if
one chooses to truly override an inherited function, there is no way to *also* get access to the underlying inherited function of the same name, short of the use of EXPORT_FUNCTIONS, is that correct?

does the above seem reasonable? am i missing anything important
before dragging EXPORT_FUNCTIONS into it in part two?

rday