dev-manual: Edits to the "Understanding Recipe Syntax" section.
(From yocto-docs rev: 97e5025ccff55efd077fdaf9b2d65eae5b59bc2b) Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
1744a1e5b9
commit
ab864d71fb
|
@ -1290,6 +1290,21 @@
|
||||||
The basic items that make up a BitBake recipe file are
|
The basic items that make up a BitBake recipe file are
|
||||||
as follows:
|
as follows:
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
<listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis>
|
||||||
|
Variable assignments allow a value to be assigned to a
|
||||||
|
variable.
|
||||||
|
The assignment can be static text or might include
|
||||||
|
the contents of other variables.
|
||||||
|
In addition to the assignment, appending and prepending
|
||||||
|
operations are also supported.</para>
|
||||||
|
<para>The following example shows some of the ways
|
||||||
|
you can use variables in recipes:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
S = "${WORKDIR}/postfix-${PV}"
|
||||||
|
CFLAGS += "-DNO_ASM"
|
||||||
|
SRC_URI_append = " file://fixup.patch"
|
||||||
|
</literallayout>
|
||||||
|
</para></listitem>
|
||||||
<listitem><para><emphasis>Functions:</emphasis>
|
<listitem><para><emphasis>Functions:</emphasis>
|
||||||
Functions provide a series of actions to be performed.
|
Functions provide a series of actions to be performed.
|
||||||
You usually use functions to override the default
|
You usually use functions to override the default
|
||||||
|
@ -1313,25 +1328,9 @@
|
||||||
new functions are not replacing or complimenting the
|
new functions are not replacing or complimenting the
|
||||||
default functions.
|
default functions.
|
||||||
You can implement functions in Python
|
You can implement functions in Python
|
||||||
instead of <filename>sh</filename>.
|
instead of shell.
|
||||||
Both of these options are not seen in the majority of
|
Both of these options are not seen in the majority of
|
||||||
recipes.</para></listitem>
|
recipes.</para></listitem>
|
||||||
<listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis>
|
|
||||||
Variable assignments allow a value to be assigned to a
|
|
||||||
variable.
|
|
||||||
The assignment can be static text or might include
|
|
||||||
the contents of other variables.
|
|
||||||
In addition to the assignment, appending and prepending
|
|
||||||
operations are also supported.</para>
|
|
||||||
<para>The following example shows some of the ways
|
|
||||||
you can use variables in recipes:
|
|
||||||
<literallayout class='monospaced'>
|
|
||||||
S = "${WORKDIR}/postfix-${PV}"
|
|
||||||
PR = "r4"
|
|
||||||
CFLAGS += "-DNO_ASM"
|
|
||||||
SRC_URI_append = "file://fixup.patch"
|
|
||||||
</literallayout>
|
|
||||||
</para></listitem>
|
|
||||||
<listitem><para><emphasis>Keywords:</emphasis>
|
<listitem><para><emphasis>Keywords:</emphasis>
|
||||||
BitBake recipes use only a few keywords.
|
BitBake recipes use only a few keywords.
|
||||||
You use keywords to include common
|
You use keywords to include common
|
||||||
|
@ -1389,7 +1388,8 @@
|
||||||
</literallayout>
|
</literallayout>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><emphasis>Quote All Assignments: <filename>"<value>"</filename></emphasis> -
|
<listitem><para><emphasis>Quote All Assignments: <filename>"<value>"</filename></emphasis> -
|
||||||
Use double quotes to make all variable assignments.
|
Use double quotes around the value in all variable
|
||||||
|
assignments.
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
VAR1 = "${OTHERVAR}"
|
VAR1 = "${OTHERVAR}"
|
||||||
VAR2 = "The version is ${PV}"
|
VAR2 = "The version is ${PV}"
|
||||||
|
@ -1401,13 +1401,14 @@
|
||||||
unset.
|
unset.
|
||||||
Use the question mark followed by the equal sign
|
Use the question mark followed by the equal sign
|
||||||
(<filename>?=</filename>) to make a "soft" assignment
|
(<filename>?=</filename>) to make a "soft" assignment
|
||||||
used for conditional assignment.</para>
|
used for conditional assignment.
|
||||||
<para>Typically, you use conditional assignment to
|
Typically, "soft" assignments are used in the
|
||||||
provide
|
<filename>local.conf</filename> file for variables
|
||||||
a default value for use when no specific definition is
|
that are allowed to come through from the external
|
||||||
provided by the machine or distro configuration in
|
environment.
|
||||||
your <filename>local.conf</filename> configuration.
|
Doing so allows you to actually set variables from
|
||||||
</para>
|
the external environment that would otherwise be
|
||||||
|
overwritten.</para>
|
||||||
<para>Here is an example:
|
<para>Here is an example:
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
VAR1 ?= "New value"
|
VAR1 ?= "New value"
|
||||||
|
@ -1455,7 +1456,9 @@
|
||||||
This operator does not add any additional space.
|
This operator does not add any additional space.
|
||||||
Also, the operator is applied after all the
|
Also, the operator is applied after all the
|
||||||
<filename>+=</filename>, and
|
<filename>+=</filename>, and
|
||||||
<filename>=+</filename> operators have been applied.
|
<filename>=+</filename> operators have been applied and
|
||||||
|
after all <filename>=</filename> assignments have
|
||||||
|
occurred.
|
||||||
</para>
|
</para>
|
||||||
<para>The following example shows the space being
|
<para>The following example shows the space being
|
||||||
explicitly added to the start to ensure the appended
|
explicitly added to the start to ensure the appended
|
||||||
|
@ -1470,26 +1473,17 @@
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
SRC_URI_append_sh4 = " file://fix-makefile.patch"
|
SRC_URI_append_sh4 = " file://fix-makefile.patch"
|
||||||
</literallayout>
|
</literallayout>
|
||||||
<note>
|
|
||||||
The appended information is a variable itself.
|
|
||||||
Therefore, it is possible to use the
|
|
||||||
<filename>+=</filename> or
|
|
||||||
<filename>=+</filename> operators to assign
|
|
||||||
variables to the <filename>_append</filename>
|
|
||||||
information:
|
|
||||||
<literallayout class='monospaced'>
|
|
||||||
SRC_URI_append = " file://fix-makefile.patch"
|
|
||||||
SRC_URI_append += "file://fix-install.patch"
|
|
||||||
</literallayout>
|
|
||||||
</note>
|
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> -
|
<listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> -
|
||||||
Use the <filename>_prepend</filename> operator to
|
Use the <filename>_prepend</filename> operator to
|
||||||
prepend values to existing variables.
|
prepend values to existing variables.
|
||||||
This operator does not add any additional space.
|
This operator does not add any additional space.
|
||||||
Also, it is applied after all the
|
This operator does not add any additional space.
|
||||||
<filename>+=</filename> and
|
Also, the operator is applied after all the
|
||||||
<filename>=+</filename> operators have been applied.
|
<filename>+=</filename>, and
|
||||||
|
<filename>=+</filename> operators have been applied and
|
||||||
|
after all <filename>=</filename> assignments have
|
||||||
|
occurred.
|
||||||
</para>
|
</para>
|
||||||
<para>The following example shows the space being
|
<para>The following example shows the space being
|
||||||
explicitly added to the end to ensure the prepended
|
explicitly added to the end to ensure the prepended
|
||||||
|
@ -1504,45 +1498,29 @@
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
CFLAGS_prepend_sh4 = " file://fix-makefile.patch"
|
CFLAGS_prepend_sh4 = " file://fix-makefile.patch"
|
||||||
</literallayout>
|
</literallayout>
|
||||||
<note>
|
|
||||||
The appended information is a variable itself.
|
|
||||||
Therefore, it is possible to use the
|
|
||||||
<filename>+=</filename> or
|
|
||||||
<filename>=+</filename> operators to assign
|
|
||||||
variables to the <filename>_prepend</filename>
|
|
||||||
information:
|
|
||||||
<literallayout class='monospaced'>
|
|
||||||
CFLAGS_prepend = "-I${S}/myincludes "
|
|
||||||
CFLAGS_prepend += "-I${S}/myincludes2 "
|
|
||||||
</literallayout>
|
|
||||||
Notice in this example no spacing is used at the
|
|
||||||
front of the value string.
|
|
||||||
Recall that the <filename>+=</filename> operator
|
|
||||||
adds space itself.
|
|
||||||
</note>
|
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><emphasis>Spaces as Compared to Tabs:</emphasis>
|
<listitem><para><emphasis>Indentation:</emphasis>
|
||||||
Use spaces for indentation rather than than tabs.
|
Use spaces for indentation rather than than tabs.
|
||||||
Both currently work, however it is a policy decision
|
For shell functions, both currently work.
|
||||||
of the Yocto Project to use tabs in shell functions
|
However, it is a policy decision of the Yocto Project
|
||||||
and spaces in Python.
|
to use tabs in shell functions.
|
||||||
However, realize that some layers use a policy of all
|
Realize that some layers have a policy to use spaces
|
||||||
spaces.
|
for all indentation.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><emphasis>Using Python for Complex Operations: <filename>${@...}</filename></emphasis> -
|
<listitem><para><emphasis>Using Python for Complex Operations: <filename>${@<variable>}</filename></emphasis> -
|
||||||
For more advanced processing, it is possible to use
|
For more advanced processing, it is possible to use
|
||||||
Python code during variable assignments (e.g.
|
Python code during variable assignments (e.g.
|
||||||
search and replacement on a variable).</para>
|
search and replacement on a variable).</para>
|
||||||
<para>You indicate Python code using a preceding
|
<para>You indicate Python code using the
|
||||||
<filename>@</filename> character in the variable
|
<filename>${@<variable>}</filename> syntax for the
|
||||||
assignment:
|
variable assignment:
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
CXXFLAGS := "${@'${CXXFLAGS}'.replace('-frename-registers', '')}"
|
SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
|
||||||
</literallayout>
|
</literallayout>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><emphasis>Shell Syntax:</emphasis>
|
<listitem><para><emphasis>Shell Function Syntax:</emphasis>
|
||||||
Use shell syntax as if you were writing a shell script
|
Use shell function syntax as if you were writing a shell
|
||||||
when you describe a list of actions to take.
|
script when you describe a list of actions to take.
|
||||||
You should ensure that your script works with a generic
|
You should ensure that your script works with a generic
|
||||||
<filename>sh</filename> and that it does not require
|
<filename>sh</filename> and that it does not require
|
||||||
any <filename>bash</filename> or other shell-specific
|
any <filename>bash</filename> or other shell-specific
|
||||||
|
|
Loading…
Reference in New Issue