<?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>10401</bug_id>
          
          <creation_ts>2016-10-08 00:37:30 +0000</creation_ts>
          <short_desc>Suggested fleshing out of the &apos;addtask&apos; documentation</short_desc>
          <delta_ts>2016-10-11 15:02:55 +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>11 Oct 2016: RESOLVED</status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.3 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ulfalizer</reporter>
          <assigned_to name="Scott Rifenbark">srifenbark</assigned_to>
          <cc>kergoth</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>ross.burton</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>67072</commentid>
    <comment_count>0</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-10-08 00:37:30 +0000</bug_when>
    <thetext>Here&apos;s some suggested changes to add some more details and do some cleanup  
in &apos;3.6. Tasks&apos;:

 * &apos;3.6. Tasks&apos; and &apos;3.6.1. Promoting a Function to a Task&apos; repeat
   the same example verbatim. &apos;3.6. Tasks&apos; could be shortened to just the
   introductory paragraph, and could also be simplified a bit. For example,
   addtask forces task names to start with &quot;do_&quot;, so calling it a convention
   might give the wrong idea.

   Here&apos;s a suggested new version of &apos;3.6. Tasks&apos;:

     Tasks are BitBake execution units that make up the steps that BitBake can
     run for a given recipe. Tasks are only supported in recipes and classes
     (that is, in .bb files and files included or inherited from .bb files).
     Tasks have names that start with &quot;do_&quot;.

 * &apos;3.6.1. Promoting a Function to a Task&apos; could then be rewritten as follows:

     Tasks are either
     [shell functions](https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#shell-functions)
     or
     [BitBake-style Python functions](https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#bitbake-style-python-functions)
     that have been promoted to tasks by using the &apos;addtask&apos; command. The
     &apos;addtask&apos; command can also optionally describe dependencies between the
     task and other tasks. Here is an example of a task being defined, along
     with some dependencies being declared:

       python do_printdate () {
           import time
           print time.strftime(&apos;%Y%m%d&apos;, time.gmtime())
       }
       addtask printdate after do_fetch before do_build

     The first argument to &apos;addtask&apos; is the name of the function to promote to
     a task. If the name does not start with &quot;do_&quot;, &quot;do_&quot; is added implicitly,
     which enforces the convention that all task names start with &quot;do_&quot;.

     In the example above, the &apos;do_printdate&apos; task becomes a dependency of the
     &apos;do_build&apos; task, which is the default task (the task run by &apos;bitbake&apos;
     command unless another task is specified explicitly). In addition, the
     &apos;do_printdate&apos; task becomes dependent upon the &apos;do_fetch&apos; task. Running
     the &apos;do_build&apos; task will result in the &apos;do_printdate&apos; task running first.

     Note {
     If you try out the example above, you might see &apos;do_printdate&apos; only being
     run the first time you build the recipe with &apos;bitbake&apos;. This is because
     BitBake considers the task &quot;up-to-date&quot; after that. If you want to force
     the task to always be rerun for experimentation purposes, you can make
     BitBake always consider it &quot;out-of-date&quot; by using the
     [[nostamp]](https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#variable-flags)
     variable flag, as follows:

       do_printdate[nostamp] = &quot;1&quot;

     Another option is to explicitly run the task with the &apos;-f&apos; flag, as
     follows:

       $ bitbake &lt;recipe&gt; -c printdate -f

     When manually selecting a task to run with &apos;bitbake &lt;recipe&gt; -c &lt;task&gt;&apos;,
     the &quot;do_&quot; prefix on the task can also be omitted.
     }

     You might wonder what the practical effect of using &apos;addtask&apos; without
     specifying any dependencies is, like in the following example:

       addtask printdate

     In this case, assuming dependencies have not been added through some other
     means, the only way to run the task is by explicitly selecting it with
     &apos;bitbake &lt;recipe&gt; -c printdate&apos;. The &apos;do_listtasks&apos; task can be run to
     list all the tasks defined in a recipe, using
     &apos;bitbake &lt;recipe&gt; -c listtasks&apos;.

     For more information on task dependencies, see the
     [Dependencies](https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#dependencies)
     section.

     See the
     [Variable Flags](https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#variable-flags)
     section for variable flags that can be used with tasks.

 * As an unrelated change, the [noexec] and [nostamp] description in
   &apos;3.7. Variable Flags&apos; could be clarified a bit, and a warning could be
   added:

     [noexec]: When set to &quot;1&quot;, marks the task as being empty, with no execution
               required. &lt;same as before...&gt;
  
     [nostamp]: When set to &quot;1&quot;, tells BitBake &lt;same as before...&gt;
  
                Caution {
                Any task that depends (possibly indirectly) on a [nostamp] task
                will always be executed as well. This can cause unnecessary
                rebuilding if you are not careful.
                }


Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67100</commentid>
    <comment_count>1</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-10-10 19:53:12 +0000</bug_when>
    <thetext>Ulf, 

See http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#tasks for the new 3.6 section.

See http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#promoting-a-function-to-a-task for the new 3.6.1 section.

See http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#variable-flags for the changes to the two flags.

Let me know if there are any problems or changes.

thanks, 
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67116</commentid>
    <comment_count>2</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-10-11 01:15:57 +0000</bug_when>
    <thetext>A few nits below:

 * The &quot;to&quot; sounds weird to me here:

   Here is an example that shows how to define a task and [to] declare
   some dependencies: 

 * Missing &quot;that&quot; here?

   If you try out the previous example, you might see [that] the
   do_printdata...

 * Extra &quot;the&quot; before the command here:

   the only way to run the task is by explicitly selecting it with [the]
   bitbake recipe -c printdate.


Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67141</commentid>
    <comment_count>3</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-10-11 15:02:55 +0000</bug_when>
    <thetext>Ulf, 

Thanks for the catches... See http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#promoting-a-function-to-a-task.

I am setting to RESOLVED and turning doc flag to &quot;done.&quot;

Scott</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>