<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>Thanks Chris. I will work on prototyping this. Since the documentation currently describes OE_IMPORTS as being “internal only”, I will modify it in base.bbclass from this:</div>
<div> </div>
<div style="text-indent:36pt;">OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license"</div>
<div><font face="Times New Roman"> </font></div>
<div>To something like this:</div>
<div> </div>
<div style="text-indent:36pt;">OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license ${BB_PROGRESS_IMPORTS}"</div>
<div><font face="Times New Roman"> </font></div>
<div>Is BB_PROGRESS_IMPORTS a suitable variable name?</div>
<div> </div>
<div>P.S. Sorry for terrible email formatting. I’m stuck with Outlook + Exchange server at work. Will try to figure out something better.</div>
<div><font face="Times New Roman"> </font></div>
<div>Chris</div>
<div><font face="Times New Roman"> </font></div>
<div><font face="Yu Gothic"><b>From:</b> Christopher Larson <kergoth@gmail.com> <br>
<b>Sent:</b> Thursday, February 21, 2019 4:46 PM<br>
<b>To:</b> Richard Purdie <richard.purdie@linuxfoundation.org><br>
<b>Cc:</b> LAPLANTE,CHRIS (A-Little Falls,ex1) <chris.laplante@agilent.com>; bitbake-devel@lists.openembedded.org<br>
<b>Subject:</b> Re: [bitbake-devel] [PATCH] build.py: support custom task [progress] handlers</font></div>
<div><font face="Times New Roman"> </font></div>
<div><font face="Calibri">This is a great idea, thanks a lot for contribution. As Richard says, I think using and hardcoding __builtins__ as the injection point isn’t ideal. Ideally I think we'd be able to provide a python module in a layer with the progress
handler, let OE_IMPORTS import it, and then let bitbake use it as is.</font></div>
<div><font face="Times New Roman"> </font></div>
<div><font face="Calibri">I think we just need to tweak it to accept the full name with imports, i.e. custom:oe.myprogressmodule.MyProgressHandler. Then if you want to inject it you can (though I think bb.context is better than __builtins__), or use an imported
module, whichever is preferred, rather than hardcoding the context.</font></div>
<div><font face="Times New Roman"> </font></div>
<div><font face="Calibri">Something like `<font face="Helvetica Neue" size="2" color="#262626"><span style="font-size:9pt;">functools.reduce(lambda x, y: x[y], cls.split("."), globals())` might do for resolving the dot-separated name to the class object, assuming
it’s already been imported.</span></font></font></div>
<div><font face="Times New Roman"> </font></div>
<div><font face="Calibri">On Thu, Feb 21, 2019 at 2:13 PM Richard Purdie <<a href="mailto:richard.purdie@linuxfoundation.org"><font color="blue"><u>richard.purdie@linuxfoundation.org</u></font></a>> wrote:</font></div>
<div><font face="Calibri">On Wed, 2018-10-03 at 22:48 -0400, Chris Laplante via bitbake-devel<br>
wrote:<br>
> To use this mechanism, you need to inject your progress handler (i.e.<br>
> something derived from bb.progress.ProgressHandler) into<br>
> __builtins__.<br>
> Here's one way to do it (from recipe-space):<br>
> <br>
> def install_my_progress_handler():<br>
> from bb.progress import ProgressHandler<br>
> <br>
> class MyProgressHandler(ProgressHandler):<br>
> pass<br>
> <br>
> if "MyProgressHandler" not in __builtins__:<br>
> __builtins__["MyProgressHandler"] = MyProgressHandler<br>
> <br>
> return "OK"<br>
> <br>
> _INSTALL_MY_PROGRESS_HANDLERS := "${@install_my_progress_handler(<br>
> )}"<br>
<br>
Sorry about the lack of review.<br>
<br>
My concern on this is the fact we have to poke around __builtins__. I<br>
understand why, I just can't help wonder if there is a better way<br>
somehow.<br>
<br>
I'm not sure I have a better one, not sure if Chris or others might?<br>
<br>
Cheers,<br>
<br>
Richard<br>
<br>
<br>
> To install on a task:<br>
> do_task[progress] = "custom:MyProgressHandler"<br>
> <br>
> To install on a task and pass extra arguments:<br>
> do_task[progress] = "custom:MyProgressHandler:my-arg"<br>
> <br>
> Signed-off-by: Chris Laplante <<a href="mailto:chris.laplante@agilent.com"><font color="blue"><u>chris.laplante@agilent.com</u></font></a>><br>
> ---<br>
> lib/bb/build.py | 8 ++++++++<br>
> 1 file changed, 8 insertions(+)<br>
> <br>
> diff --git a/lib/bb/build.py b/lib/bb/build.py<br>
> index 3e2a94e..2e14572 100644<br>
> --- a/lib/bb/build.py<br>
> +++ b/lib/bb/build.py<br>
> @@ -387,6 +387,14 @@ exit $ret<br>
> elif progress.startswith('outof:'):<br>
> # Use specified regex<br>
> logfile = bb.progress.OutOfProgressHandler(d,<br>
> regex=progress.split(':', 1)[1], outfile=logfile)<br>
> + elif progress.startswith("custom:"):<br>
> + # Use a custom progress handler<br>
> + parts = progress.split(":", 2)<br>
> + _, cls, otherargs = parts[0], parts[1], (parts[2] or<br>
> None) if parts[2:] else None<br>
> + if cls and cls in __builtins__:<br>
> + logfile = __builtins__[cls](d, outfile=logfile,<br>
> otherargs=otherargs)<br>
> + else:<br>
> + bb.warn('%s: unknown custom progress handler in task<br>
> progress varflag value "%s", ignoring' % (func, cls))<br>
> else:<br>
> bb.warn('%s: invalid task progress varflag value "%s",<br>
> ignoring' % (func, progress))<br>
> <br>
> -- <br>
> 2.7.4<br>
> <br>
<br>
-- <br>
_______________________________________________<br>
bitbake-devel mailing list<br>
<a href="mailto:bitbake-devel@lists.openembedded.org"><font color="blue"><u>bitbake-devel@lists.openembedded.org</u></font></a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/bitbake-devel"><font color="blue"><u>http://lists.openembedded.org/mailman/listinfo/bitbake-devel</u></font></a></font></div>
<div><font face="Times New Roman"><br>
</font></div>
<div><font face="Times New Roman"> </font></div>
<div><font face="Calibri">-- </font></div>
<div><font face="Calibri">Christopher Larson<br>
kergoth at gmail dot com<br>
Founder - BitBake, OpenEmbedded, OpenZaurus<br>
Senior Software Engineer, Mentor Graphics</font></div>
<div><font face="Times New Roman"> </font></div>
</span></font>
</body>
</html>