Patchwork [2/4] classes: Add recipe class to overrides

login
register
mail settings
Submitter Khem Raj
Date Feb. 24, 2012, 3:33 a.m.
Message ID <0c86983a495510f1fec576591e2f5d5e70cb4aa5.1330053959.git.raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/21889/
State New
Headers show

Comments

Khem Raj - Feb. 24, 2012, 3:33 a.m.
We have currently no override to detect a recipe
being build cross, crosssdk or for target
at times we can use virtclass-native and virtclass-nativesdk to
override stuff in recipes but we dont have way to modify a variables
based on recipe type always.

With this patch we attempt to have recipe class override always
so we can use it in recipes which use BBCLASSEXTEND as well as
others which inherit the classes directly.

I am not too fond of names that I have used so any suggestions are
welcome I would have liked to drop virtclass- from the existing
overrides but that would mean a lot of changes so I left them
alone.

With this change now we can say

EXTRA_OECONF_class-target = "...."
EXTRA_OECONF_virtclass-native = "..."
EXTRA_OECONF_virtclass-nativesdk = "..."
EXTRA_OECONF_virtclass-crosssdk= "..."

....

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/classes/base.bbclass           |    1 +
 meta/classes/cross-canadian.bbclass |    2 +-
 meta/classes/cross.bbclass          |    1 +
 meta/classes/crosssdk.bbclass       |    1 +
 meta/classes/native.bbclass         |    3 +--
 meta/classes/nativesdk.bbclass      |    3 +--
 meta/conf/bitbake.conf              |    3 ++-
 7 files changed, 8 insertions(+), 6 deletions(-)
Richard Purdie - Feb. 24, 2012, 4:20 p.m.
On Thu, 2012-02-23 at 19:33 -0800, Khem Raj wrote:
> We have currently no override to detect a recipe
> being build cross, crosssdk or for target
> at times we can use virtclass-native and virtclass-nativesdk to
> override stuff in recipes but we dont have way to modify a variables
> based on recipe type always.
> 
> With this patch we attempt to have recipe class override always
> so we can use it in recipes which use BBCLASSEXTEND as well as
> others which inherit the classes directly.
> 
> I am not too fond of names that I have used so any suggestions are
> welcome I would have liked to drop virtclass- from the existing
> overrides but that would mean a lot of changes so I left them
> alone.
> 
> With this change now we can say
> 
> EXTRA_OECONF_class-target = "...."
> EXTRA_OECONF_virtclass-native = "..."
> EXTRA_OECONF_virtclass-nativesdk = "..."
> EXTRA_OECONF_virtclass-crosssdk= "..."

I think we need to drop the "virt" here and make this consistent since
they are no longer specific to the virtual BBCLASSEXTEND code...

Cheers,

Richard
Khem Raj - Feb. 24, 2012, 5:02 p.m.
On Fri, Feb 24, 2012 at 8:20 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>> With this change now we can say
>>
>> EXTRA_OECONF_class-target = "...."
>> EXTRA_OECONF_virtclass-native = "..."
>> EXTRA_OECONF_virtclass-nativesdk = "..."
>> EXTRA_OECONF_virtclass-crosssdk= "..."
>
> I think we need to drop the "virt" here and make this consistent since
> they are no longer specific to the virtual BBCLASSEXTEND code...
>

since they were used in quite few places I thought to keep them as it is
renaming would mean all places should change and other layers too and
I am infamous
to break other layers :) and keeping both would be more confusion.


> Cheers,
>
> Richard

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index e80e874..e977485 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -1,4 +1,5 @@ 
 BB_DEFAULT_TASK ?= "build"
+CLASSOVERRIDE ?= "class-target"
 
 inherit patch
 inherit staging
diff --git a/meta/classes/cross-canadian.bbclass b/meta/classes/cross-canadian.bbclass
index 499a1fb..d4d18c4 100644
--- a/meta/classes/cross-canadian.bbclass
+++ b/meta/classes/cross-canadian.bbclass
@@ -8,7 +8,7 @@ 
 # SDK packages are built either explicitly by the user,
 # or indirectly via dependency.  No need to be in 'world'.
 EXCLUDE_FROM_WORLD = "1"
-
+CLASSOVERRIDE = "virtclass-cross-canadian"
 STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${SDK_VENDOR}-${SDK_OS}:${STAGING_DIR_NATIVE}${bindir_native}/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}"
 
 #
diff --git a/meta/classes/cross.bbclass b/meta/classes/cross.bbclass
index 8da3048..63eb91e 100644
--- a/meta/classes/cross.bbclass
+++ b/meta/classes/cross.bbclass
@@ -4,6 +4,7 @@  inherit relocatable
 # no need for them to be a direct target of 'world'
 EXCLUDE_FROM_WORLD = "1"
 
+CLASSOVERRIDE = "virtclass-cross"
 PACKAGES = ""
 PACKAGES_DYNAMIC = ""
 PACKAGES_DYNAMIC_virtclass-native = ""
diff --git a/meta/classes/crosssdk.bbclass b/meta/classes/crosssdk.bbclass
index 83753b4..5abc950 100644
--- a/meta/classes/crosssdk.bbclass
+++ b/meta/classes/crosssdk.bbclass
@@ -1,5 +1,6 @@ 
 inherit cross
 
+CLASSOVERRIDE = "virtclass-crosssdk"
 PACKAGE_ARCH = "${SDK_ARCH}"
 STAGING_DIR_TARGET = "${STAGING_DIR}/${SDK_ARCH}-nativesdk${SDK_VENDOR}-${SDK_OS}"
 STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclass
index 00196ba..9fcb31f 100644
--- a/meta/classes/native.bbclass
+++ b/meta/classes/native.bbclass
@@ -94,6 +94,7 @@  PKG_CONFIG_SYSROOT_DIR = ""
 
 # we dont want libc-uclibc or libc-glibc to kick in for native recipes
 LIBCOVERRIDE = ""
+CLASSOVERRIDE = "virtclass-native"
 
 PATH =. "${COREBASE}/scripts/native-intercept:"
 
@@ -141,8 +142,6 @@  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")
 }
 
 addhandler native_virtclass_handler
diff --git a/meta/classes/nativesdk.bbclass b/meta/classes/nativesdk.bbclass
index ceec53e..084f5d9 100644
--- a/meta/classes/nativesdk.bbclass
+++ b/meta/classes/nativesdk.bbclass
@@ -8,6 +8,7 @@  STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S
 
 # we dont want libc-uclibc or libc-glibc to kick in for nativesdk recipes
 LIBCOVERRIDE = ""
+CLASSOVERRIDE = "virtclass-nativesdk"
 
 #
 # Update PACKAGE_ARCH and PACKAGE_ARCHS
@@ -63,8 +64,6 @@  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")
 }
 
 python () {
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 90e5f7a..1e47b13 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -630,7 +630,8 @@  AUTO_LIBNAME_PKGS = "${PACKAGES}"
 #
 # This works for  functions as well, they are really just environment variables.
 # Default OVERRIDES to make compilation fail fast in case of build system misconfiguration.
-OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:build-${BUILD_OS}:pn-${PN}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:forcevariable"
+OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:build-${BUILD_OS}:pn-${PN}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}:forcevariable"
+CLASSOVERRIDE ?= "class-target"
 DISTROOVERRIDES ?= "${DISTRO}"
 MACHINEOVERRIDES ?= "${MACHINE}"
 MACHINEOVERRIDES[vardepsexclude] = "MACHINE"