mirror of
https://git.yoctoproject.org/poky
synced 2026-09-14 21:49:33 +02:00
base.bbclass: switch to current OE's imports handling
The current mechanism makes it easier for classes to add new oe modules to be
automatically imported, and thereby made available to python snippets (${@}).
(From OE-Core rev: 0c560a2a7954412f714db86b1aaadb7acbe72d1b)
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
4da8c86ca2
commit
6bdfae902e
@@ -10,32 +10,28 @@ inherit metadata_scm
|
|||||||
inherit buildstats
|
inherit buildstats
|
||||||
inherit logging
|
inherit logging
|
||||||
|
|
||||||
python sys_path_eh () {
|
OE_IMPORTS += "os sys time oe.path oe.utils oe.data"
|
||||||
|
|
||||||
|
python oe_import () {
|
||||||
if isinstance(e, bb.event.ConfigParsed):
|
if isinstance(e, bb.event.ConfigParsed):
|
||||||
import sys
|
import os, sys
|
||||||
import os
|
|
||||||
import time
|
|
||||||
|
|
||||||
bbpath = e.data.getVar("BBPATH", True).split(":")
|
bbpath = e.data.getVar("BBPATH", True).split(":")
|
||||||
sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
|
sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
|
||||||
|
|
||||||
def inject(name, value):
|
def inject(name, value):
|
||||||
"""Make a python object accessible from everywhere for the metadata"""
|
"""Make a python object accessible from the metadata"""
|
||||||
if hasattr(bb.utils, "_context"):
|
if hasattr(bb.utils, "_context"):
|
||||||
bb.utils._context[name] = value
|
bb.utils._context[name] = value
|
||||||
else:
|
else:
|
||||||
__builtins__[name] = value
|
__builtins__[name] = value
|
||||||
|
|
||||||
import oe.path
|
for toimport in e.data.getVar("OE_IMPORTS", True).split():
|
||||||
import oe.utils
|
imported = __import__(toimport)
|
||||||
import oe.data
|
inject(toimport.split(".", 1)[0], imported)
|
||||||
inject("bb", bb)
|
|
||||||
inject("sys", sys)
|
|
||||||
inject("time", time)
|
|
||||||
inject("oe", oe)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addhandler sys_path_eh
|
addhandler oe_import
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
bbfatal "$*"
|
bbfatal "$*"
|
||||||
|
|||||||
Reference in New Issue
Block a user