From patchwork Thu Mar 17 16:19:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [06/12] Shift oe import logic out of the event handler Date: Thu, 17 Mar 2011 16:19:04 -0000 From: Christopher Larson X-Patchwork-Id: 1559 Message-Id: <364a78379e4afb498435367b9651886cfea81798.1300378596.git.chris_larson@mentor.com> To: openembedded-core@lists.openembedded.org Cc: Chris Larson From: Chris Larson 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 --- 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 7a87f57..a3d4086 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -11,26 +11,29 @@ inherit buildstats OE_IMPORTS += "oe.path oe.utils sys os time" -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() { oefatal "$*"