Skip to contentSkip to conversation

base: improve PACKAGECONFIG handling logic

PATCH In review Ross Burton 2 participants 4 messages Sep 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 base: improve PACKAGECONFIG handling logic

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.

---
 meta/classes/base.bbclass |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
meta/classes/base.bbclass +10 -7
index dfa580c..12c8741 100644
@@ -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,15 @@ 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:
+                    extraconf.append(items.pop(0))
+                # Skip over disable
+                if items:
+                    items.pop(0)
+                if items:
+                    extradeps.append(items.pop(0))
+                if items:
+                    extrardeps.append(items.pop(0))
             elif num >= 2 and items[1]:
                     extraconf.append(items[1])
         appendVar('DEPENDS', extradeps)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/2 base: add RRECOMMENDS to PACKAGECONFIG

Add a fifth optional element of the PACKAGECONFIG flags that can be used to set RRECOMMENDS_${PN}.

---
 meta/classes/base.bbclass |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
meta/classes/base.bbclass +8 -4
index 12c8741..651512a 100644
@@ -394,7 +394,7 @@ python () {
     # These take the form:
     #
     # PACKAGECONFIG ??= "<default options>"
-    # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends"
+    # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends,foo_runtime_recommends"
     pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {}
     if pkgconfigflags:
         pkgconfig = (d.getVar('PACKAGECONFIG', True) or "").split()
@@ -420,7 +420,7 @@ python () {
         def appendVar(varname, appends):
             if not appends:
                 return
-            if "DEPENDS_" in varname:
+            if "DEPENDS_" in varname or "RRECOMMENDS_" in varname:
                 if pn.startswith("nativesdk-"):
                     appends = expandFilter(appends, "", "nativesdk-")
                 if pn.endswith("-native"):
@@ -432,14 +432,15 @@ python () {
 
         extradeps = []
         extrardeps = []
+        extrarrecs = []
         extraconf = []
         for flag, flagval in pkgconfigflags.items():
             if flag == "defaultval":
                 continue
             items = flagval.split(",")
             num = len(items)
-            if num > 4:
-                bb.error("Only enable,disable,depend,rdepend can be specified!")
+            if num > 5:
+                bb.error("Only enable,disable,depend,rdepend,rrecommend can be specified!")
 
             if flag in pkgconfig:
                 if items:
@@ -451,10 +452,13 @@ python () {
                     extradeps.append(items.pop(0))
                 if items:
                     extrardeps.append(items.pop(0))
+                if items:
+                    extrarrecs.append(items.pop(0))
             elif num >= 2 and items[1]:
                     extraconf.append(items[1])
         appendVar('DEPENDS', extradeps)
         appendVar('RDEPENDS_${PN}', extrardeps)
+        appendVar('RRECOMMENDS_${PN}', extrarrecs)
         if bb.data.inherits_class('cmake', d):
             appendVar('EXTRA_OECMAKE', extraconf)
         else:
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to Ross Burton
Quoted 5 lines · Ross Burton
meta/classes/base.bbclass +0 -5
-                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]:

meta/classes/base.bbclass python () { · line 453

Quoted 10 lines
meta/classes/base.bbclass +9 -1
-                    extraconf.append(items[0])
+                if items:
+                    extraconf.append(items.pop(0))
+                # Skip over disable
+                if items:
+                    items.pop(0)
+                if items:
+                    extradeps.append(items.pop(0))
+                if items:
+                    extrardeps.append(items.pop(0))

I should note that in a PACKAGECONFIG[foo] such as ",,,foo" this will add some whitespace to EXTRA_OECONF and DEPENDS. If this is a massive concern I can sort it, but the clear code trumps the odd extra whitespace in my mind.

Ross

#3 lore raw
Quoted 17 lines · Ross
Quoted 5 lines · Ross Burton
meta/classes/base.bbclass +0 -5
-                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]:

meta/classes/base.bbclass python () { · line 453

Quoted 10 lines
meta/classes/base.bbclass +9 -1
-                    extraconf.append(items[0])
+                if items:
+                    extraconf.append(items.pop(0))
+                # Skip over disable
+                if items:
+                    items.pop(0)
+                if items:
+                    extradeps.append(items.pop(0))
+                if items:
+                    extrardeps.append(items.pop(0))
Quoted 4 lines

I should note that in a PACKAGECONFIG[foo] such as ",,,foo" this will add some whitespace to EXTRA_OECONF and DEPENDS. If this is a massive concern I can sort it, but the clear code trumps the odd extra whitespace in my mind.

EXTRA_OECONF/DEPENDS space will probably force do_compile/do_install tasks to execute again, while RDEPENDS/RRECOMMENDS only PACKAGECONFIGs could be enabled with only do_package re-executed.

I don't know how many PACKAGECONFIG options we have without first 3 parameters, but in your example with foo it would be significant change.

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]