<?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>3890</bug_id>
          
          <creation_ts>2013-02-14 11:24:17 +0000</creation_ts>
          <short_desc>@contains does not create vardep automatically</short_desc>
          <delta_ts>2013-04-12 16:50:32 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>1.4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Martin Jansa">Martin.Jansa</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>29796</commentid>
    <comment_count>0</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2013-02-14 11:24:17 +0000</bug_when>
    <thetext>tested with all 3 &quot;contains&quot; variants
oe.utils.contains
base_contains (calls oe.utils.contains)
bb.utils.contains (same code as oe.utils.contains)

When I use 
FOO=&quot;${@oe.utils.contains(&apos;BAR&apos;, &apos;1&apos;, &apos;YES&apos;, &apos;NO&apos;)}&quot;
it would be convenient to automatically detect FOO dependency on BAR as variable.

Real world example:

foo.bb:
RDEPENDS_${PN} = &quot;${@oe.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;bar&apos;, &apos;man&apos;, &apos;&apos;, d)}&quot;

This scenario currently works very badly:
1) do_package checksum is not changed when DISTRO_FEATURES gets or loose &apos;bar&apos;, because expression looks the same and foo.do_package does not depend on DISTRO_FEATURES variable
2) do_package_write checksum is changed, because new deptask is found as reported by bitbake-diffsigs:
Dependency on task man.do_packagedata was added with hash deadcafe 
so user sees do_package_write and e.g. do_package_write_ipk executed, but &apos;Depends&apos; field in .ipk is the same, because do_packagedata/emit_pkgdata wasn&apos;t reexecuted to write new RDEPENDS value.

There is simple work around to add explicit vardep
RDEPENDS_foo[vardep] += &quot;DISTRO_FEATURES&quot;
but that&apos;s not really intuitive, easy to forget and hard to find out later when you just notice on target that some incremental builds behave different then other.

Also RDEPENDS_${PN}[vardep] += &quot;DISTRO_FEATURES&quot; does not seem to work.

Can we record this dependency somehow automatically?

I can probably add something like
def append_contains(variable, checkvariable, checkvalues, truevalue, falsevalue, d):
    d.appendVar(variable, base_contains(checkvariable, checkvalues, truevalue, falsevalue, d)
    d.appendVarFlag(variable, &apos;vardeps&apos;, checkvariable)

or

def base_contains_with_vardep(variable, checkvariable, checkvalues, truevalue, falsevalue, d):
    d.appendVarFlag(variable, &apos;vardeps&apos;, checkvariable)
    base_contains(checkvariable, checkvalues, truevalue, falsevalue, d)

RDEPENDS_${PN} = &quot;${@base_contains_wit_vardep(&apos;RDEPENDS_foo&apos;, &apos;DISTRO_FEATURES&apos;, &apos;bar&apos;, &apos;man&apos;, &apos;&apos;, d)}&quot;

But I hope there is better simpler solution :).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29802</commentid>
    <comment_count>1</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2013-02-14 11:37:47 +0000</bug_when>
    <thetext>This one is simpler for sure..
(the same as base_contains without first line to getVar(variable))

${@val_contains(&quot;${DISTRO_FEATURES}&quot;, &apos;bar&apos;, &apos;man&apos;, &apos;&apos;, d)}

Other ideas?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29844</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-02-14 21:51:30 +0000</bug_when>
    <thetext>See how this works:

diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py
index 979e6bd..78f82e1 100644
--- a/bitbake/lib/bb/codeparser.py
+++ b/bitbake/lib/bb/codeparser.py
@@ -101,6 +101,7 @@ class BufferedLogger(Logger):
 
 class PythonParser():
     getvars = (&quot;d.getVar&quot;, &quot;bb.data.getVar&quot;, &quot;data.getVar&quot;, &quot;d.appendVar&quot;, &quot;d.prependVar&quot;)
+    containsfuncs = (&quot;bb.utils.contains&quot;, &quot;base_contains&quot;, &quot;oe.utils.contains&quot;)
     execfuncs = (&quot;bb.build.exec_func&quot;, &quot;bb.build.exec_task&quot;)
 
     def warn(self, func, arg):
