The documentation on anonymous Python functions doesn't have much detail at the moment. The following two changes try to make it clearer when anonymous functions run, how their effects are seen, and how they act in corner cases: Rewrite '3.4.4. Anonymous Python Functions' as follows: Sometimes it is useful to set variables or perform other operations programmatically during parsing. To do this, you can define special Python functions, called anonymous Python functions, that run at the end of parsing. Here is an example that conditionally sets a variable based on the value of another variable: python () { if d.getVar('SOMEVAR', True) == 'value': d.setVar('ANOTHERVAR', 'value2') } An equivalent way to mark a function as an anonymous function is to give it the name "__anonymous", rather than no name. Anonymous Python functions always run at the end of parsing, regardless of where they are defined. If a recipe contains many anonymous functions, they run in the same order as they are defined within the recipe. As an example, consider the following snippet: python () { d.setVar('FOO', 'foo 2') } FOO = "foo 1" python () { d.appendVar('BAR', ' bar 2') } BAR = "bar 1" This is conceptually equivalent to the following snippet: FOO = "foo 1" BAR = "bar 1" FOO = "foo 2" BAR += "bar 2" FOO ends up with the value "foo 2", and BAR with the value "bar 1 bar 2". Just as in the second snippet, the values set for the variables within the anonymous functions become available to tasks, which always run after parsing. Overrides and override-style operators such as "_append" are applied before anonymous functions run. In the following example, FOO ends up with the value "foo from anonymous". FOO = "foo" FOO_append = " from outside" python () { d.setVar("FOO", "foo from anonymous") } See [3.10. Accessing Datastore Variables Using Python] for some methods you can use within anonymous Python functions. For a different method to run Python code during parsing, see [3.1.12. Inline Python Variable Expansion]. Add this to the end of '3.1.12. Inline Python Variable Expansion': For a different way to set variables with Python code during parsing, see [3.4.4. Anonymous Python Functions]. Cheers, Ulf
Ulf, See http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#anonymous-python-functions for the re-write of the "Anonymous Python Functions" section. See http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#inline-python-variable-expansion for the additional cross-reference in the "Inline Python Variable Expansion" section. Thanks, Scott
Looks good to me. Thanks, Ulf
Thanks - setting to RESOLVED and putting doc flag to "done." Scott
Forgot the flag.. reset to "done"