Patchwork classes: Apply libc-${LIBC} overrides to target recipes only

login
register
mail settings
Submitter Khem Raj
Date Nov. 29, 2011, 10:46 p.m.
Message ID <1322606818-2817-1-git-send-email-raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/15653/
State New
Headers show

Comments

Khem Raj - Nov. 29, 2011, 10:46 p.m.
Currently these overrides are enabled for native and nativesdk
recipes as well when inheriting native and nativesdk classes. This patch
filters these from OVERRIDES variables for native and nativesdk
recipes.

oe_filter_out and oe_filter functions currently only operated on
space separated strings. Since OVERRIDES are separated using ':'
these functions are enhanced to take and additional parameter
called 'sep' which defaults to None if not specified which means we keep
the existing behaviour.

Drop the last parameter 'd' from filter functions since it was not being
used.

adjust uclibc and gcc-runtime recipes to follow new signatures of
oe_fiter functions.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/classes/native.bbclass                        |    5 +++--
 meta/classes/nativesdk.bbclass                     |    5 +++--
 meta/classes/utils.bbclass                         |    8 ++++----
 meta/lib/oe/utils.py                               |   14 ++++++++++----
 meta/recipes-core/uclibc/uclibc.inc                |    6 +++---
 .../recipes-devtools/gcc/gcc-configure-runtime.inc |    2 +-
 6 files changed, 24 insertions(+), 16 deletions(-)
Richard Purdie - Nov. 30, 2011, 11:26 p.m.
On Tue, 2011-11-29 at 14:46 -0800, Khem Raj wrote:
> Currently these overrides are enabled for native and nativesdk
> recipes as well when inheriting native and nativesdk classes. This patch
> filters these from OVERRIDES variables for native and nativesdk
> recipes.
> 
> oe_filter_out and oe_filter functions currently only operated on
> space separated strings. Since OVERRIDES are separated using ':'
> these functions are enhanced to take and additional parameter
> called 'sep' which defaults to None if not specified which means we keep
> the existing behaviour.
> 
> Drop the last parameter 'd' from filter functions since it was not being
> used.

This last piece worries me a lot. It requires a flag day where everyone
changes, particularly layers. I don't think that is something that is
acceptable.

I'd like to think simpler. How about we change tclibc*.inc to do
something like:

LIBCOVERRIDE = ":libc-glibc"
OVERRIDES .= "${LIBCOVERRIDE}"

and then native.bbclass can just do:

LIBCOVERRIDE = ""

Cheers,

Richard
Khem Raj - Nov. 30, 2011, 11:33 p.m.
On Wed, Nov 30, 2011 at 3:26 PM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> I'd like to think simpler. How about we change tclibc*.inc to do
> something like:
>
> LIBCOVERRIDE = ":libc-glibc"
> OVERRIDES .= "${LIBCOVERRIDE}"
>
> and then native.bbclass can just do:
>
> LIBCOVERRIDE = ""

OK let me experiment with this.

Patch

diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclass
index 8f7cc1f..270b4f3 100644
--- a/meta/classes/native.bbclass
+++ b/meta/classes/native.bbclass
@@ -138,8 +138,9 @@  python native_virtclass_handler () {
         if not prov.endswith("-native"):
             provides = provides.replace(prov, prov + "-native")
     e.data.setVar("PROVIDES", provides)
-
-    e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + ":virtclass-native")
+    overrides = e.data.getVar("OVERRIDES", False);
+    overrides = oe_filter_out('libc-uclibc|libc-glibc', overrides, ':')
+    e.data.setVar("OVERRIDES",overrides + ":virtclass-native")
 }
 
 addhandler native_virtclass_handler
