summaryrefslogtreecommitdiffstats
path: root/bitbake/doc/bitbake-user-manual
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/doc/bitbake-user-manual')
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml117
1 files changed, 104 insertions, 13 deletions
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 @@
277 override syntax. 277 override syntax.
278 </note> 278 </note>
279 </para> 279 </para>
280
281 <para>
282 It is also possible to append and prepend to shell
283 functions and BitBake-style Python functions.
284 See the
285 "<link linkend='shell-functions'>Shell Functions</link>" and
286 "<link linkend='bitbake-style-python-functions'>BitBake Style Python Functions</link>
287 sections for examples.
288 </para>
280 </section> 289 </section>
281 290
282 <section id='removing-override-style-syntax'> 291 <section id='removing-override-style-syntax'>
@@ -1090,6 +1099,56 @@
1090 such as <filename>dash</filename>. 1099 such as <filename>dash</filename>.
1091 You should not use Bash-specific script (bashisms). 1100 You should not use Bash-specific script (bashisms).
1092 </para> 1101 </para>
1102
1103 <para>
1104 Overrides and override-style operators like
1105 <filename>_append</filename> and
1106 <filename>_prepend</filename> can also be applied to
1107 shell functions.
1108 Most commonly, this application would be used in a
1109 <filename>.bbappend</filename> file to modify functions in
1110 the main recipe.
1111 It can also be used to modify functions inherited from
1112 classes.
1113 </para>
1114
1115 <para>
1116 As an example, consider the following:
1117 <literallayout class='monospaced'>
1118 do_foo() {
1119 bbplain first
1120 fn
1121 }
1122
1123 fn_prepend() {
1124 bbplain second
1125 }
1126
1127 fn() {
1128 bbplain third
1129 }
1130
1131 do_foo_append() {
1132 bbplain fourth
1133 }
1134 </literallayout>
1135 The output from <filename>do_foo</filename>
1136 results in the following:
1137 <literallayout class='monospaced'>
1138 recipename do_foo: first
1139 recipename do_foo: second
1140 recipename do_foo: third
1141 recipename do_foo: fourth
1142 </literallayout>
1143 <note>
1144 Overrides and override-style operators can
1145 be applied to any shell function, not just
1146 <link linkend='tasks'>tasks</link>.
1147 </note>
1148 You can use the <filename>bitbake -e</filename>&nbsp;<replaceable>recipename</replaceable>
1149 command to view the final assembled function
1150 after all overrides have been applied.
1151 </para>
1093 </section> 1152 </section>
1094 1153
1095 <section id='bitbake-style-python-functions'> 1154 <section id='bitbake-style-python-functions'>
@@ -1114,19 +1173,51 @@
1114 Also in these types of functions, the datastore ("d") 1173 Also in these types of functions, the datastore ("d")
1115 is a global variable and is always automatically 1174 is a global variable and is always automatically
1116 available. 1175 available.
1117 </para> 1176 <note>
1118 1177 Variable expressions (e.g. <filename>${X}</filename>)
1119 <note> 1178 are no longer expanded within Python functions.
1120 Variable expressions (e.g. <filename>${X}</filename>) are no 1179 This behavior is intentional in order to allow you
1121 longer expanded within Python functions. 1180 to freely set variable values to expandable expressions
1122 This behavior is intentional in order to allow you to freely 1181 without having them expanded prematurely.
1123 set variable values to expandable expressions without having 1182 If you do wish to expand a variable within a Python
1124 them expanded prematurely. 1183 function, use <filename>d.getVar("X", True)</filename>.
1125 If you do wish to expand a variable within a Python function, 1184 Or, for more complicated expressions, use
1126 use <filename>d.getVar("X", True)</filename>. 1185 <filename>d.expand()</filename>.
1127 Or, for more complicated expressions, use 1186 </note>
1128 <filename>d.expand()</filename>. 1187 </para>
1129 </note> 1188
1189 <para>
1190 Similar to shell functions, you can also apply overrides
1191 and override-style operators to BitBake-style Python
1192 functions.
1193 </para>
1194
1195 <para>
1196 As an example, consider the following:
1197 <literallayout class='monospaced'>
1198 python do_foo_prepend() {
1199 bb.plain("first")
1200 }
1201
1202 python do_foo() {
1203 bb.plain("second")
1204 }
1205
1206 python do_foo_append() {
1207 bb.plain("third")
1208 }
1209 </literallayout>
1210 The output from <filename>do_foo</filename> results
1211 in the following:
1212 <literallayout class='monospaced'>
1213 recipename do_foo: first
1214 recipename do_foo: second
1215 recipename do_foo: third
1216 </literallayout>
1217 You can use the <filename>bitbake -e</filename>&nbsp;<replaceable>recipename</replaceable>
1218 command to view the final assembled function
1219 after all overrides have been applied.
1220 </para>
1130 </section> 1221 </section>
1131 1222
1132 <section id='python-functions'> 1223 <section id='python-functions'>