aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-03-07 09:51:39 -0700
committerChris Larson <chris_larson@mentor.com>2011-05-18 13:58:56 -0700
commitde72fa6b7cdb0b808b0f12a62822efc5782a1748 (patch)
treea928865e7b909da4a1160732ea4905ca2cb7fc4c
parent674b9a84873e66a42dd7e791b84b2afb1f5b033a (diff)
downloadopenembedded-core-contrib-de72fa6b7cdb0b808b0f12a62822efc5782a1748.tar.gz
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. Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r--meta/classes/base.bbclass33
1 files changed, 18 insertions, 15 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 51f5a14a45..391545c655 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -12,26 +12,29 @@ inherit logging
OE_IMPORTS += "os sys time oe.path oe.utils oe.data"
-python oe_import () {
- if isinstance(e, bb.event.ConfigParsed):
- import os, sys
+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]
- 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
- 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)
- for toimport in e.data.getVar("OE_IMPORTS", True).split():
- imported = __import__(toimport)
- inject(toimport.split(".", 1)[0], imported)
+python oe_import_eh () {
+ if isinstance(e, bb.event.ConfigParsed):
+ oe_import(e.data)
}
-addhandler oe_import
+addhandler oe_import_eh
die() {
bbfatal "$*"