[1/2] base: improve PACKAGECONFIG handling logic

Submitted by Ross Burton on Sept. 11, 2013, 6:17 p.m.

Details

Message ID 1378923463-31773-1-git-send-email-ross.burton@intel.com
State New
Headers show

Commit Message

Ross Burton Sept. 11, 2013, 6:17 p.m.
The existing code for handling PACKAGECONFIG lists wasn't the cleanest Python
around.  Instead of diving into the list directly using indices and lengths, use
pop() to iterate through the list.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/base.bbclass |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index dfa580c..37dc790 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -420,7 +420,7 @@  python () {
         def appendVar(varname, appends):
             if not appends:
                 return
-            if varname.find("DEPENDS") != -1:
+            if "DEPENDS_" in varname:
                 if pn.startswith("nativesdk-"):
                     appends = expandFilter(appends, "", "nativesdk-")
                 if pn.endswith("-native"):
@@ -442,12 +442,21 @@  python () {
                 bb.error("Only enable,disable,depend,rdepend can be specified!")
 
             if flag in pkgconfig:
-                if num >= 3 and items[2]:
-                    extradeps.append(items[2])
-                if num >= 4 and items[3]:
-                    extrardeps.append(items[3])
-                if num >= 1 and items[0]:
-                    extraconf.append(items[0])
+                if items:
+                    item = items.pop(0)
+                    if item:
+                        extraconf.append(item)
+                # Skip over disable
+                if items:
+                    items.pop(0)
+                if items:
+                    item = items.pop(0)
+                    if item:
+                        extradeps.append(item)
+                if items:
+                    item = items.pop(0)
+                    if item:
+                        extrardeps.append(item)
             elif num >= 2 and items[1]:
                     extraconf.append(items[1])
         appendVar('DEPENDS', extradeps)

Comments

Saul Wold Sept. 12, 2013, 3:30 a.m.
On 09/11/2013 11:17 AM, Ross Burton wrote:
> The existing code for handling PACKAGECONFIG lists wasn't the cleanest Python
> around.  Instead of diving into the list directly using indices and lengths, use
> pop() to iterate through the list.
>

I started to get some strange behaviour with building world, 
specifically, rpm-native stopped building.  You can test this by 
cleaning beecrypt-native and then try to build rpm-native.

Sau!

> Signed-off-by: Ross Burton <ross.burton@intel.com>
> ---
>   meta/classes/base.bbclass |   23 ++++++++++++++++-------
>   1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index dfa580c..37dc790 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -420,7 +420,7 @@ python () {
>           def appendVar(varname, appends):
>               if not appends:
>                   return
> -            if varname.find("DEPENDS") != -1:
> +            if "DEPENDS_" in varname:
>                   if pn.startswith("nativesdk-"):
>                       appends = expandFilter(appends, "", "nativesdk-")
>                   if pn.endswith("-native"):
> @@ -442,12 +442,21 @@ python () {
>                   bb.error("Only enable,disable,depend,rdepend can be specified!")
>
>               if flag in pkgconfig:
> -                if num >= 3 and items[2]:
> -                    extradeps.append(items[2])
> -                if num >= 4 and items[3]:
> -                    extrardeps.append(items[3])
> -                if num >= 1 and items[0]:
> -                    extraconf.append(items[0])
> +                if items:
> +                    item = items.pop(0)
> +                    if item:
> +                        extraconf.append(item)
> +                # Skip over disable
> +                if items:
> +                    items.pop(0)
> +                if items:
> +                    item = items.pop(0)
> +                    if item:
> +                        extradeps.append(item)
> +                if items:
> +                    item = items.pop(0)
> +                    if item:
> +                        extrardeps.append(item)
>               elif num >= 2 and items[1]:
>                       extraconf.append(items[1])
>           appendVar('DEPENDS', extradeps)
>