diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml index 47691af3b3..82094b85c6 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml @@ -277,6 +277,15 @@ override syntax. + + + It is also possible to append and prepend to shell + functions and BitBake-style Python functions. + See the + "Shell Functions" and + "BitBake Style Python Functions + sections for examples. +
@@ -1090,6 +1099,56 @@ such as dash. You should not use Bash-specific script (bashisms). + + + Overrides and override-style operators like + _append and + _prepend can also be applied to + shell functions. + Most commonly, this application would be used in a + .bbappend file to modify functions in + the main recipe. + It can also be used to modify functions inherited from + classes. + + + + As an example, consider the following: + + do_foo() { + bbplain first + fn + } + + fn_prepend() { + bbplain second + } + + fn() { + bbplain third + } + + do_foo_append() { + bbplain fourth + } + + The output from do_foo + results in the following: + + recipename do_foo: first + recipename do_foo: second + recipename do_foo: third + recipename do_foo: fourth + + + Overrides and override-style operators can + be applied to any shell function, not just + tasks. + + You can use the bitbake -e recipename + command to view the final assembled function + after all overrides have been applied. +
@@ -1114,19 +1173,51 @@ Also in these types of functions, the datastore ("d") is a global variable and is always automatically available. - + + Variable expressions (e.g. ${X}) + are no longer expanded within Python functions. + This behavior is intentional in order to allow you + to freely set variable values to expandable expressions + without having them expanded prematurely. + If you do wish to expand a variable within a Python + function, use d.getVar("X", True). + Or, for more complicated expressions, use + d.expand(). + + - - Variable expressions (e.g. ${X}) are no - longer expanded within Python functions. - This behavior is intentional in order to allow you to freely - set variable values to expandable expressions without having - them expanded prematurely. - If you do wish to expand a variable within a Python function, - use d.getVar("X", True). - Or, for more complicated expressions, use - d.expand(). - + + Similar to shell functions, you can also apply overrides + and override-style operators to BitBake-style Python + functions. + + + + As an example, consider the following: + + python do_foo_prepend() { + bb.plain("first") + } + + python do_foo() { + bb.plain("second") + } + + python do_foo_append() { + bb.plain("third") + } + + The output from do_foo results + in the following: + + recipename do_foo: first + recipename do_foo: second + recipename do_foo: third + + You can use the bitbake -e recipename + command to view the final assembled function + after all overrides have been applied. +