[OE-core] [PROPOSAL] Package feature switches, redux.

Chris Elston celston at katalix.com
Mon Jul 4 11:54:53 UTC 2011


Since responses to my previous mail were generally positive, I've
reworked the package feature switches so that the interface is as RP
suggested.

In the recipe for foo you would have a set of features defined like
this:

PACKAGE_CONFIG[bar] = "--enable-bar, --disable-bar, libbar"
PACKAGE_CONFIG[baz] = "--enable-baz, --disable-baz, libbaz"

The default set of features for the package would be defined with:

PACKAGE_FEATURES ?= "bar baz" 

Perhaps this set of features could go into a metadata field in the .ipk
- would this be helpful for feed users?

The package features can then be tailored in a config/layer with
something like:

PACKAGE_FEATURES_pn-foo = "baz pop"

If a layer requests a feature not supported by the recipe, you get a
warning (should help distro maintainers detect bitrot in their layer):

WARNING: foo: Unknown feature 'pop' requested

The patch below uses gstreamer as an example of something which would
benefit from this:

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 8f4ef1e..ee8e914 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -396,6 +396,30 @@ python () {
             break
 
     bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
+
+    features = bb.data.getVar('PACKAGE_FEATURES', d, True)
+    if features:
+        config = list(bb.data.getVarFlags('PACKAGE_CONFIG', d) or {})
+        oeconf = [ (bb.data.getVar('EXTRA_OECONF', d, True) or '') ]
+        depends = [ (bb.data.getVar('DEPENDS', d, True) or '') ]
+        for feature in features.split():
+            if feature in config:
+                settings = bb.data.getVarFlag('PACKAGE_CONFIG', feature, d).split(',')
+                oeconf.append(settings[0])
+                depends.append(settings[2])
+                config.remove(feature) 
+            else:
+                bb.warn("%s: Unknown feature '%s' requested" % (pn, feature))
+
+        for feature in config:
+            settings = bb.data.getVarFlag('PACKAGE_CONFIG', feature, d).split(',')
+            oeconf.append(settings[1])
+
+        if len(oeconf) > 1:
+            bb.data.setVar('EXTRA_OECONF', ' '.join(oeconf), d)
+
+        if len(depends) > 1:
+            bb.data.setVar('DEPENDS', ' '.join(depends), d)
 }
 
 def check_gcc3(data):
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.32.bb b/meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.32.bb
index f81011f..70f0171 100644
--- a/meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.32.bb
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.32.bb
@@ -6,10 +6,16 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
                     file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
                     file://gst/ffmpegcolorspace/utils.c;beginline=1;endline=20;md5=9c83a200b8e597b26ca29df20fc6ecd0"
 
-DEPENDS += "virtual/libx11 alsa-lib freetype gnome-vfs liboil libogg libvorbis libxv libtheora avahi util-linux tremor"
+DEPENDS += "virtual/libx11 alsa-lib freetype gnome-vfs liboil libxv avahi util-linux tremor"
 RDEPENDS_${PN} += "gnome-vfs-plugin-file gnome-vfs-plugin-http gnome-vfs-plugin-ftp \
              gnome-vfs-plugin-sftp"
 
+PACKAGE_CONFIG[ogg] = "--enable-ogg, --disable-ogg, libogg"
+PACKAGE_CONFIG[vorbis] = "--enable-vorbis, --disable-vorbis, libvorbis"
+PACKAGE_CONFIG[theora] = "--enable-theora, --disable-theora, libtheora"
+
+PACKAGE_FEATURES ?= "ogg vorbis theora" 
+
 SRC_URI += " file://gst-plugins-base-tremor.patch"
 
 SRC_URI[md5sum] = "2920af2b3162f3d9fbaa7fabc8ed4d38"
---

Cheers,

Chris.







More information about the Openembedded-core mailing list