base: Add deferred class event handler

Use the new deferred class event to set the class overrides earlier.
This improves interaction of the override with PACKAGECONFIG values
that control conditional inherits (such as python support).

This also allows toolchain configuration in an easier and more user
friendly way.

(From OE-Core rev: d58f94d5684332bd4fac3747688558bb261b9c63)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2025-06-06 11:46:46 +01:00
parent bb4dd2e54d
commit c49991441c

View File

@ -267,10 +267,19 @@ def buildcfg_neededvars(d):
bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser))
addhandler base_eventhandler
base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed"
base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed bb.event.RecipePreDeferredInherits"
python base_eventhandler() {
import bb.runqueue
if isinstance(e, bb.event.RecipePreDeferredInherits):
# Use this to snoop on class extensions and set these up before the deferred inherits
# are processed which allows overrides on conditional variables.
for c in ['native', 'nativesdk', 'crosssdk', 'cross']:
if c in e.inherits:
d.setVar('CLASSOVERRIDE', 'class-' + c)
break
return
if isinstance(e, bb.event.ConfigParsed):
if not d.getVar("NATIVELSBSTRING", False):
d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))