diff options
-rw-r--r-- | meta/classes/base.bbclass | 33 |
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 | ||
13 | OE_IMPORTS += "os sys time oe.path oe.utils oe.data" | 13 | OE_IMPORTS += "os sys time oe.path oe.utils oe.data" |
14 | 14 | ||
15 | python oe_import () { | 15 | def 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(): | 32 | python 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 | ||
34 | addhandler oe_import | 37 | addhandler oe_import_eh |
35 | 38 | ||
36 | die() { | 39 | die() { |
37 | bbfatal "$*" | 40 | bbfatal "$*" |