aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Traynor <wmat@alphatroop.com>2013-04-15 20:10:07 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-13 22:00:27 +0000
commit9710ffa1435268a001d371d6c213eed537cec807 (patch)
treeabef4a5fb7acffe1edbfde73d9322021f666c7fd
parentd5a611bd8ea74aeb1a4006670ed3481fac9d4701 (diff)
downloadbitbake-9710ffa1435268a001d371d6c213eed537cec807.tar.gz
bitbake-9710ffa1435268a001d371d6c213eed537cec807.tar.bz2
bitbake-9710ffa1435268a001d371d6c213eed537cec807.zip
user-manual-metadata: Added section on Functions.
Initial dump of the Functions section. Still to be refined later for grammar. Signed-off-by: Bill Traynor <wmat@alphatroop.com>
-rw-r--r--doc/user-manual/user-manual-metadata.xml77
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 7c9d3fa7..984f5965 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>