aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-02-09 07:09:43 -0700
committerChris Larson <chris_larson@mentor.com>2011-05-18 13:58:53 -0700
commit674b9a84873e66a42dd7e791b84b2afb1f5b033a (patch)
treed5ddb1ba720faf958dca007a00f755102d9a6e3d
parent33f8286787326128301ce3ab8c1144bc86a9364e (diff)
downloadopenembedded-core-contrib-674b9a84873e66a42dd7e791b84b2afb1f5b033a.tar.gz
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 (${@}). Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r--meta/classes/base.bbclass22
1 files changed, 9 insertions, 13 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index b552de2948..51f5a14a45 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -10,32 +10,28 @@ inherit metadata_scm
inherit buildstats
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):
- import sys
- import os
- import time
+ 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 everywhere for the metadata"""
+ """Make a python object accessible from the metadata"""
if hasattr(bb.utils, "_context"):
bb.utils._context[name] = value
else:
__builtins__[name] = value
- import oe.path
- import oe.utils
- import oe.data
- inject("bb", bb)
- inject("sys", sys)
- inject("time", time)
- inject("oe", oe)
+ for toimport in e.data.getVar("OE_IMPORTS", True).split():
+ imported = __import__(toimport)
+ inject(toimport.split(".", 1)[0], imported)
}
-addhandler sys_path_eh
+addhandler oe_import
die() {
bbfatal "$*"