mirror of
https://git.yoctoproject.org/poky
synced 2026-05-07 16:59:22 +00:00
Shift oe import logic out of the event handler
This can be useful if we need the imports from another config parsed event handler, and can't rely upon the base one running before that one. (From OE-Core rev: dc579ce4dcf9a3743ced9eae4fe510a079961faf) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
6bdfae902e
commit
adceb2e272
+20
-17
@@ -12,26 +12,29 @@ inherit logging
|
||||
|
||||
OE_IMPORTS += "os sys time oe.path oe.utils oe.data"
|
||||
|
||||
python oe_import () {
|
||||
def oe_import(d):
|
||||
import os, sys
|
||||
|
||||
bbpath = d.getVar("BBPATH", True).split(":")
|
||||
sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
|
||||
|
||||
def inject(name, value):
|
||||
"""Make a python object accessible from the metadata"""
|
||||
if hasattr(bb.utils, "_context"):
|
||||
bb.utils._context[name] = value
|
||||
else:
|
||||
__builtins__[name] = value
|
||||
|
||||
for toimport in d.getVar("OE_IMPORTS", True).split():
|
||||
imported = __import__(toimport)
|
||||
inject(toimport.split(".", 1)[0], imported)
|
||||
|
||||
python oe_import_eh () {
|
||||
if isinstance(e, bb.event.ConfigParsed):
|
||||
import os, sys
|
||||
|
||||
bbpath = e.data.getVar("BBPATH", True).split(":")
|
||||
sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
|
||||
|
||||
def inject(name, value):
|
||||
"""Make a python object accessible from the metadata"""
|
||||
if hasattr(bb.utils, "_context"):
|
||||
bb.utils._context[name] = value
|
||||
else:
|
||||
__builtins__[name] = value
|
||||
|
||||
for toimport in e.data.getVar("OE_IMPORTS", True).split():
|
||||
imported = __import__(toimport)
|
||||
inject(toimport.split(".", 1)[0], imported)
|
||||
oe_import(e.data)
|
||||
}
|
||||
|
||||
addhandler oe_import
|
||||
addhandler oe_import_eh
|
||||
|
||||
die() {
|
||||
bbfatal "$*"
|
||||
|
||||
Reference in New Issue
Block a user