bitbake: bitbake-user-manual: Updated the variable expansion section.
Fixes [YOCTO #9984] Added more detail to the examples that show the effects of variable expanison. (Bitbake rev: 480096ca93c0a649ebfff68dfc7d9bbe8eb2ea2d) Signed-off-by: Scott Rifenbark <srifenbark@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
2652217970
commit
d1e3f0bb16
|
@ -50,22 +50,41 @@
|
||||||
<title>Variable Expansion</title>
|
<title>Variable Expansion</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
BitBake supports variables referencing one another's
|
Variables can reference the contents of other variables
|
||||||
contents using a syntax that is similar to shell scripting.
|
using a syntax that is similar to variable expansion in
|
||||||
Following is an example that results in <filename>A</filename>
|
Bourne shells.
|
||||||
containing "aval" and <filename>B</filename> evaluating to
|
The following assignments
|
||||||
"preavalpost" based on that current value of
|
result in A containing "aval" and B evaluating to "preavalpost".
|
||||||
<filename>A</filename>.
|
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
A = "aval"
|
A = "aval"
|
||||||
B = "pre${A}post"
|
B = "pre${A}post"
|
||||||
</literallayout>
|
</literallayout>
|
||||||
You should realize that whenever <filename>B</filename> is
|
<note>
|
||||||
referenced, its evaluation will depend on the state of
|
Unlike in Bourne shells, the curly braces are mandatory:
|
||||||
<filename>A</filename> at that time.
|
Only <filename>${FOO}</filename> and not
|
||||||
Thus, later evaluations of <filename>B</filename> in the
|
<filename>$FOO</filename> is recognized as an expansion of
|
||||||
previous example could result in different values
|
<filename>FOO</filename>.
|
||||||
depending on the value of <filename>A</filename>.
|
</note>
|
||||||
|
The "=" operator does not immediately expand variable
|
||||||
|
references in the right-hand side.
|
||||||
|
Instead, expansion is deferred until the variable assigned to
|
||||||
|
is actually used.
|
||||||
|
The result depends on the current values of the referenced
|
||||||
|
variables.
|
||||||
|
The following example should clarify this behavior:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
A = "${B} baz"
|
||||||
|
B = "${C} bar"
|
||||||
|
C = "foo"
|
||||||
|
*At this point, ${A} equals "foo bar baz"*
|
||||||
|
C = "qux"
|
||||||
|
*At this point, ${A} equals "qux bar baz"*
|
||||||
|
B = "norf"
|
||||||
|
*At this point, ${A} equals "norf baz"*
|
||||||
|
</literallayout>
|
||||||
|
Contrast this behavior with the
|
||||||
|
<link linkend='immediate-variable-expansion'>immediate variable expansion</link>
|
||||||
|
operator (i.e. ":=").
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue