Skip to contentSkip to conversation

classes: Add recipe class to overrides

RFC New Khem Raj 1 participant 1 message Feb 11, 2012

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

RFC 1/1 classes: Add recipe class to overrides

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= "..."

....

---
 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/distro/include/default-distrovars.inc |    8 ++++++++
 7 files changed, 14 insertions(+), 5 deletions(-)
meta/classes/base.bbclass +1 -0
index a26ac94..b39bb0b 100644
@@ -1,4 +1,5 @@
 BB_DEFAULT_TASK ?= "build"
+RECIPECLASSOVERRIDE ?= ":class-target"
 
 inherit patch
 inherit staging
meta/classes/cross-canadian.bbclass +1 -1
index 499a1fb..439404e 100644
@@ -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"
-
+RECIPECLASSOVERRIDE = ":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}"
 
 #
meta/classes/cross.bbclass +1 -0
index 8da3048..421ede6 100644
@@ -4,6 +4,7 @@ inherit relocatable
 # no need for them to be a direct target of 'world'
 EXCLUDE_FROM_WORLD = "1"
 
+RECIPECLASSOVERRIDE = ":virtclass-cross"
 PACKAGES = ""
 PACKAGES_DYNAMIC = ""
 PACKAGES_DYNAMIC_virtclass-native = ""
meta/classes/crosssdk.bbclass +1 -0
index 83753b4..89eaadd 100644
@@ -1,5 +1,6 @@
 inherit cross
 
+RECIPECLASSOVERRIDE = ":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}"
meta/classes/native.bbclass +1 -2
index 00196ba..dbdb406 100644
@@ -94,6 +94,7 @@ PKG_CONFIG_SYSROOT_DIR = ""
 
 # we dont want libc-uclibc or libc-glibc to kick in for native recipes
 LIBCOVERRIDE = ""
+RECIPECLASSOVERRIDE = ":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
meta/classes/nativesdk.bbclass +1 -2
index ceec53e..6858604 100644
@@ -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 = ""
+RECIPECLASSOVERRIDE = ":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 () {
meta/conf/distro/include/default-distrovars.inc +8 -0
index 16b3108..ca7c750 100644
@@ -41,8 +41,16 @@ NO32LIBS ??= "1"
 
 # Default to emitting logfiles if a build fails.
 BBINCLUDELOGS ??= "yes"
+
+# dummy distro related variables
+# they should be overridden by real distros
+# these fallbacks only serve the purpose of
+# oe-core standalone testability
+
+DISTRO ??= ""
 SDK_VERSION ??= "oe-core.0"
 DISTRO_VERSION ??= "oe-core.0"
 
 # Missing checksums should raise an error
 BB_STRICT_CHECKSUM = "1"
+OVERRIDES .= "${RECIPECLASSOVERRIDE}"
Signature · 1 line
1.7.5.4