diff options
Diffstat (limited to 'doc/user-manual/user-manual-metadata.xml')
-rw-r--r-- | doc/user-manual/user-manual-metadata.xml | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/doc/user-manual/user-manual-metadata.xml b/doc/user-manual/user-manual-metadata.xml index 7c9d3fa75..984f5965c 100644 --- a/doc/user-manual/user-manual-metadata.xml +++ b/doc/user-manual/user-manual-metadata.xml @@ -505,12 +505,14 @@ yourself.</para> unique names. </para> <para> - <screen>def get_depends(bb, d): if - d.getVar('SOMECONDITION', True): return - "dependencywithcond" else: return "dependency" - <varname>SOMECONDITION</varname> = "1" - <varname>DEPENDS</varname> = "${@get_depends(bb, - d)}" + <screen> + def get_depends(d): + if d.getVar('SOMECONDITION', True): + return "dependencywithcond" + else: + return "dependency" + SOMECONDITION = "1" + DEPENDS = "${@get_depends(d)}" </screen> </para> <para>This would result in @@ -520,7 +522,57 @@ yourself.</para> </para> </section> - <section> + <section> + <title>Functions</title> + <section> + <para> + NOTE: This is only supported in .bb and .bbclass files.</para> + <para>As with most languages, functions are the building blocks that + define operations. + Bitbake supports shell and python functions. + An example shell function definition is: + <screen> +some_function () { + echo "Hello World" +} +</screen> + +and an example python function definition is: +<screen> +python some_python_function () { + d.setVar("TEXT", "Hello World") + print d.getVar("TEXT", True) +} +</screen> +<para>In python functions, the "bb" and "os" modules are already imported, +there is no need to import those module. +The datastore, "d" is also a global variable and always available to these + functions automatically.</para> + + <para>Bitbake will execute functions of this form using bb.build.exec_func() +which can also be called from python functions to execute other functions, + either shell or python based. + Shell functions can only execute other shell functions.</para> + +<para>There is also a second way to declare python functions with parameters +which takes the form: +<screen> +def some_python_function(arg1, arg2): + print arg1 + " " + arg2 +</screen> + +The difference is that the second form takes parameters, the datastore +is not available automatically and must be passed as a parameter and +these functions are not called with exec_func() but are executed with +direct python function calls. +The "bb" and "os" modules are still automatically available and there is no +need to import them.</para> + </para> + </section> + </section> +</section> + +<section> <title>Tasks</title> <para> <emphasis>NOTE:</emphasis> @@ -675,7 +727,7 @@ yourself.</para> </section> <section> - <title>Variants</title> + <title>Variants - Class Extension Mechanism</title> <para>Two BitBake features exist to facilitate the creation of multiple buildable incarnations from a single recipe file. </para> @@ -815,5 +867,12 @@ yourself.</para> namespace. </para> </section> -</section> + </section> + + <section> + <title>Task Checksums and Setscene</title> + <section> + <para></para> + </section> + </section> </chapter> |