<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>10093</bug_id>
          
          <creation_ts>2016-08-05 02:45:00 +0000</creation_ts>
          <short_desc>Suggested fleshing out of the anonymous function documentation</short_desc>
          <delta_ts>2016-08-08 20:42:52 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>BitBake User Manual</product>
          <component>bitbake-manual</component>
          <version>2.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>08 August 2016: RESOLVED</status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.2 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ulfalizer</reporter>
          <assigned_to name="Scott Rifenbark">srifenbark</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>srifenbark</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Done (doc changes complete)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>64927</commentid>
    <comment_count>0</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-05 02:45:00 +0000</bug_when>
    <thetext>The documentation on anonymous Python functions doesn&apos;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 &apos;3.4.4. Anonymous Python Functions&apos; 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(&apos;SOMEVAR&apos;, True) == &apos;value&apos;:
               d.setVar(&apos;ANOTHERVAR&apos;, &apos;value2&apos;)
       }
  
  An equivalent way to mark a function as an anonymous function is to give it
  the name &quot;__anonymous&quot;, 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(&apos;FOO&apos;, &apos;foo 2&apos;)
      }
  
      FOO = &quot;foo 1&quot;
  
      python () {
          d.appendVar(&apos;BAR&apos;, &apos; bar 2&apos;)
      }
  
      BAR = &quot;bar 1&quot;
  
  This is conceptually equivalent to the following snippet:
  
      FOO = &quot;foo 1&quot;
      BAR = &quot;bar 1&quot;
      FOO = &quot;foo 2&quot;
      BAR += &quot;bar 2&quot;
  
  FOO ends up with the value &quot;foo 2&quot;, and BAR with the value &quot;bar 1 bar 2&quot;. 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 &quot;_append&quot; are applied before
  anonymous functions run. In the following example, FOO ends up with the value
  &quot;foo from anonymous&quot;.
  
      FOO = &quot;foo&quot;
      FOO_append = &quot; from outside&quot;
  
      python () {
          d.setVar(&quot;FOO&quot;, &quot;foo from anonymous&quot;)
      }
  
  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 &apos;3.1.12. Inline Python Variable Expansion&apos;:

  For a different way to set variables with Python code during parsing, see
  [3.4.4. Anonymous Python Functions].


Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64951</commentid>
    <comment_count>1</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-08 15:53:26 +0000</bug_when>
    <thetext>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 &quot;Anonymous Python Functions&quot; 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 &quot;Inline Python Variable Expansion&quot; section.

Thanks, 
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64960</commentid>
    <comment_count>2</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-08 19:24:02 +0000</bug_when>
    <thetext>Looks good to me.

Thanks,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64967</commentid>
    <comment_count>3</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-08 20:42:33 +0000</bug_when>
    <thetext>Thanks - setting to RESOLVED and putting doc flag to &quot;done.&quot;

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64968</commentid>
    <comment_count>4</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-08 20:42:52 +0000</bug_when>
    <thetext>Forgot the flag.. reset to &quot;done&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>