Skip to contentSkip to conversation

base.bbclass: Add detection/sanity check of non-global class inheritance

RFC PATCH In review Richard Purdie 1 participant 1 message Mar 26, 2014

lore
Share & tools
lore
#0 lore raw

RFC PATCH 3/3 base.bbclass: Add detection/sanity check of non-global class inheritance

Users are doing things like inheriting bootimg in local.conf and not understanding that there are two types of class, "global" classes and "recipe" classes. This patch starts to markup the recipe classes to tell the user when they're including a "recipe" class in global context by mistake.

RFC: Only one class has markup here but we could go through them and mark the "recipe" classes accordingly.

---

meta/classes/base.bbclass +3 -0
index 360b112..08617e8 100644
@@ -295,6 +295,9 @@ python base_eventhandler() {
         preferred_ml_updates(e.data)
         oe.utils.features_backfill("DISTRO_FEATURES", e.data)
         oe.utils.features_backfill("MACHINE_FEATURES", e.data)
+        nonglobalclasses = e.data.getVar("NONGLOBALBBCLASS", True)
+        if nonglobalclasses:
+            bb.error("The following classes were inserted into the global namespace but are not designed for use like this. Please inherit them in the appropriate recipe instead: %s" % nonglobalclasses)
 
     if isinstance(e, bb.event.BuildStarted):
         localdata = bb.data.createCopy(e.data)
meta/classes/bootimg.bbclass +2 -0
index b13eef9..1562408 100644
@@ -4,6 +4,8 @@
 # Creates a bootable image using syslinux, your kernel and an optional
 # initrd
 
+NONGLOBALBBCLASS += "bootimg"
+
 #
 # End result is two things:
 #