summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-03-07 09:51:39 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-20 17:34:22 +0100
commitadceb2e27275c9349acb51ebfee40383b2a5e365 (patch)
treeb15c91b337ff36818eeb79413628a648f7046950
parent6bdfae902ea61d5794dc65c3b0db744f5b2661b4 (diff)
downloadpoky-adceb2e27275c9349acb51ebfee40383b2a5e365.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. (From OE-Core rev: dc579ce4dcf9a3743ced9eae4fe510a079961faf) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 d40d5863c9..5363a1b37c 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -12,26 +12,29 @@ inherit logging
12 12
13OE_IMPORTS += "os sys time oe.path oe.utils oe.data" 13OE_IMPORTS += "os sys time oe.path oe.utils oe.data"
14 14
15python oe_import () { 15def oe_import(d):
16 if isinstance(e, bb.event.ConfigParsed): 16 import os, sys
17 import os, sys 17
18 bbpath = d.getVar("BBPATH", True).split(":")
19 sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
18 20
19 bbpath = e.data.getVar("BBPATH", True).split(":") 21 def inject(name, value):
20 sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath] 22 """Make a python object accessible from the metadata"""
23 if hasattr(bb.utils, "_context"):
24 bb.utils._context[name] = value
25 else:
26 __builtins__[name] = value
21 27
22 def inject(name, value): 28 for toimport in d.getVar("OE_IMPORTS", True).split():
23 """Make a python object accessible from the metadata""" 29 imported = __import__(toimport)
24 if hasattr(bb.utils, "_context"): 30 inject(toimport.split(".", 1)[0], imported)
25 bb.utils._context[name] = value
26 else:
27 __builtins__[name] = value
28 31
29 for toimport in e.data.getVar("OE_IMPORTS", True).split(): 32python oe_import_eh () {
30 imported = __import__(toimport) 33 if isinstance(e, bb.event.ConfigParsed):
31 inject(toimport.split(".", 1)[0], imported) 34 oe_import(e.data)
32} 35}
33 36
34addhandler oe_import 37addhandler oe_import_eh
35 38
36die() { 39die() {
37 bbfatal "$*" 40 bbfatal "$*"