diff --git a/meta/classes/nativesdk.bbclass b/meta/classes/nativesdk.bbclass
index e6204c0..0f897a9 100644
--- a/meta/classes/nativesdk.bbclass
+++ b/meta/classes/nativesdk.bbclass
@@ -65,8 +65,9 @@  python nativesdk_virtclass_handler () {
     pn = e.data.getVar("PN", True)
     if not pn.endswith("-nativesdk"):
         return
-
-    e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + ":virtclass-nativesdk")
+    overrides = e.data.getVar("OVERRIDES", False)
+    oe_filter_out('libc-uclibc|libc-glibc', overrides, ':')
+    e.data.setVar("OVERRIDES",overrides + ":virtclass-nativesdk")
 }
 
 python () {
diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index 103fa9a..6311017 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -32,11 +32,11 @@  def base_both_contain(variable1, variable2, checkvalue, d):
 def base_prune_suffix(var, suffixes, d):
     return oe.utils.prune_suffix(var, suffixes, d)
 
-def oe_filter(f, str, d):
-    return oe.utils.str_filter(f, str, d)
+def oe_filter(f, str, sep = None):
+    return oe.utils.str_filter(f, str, sep)
 
-def oe_filter_out(f, str, d):
-    return oe.utils.str_filter_out(f, str, d)
+def oe_filter_out(f, str, sep = None):
+    return oe.utils.str_filter_out(f, str, sep)
 
 def machine_paths(d):
     """List any existing machine specific filespath directories"""
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 95daace..3e321fc 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -66,13 +66,19 @@  def prune_suffix(var, suffixes, d):
 
     return var
 
-def str_filter(f, str, d):
+def str_filter(f, str, sep = None):
     from re import match
-    return " ".join(filter(lambda x: match(f, x, 0), str.split()))
+    if sep is None or sep is '':
+	return " ".join(filter(lambda x: match(f, x, 0), str.split()))
+    else:
+	return sep.join(filter(lambda x: match(f, x, 0), str.split(sep)))
 
-def str_filter_out(f, str, d):
+def str_filter_out(f, str, sep = None):
     from re import match
-    return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
+    if sep is None or sep is '':
+	return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
+    else:
+	return sep.join(filter(lambda x: not match(f, x, 0), str.split(sep)))
 
 def param_bool(cfg, field, dflt = None):
     """Lookup <field> in <cfg> map and convert it to a boolean; take
diff --git a/meta/recipes-core/uclibc/uclibc.inc b/meta/recipes-core/uclibc/uclibc.inc
index 92157bd..5845519 100644
--- a/meta/recipes-core/uclibc/uclibc.inc
+++ b/meta/recipes-core/uclibc/uclibc.inc
@@ -112,9 +112,9 @@  export V="2"
 # -O<n> -fno-omit-frame-pointer ends up with GCC ICE on thumb as reported
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44860
 #
-CFLAGS_arm := "${@oe_filter_out('-fno-omit-frame-pointer', '${CFLAGS}', d)}"
-UCLIBC_EXTRA_CFLAGS  := "${@oe_filter_out('(-I\S+|-i\S+)', '${CFLAGS}', d)}"
-UCLIBC_EXTRA_LDFLAGS := "${@oe_filter_out('(-L\S+|-l\S+)', '${LDFLAGS}', d)}"
+CFLAGS_arm := "${@oe_filter_out('-fno-omit-frame-pointer', '${CFLAGS}')}"
+UCLIBC_EXTRA_CFLAGS  := "${@oe_filter_out('(-I\S+|-i\S+)', '${CFLAGS}')}"
+UCLIBC_EXTRA_LDFLAGS := "${@oe_filter_out('(-L\S+|-l\S+)', '${LDFLAGS}')}"
 do_compile_prepend () {
   unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
 }
diff --git a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
index 34bfaeb..5b19ec9 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
@@ -1,6 +1,6 @@ 
 require gcc-configure-common.inc
 
-CXXFLAGS := "${@oe_filter_out('-fvisibility-inlines-hidden', '${CXXFLAGS}', d)}"
+CXXFLAGS := "${@oe_filter_out('-fvisibility-inlines-hidden', '${CXXFLAGS}')}"
 
 EXTRA_OECONF_PATHS = " \
     --with-local-prefix=${STAGING_DIR_TARGET}${prefix} \