@@ -119,7 +120,7 @@ class PythonParser():
 
     def visit_Call(self, node):
         name = self.called_node_name(node.func)
-        if name in self.getvars:
+        if name in self.getvars or name in self.containsfuncs:
             if isinstance(node.args[0], ast.Str):
                 self.var_references.add(node.args[0].s)
             else:</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29847</commentid>
    <comment_count>3</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2013-02-15 04:20:50 +0000</bug_when>
    <thetext>For some reason this isn&apos;t enough, bitbake-diffsigs does not show new dependency and task checksum is the same with or without bar in DISTRO_FEATURES.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29850</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-02-15 11:35:02 +0000</bug_when>
    <thetext>I did some experimentation. I can&apos;t make it work properly with base_contains since it doesn&apos;t track the variable reference properly however if I instead do:

--- a/meta/recipes-kernel/latencytop/latencytop_0.5.bb
+++ b/meta/recipes-kernel/latencytop/latencytop_0.5.bb
@@ -15,7 +15,7 @@ SRC_URI = &quot;http://www.latencytop.org/download/latencytop-${PV}.tar.gz \
 SRC_URI[md5sum] = &quot;73bb3371c6ee0b0e68e25289027e865c&quot;
 SRC_URI[sha256sum] = &quot;9e7f72fbea7bd918e71212a1eabaad8488d2c602205d2e3c95d62cd57e9203ef&quot;
 
-EXTRA_OEMAKE_X = &quot;${@base_contains(&apos;DISTRO_FEATURES&apos;, &apos;x11&apos;, &apos;HAS_GTK_GUI=1&apos;, &apos;&apos;, d)}&quot;
+EXTRA_OEMAKE_X = &quot;${@oe.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;x11&apos;, &apos;HAS_GTK_GUI=1&apos;, &apos;&apos;, d)}&quot;
 
 CFLAGS += &quot;${LDFLAGS}&quot;
 
then this does track the reference properly with the patch I attached. I&apos;m tempted just to remove base_contains since it is just an old wrapper...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29851</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-02-15 11:42:57 +0000</bug_when>
    <thetext>A further update - there is a cache issue here. The patch does work and *does* need the base_contains. You need to rm tmp/cache/bb_codeparser.dat for the changes to be visible though since the cache gets in the way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29853</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-02-15 12:33:20 +0000</bug_when>
    <thetext>Fixed with http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=f966c544aa4da61a19bc0d751c2bbf0f66028791 (now including cache version bump)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29872</commentid>
    <comment_count>7</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2013-02-15 21:42:23 +0000</bug_when>
    <thetext>Confirmed on my use-case with base_contains. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29873</commentid>
    <comment_count>8</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2013-02-15 21:42:55 +0000</bug_when>
    <thetext>Is this something we can backport to danny?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29875</commentid>
    <comment_count>9</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-02-15 23:00:50 +0000</bug_when>
    <thetext>cc&apos;d to the danny maintainer. We need to test this in master a while first but in theory the patch would apply easily enough. Probably some other bitbake fixes we could pull onto the stable branch I guess.

Only concern is this will change all the sstate checksums but we&apos;ve probably changed enough in the point release anyway to make that a lesser consideration...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32084</commentid>
    <comment_count>10</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2013-04-12 16:13:08 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; cc&apos;d to the danny maintainer. We need to test this in master a while first
&gt; but in theory the patch would apply easily enough. Probably some other
&gt; bitbake fixes we could pull onto the stable branch I guess.
&gt; 
&gt; Only concern is this will change all the sstate checksums but we&apos;ve probably
&gt; changed enough in the point release anyway to make that a lesser
&gt; consideration...

Ross, can you cherry-pick 
767b4751232f4ee3979deb4d3f733fcf9ee2bd44
0b9d117631ce909312d53b93289e61defc6be01c
to bitbake-1.16?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32087</commentid>
    <comment_count>11</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2013-04-12 16:24:49 +0000</bug_when>
    <thetext>Richard has to do the bitbake cherry-picking.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32089</commentid>
    <comment_count>12</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-04-12 16:50:32 +0000</bug_when>
    <thetext>cherry-picked to 1.16</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>