[oe-commits] [bitbake] 04/04: build: implement custom progress handlers injected via OE_EXTRA_IMPORTS
git at git.openembedded.org
git at git.openembedded.org
Mon Jun 10 16:44:45 UTC 2019
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository bitbake.
commit 89abe8faab966ca8bb9b4a0d6b4c630d49e8a830
Author: Chris Laplante via bitbake-devel <bitbake-devel at lists.openembedded.org>
AuthorDate: Fri Jun 7 14:24:04 2019 -0400
build: implement custom progress handlers injected via OE_EXTRA_IMPORTS
A separate patch to base.bbclass (in poky) will add the OE_EXTRA_IMPORTS
variable. The contents are appended into OE_IMPORTS. This provides a
mechanism by which layers (in their layer.conf) can make custom progress
handlers available.
As a backup, individual recipes can inject progress handlers into
__builtins__.
Custom handlers are expected to have this __init__ signature:
def __init__(self, d, outfile=None, otherargs=None):
Recipes can then use the handlers like this:
do_task[progress] = "custom:mylayer.util.ProgressHandler[:args]"
The last part (everything after and including the second colon) is
optional. If provided, it is passed to HandlerClass's __init__ as
otherargs="args". Otherwise, otherargs=None.
Signed-off-by: Chris Laplante <chris.laplante at agilent.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/build.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 85ad8ea..e2f91fa 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -356,6 +356,27 @@ def create_progress_handler(func, progress, logfile, d):
elif progress.startswith('outof:'):
# Use specified regex
return bb.progress.OutOfProgressHandler(d, regex=progress.split(':', 1)[1], outfile=logfile)
+ elif progress.startswith("custom:"):
+ # Use a custom progress handler that was injected via OE_EXTRA_IMPORTS or __builtins__
+ import functools
+ from types import ModuleType
+
+ parts = progress.split(":", 2)
+ _, cls, otherargs = parts[0], parts[1], (parts[2] or None) if parts[2:] else None
+ if cls:
+ def resolve(x, y):
+ if not x:
+ return None
+ if isinstance(x, ModuleType):
+ return getattr(x, y, None)
+ return x.get(y)
+ cls_obj = functools.reduce(resolve, cls.split("."), bb.utils._context)
+ if not cls_obj:
+ # Fall-back on __builtins__
+ cls_obj = functools.reduce(lambda x, y: x.get(y), cls.split("."), __builtins__)
+ if cls_obj:
+ return cls_obj(d, outfile=logfile, otherargs=otherargs)
+ bb.warn('%s: unknown custom progress handler in task progress varflag value "%s", ignoring' % (func, cls))
else:
bb.warn('%s: invalid task progress varflag value "%s", ignoring' % (func, progress))
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list