summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/build.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-07-10 14:51:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-12 22:50:40 +0100
commit3b5031230717d7430951dfa4a148b7f83bad514b (patch)
tree8e5a487c2498ed49e1a28d7acc94e964e7d7a3ba /bitbake/lib/bb/build.py
parent8f8d3362b8631aa6d09f1ef9df5111ba7ce10f85 (diff)
downloadpoky-3b5031230717d7430951dfa4a148b7f83bad514b.tar.gz
bitbake: lib/bb: set up infrastructure for shell message functions
Create a fifo under ${T} for each running task that can be used by the task to send events back to BitBake. The purpose of this is to allow OpenEmbedded's logging.bbclass (which provides shell function equivalents for bb.warn(), bb.note() etc.) to have those functions trigger the appropriate events within BitBake so that messages are shown through the BitBake UI rather than just in the task log; to do that we just call the python functions. Part of the fix for [YOCTO #5275]. (Bitbake rev: bae330a1f8a59a912eca71177b3c6ba7c92a2f38) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r--bitbake/lib/bb/build.py50
1 files changed, 43 insertions, 7 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 14dc5e0619..cce01feba2 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -329,14 +329,50 @@ exit $?
329 else: 329 else:
330 logfile = sys.stdout 330 logfile = sys.stdout
331 331
332 bb.debug(2, "Executing shell function %s" % func) 332 def readfifo(data):
333 lines = data.split('\0')
334 for line in lines:
335 splitval = line.split(' ', 1)
336 cmd = splitval[0]
337 if len(splitval) > 1:
338 value = splitval[1]
339 else:
340 value = ''
341 if cmd == 'bbplain':
342 bb.plain(value)
343 elif cmd == 'bbnote':
344 bb.note(value)
345 elif cmd == 'bbwarn':
346 bb.warn(value)
347 elif cmd == 'bberror':
348 bb.error(value)
349 elif cmd == 'bbfatal':
350 # The caller will call exit themselves, so bb.error() is
351 # what we want here rather than bb.fatal()
352 bb.error(value)
353 elif cmd == 'bbdebug':
354 splitval = value.split(' ', 1)
355 level = int(splitval[0])
356 value = splitval[1]
357 bb.debug(level, value)
333 358
334 try: 359 tempdir = d.getVar('T', True)
335 with open(os.devnull, 'r+') as stdin: 360 fifopath = os.path.join(tempdir, 'fifo.%s' % os.getpid())
336 bb.process.run(cmd, shell=False, stdin=stdin, log=logfile) 361 if os.path.exists(fifopath):
337 except bb.process.CmdError: 362 os.unlink(fifopath)
338 logfn = d.getVar('BB_LOGFILE', True) 363 os.mkfifo(fifopath)
339 raise FuncFailed(func, logfn) 364 with open(fifopath, 'r+') as fifo:
365 try:
366 bb.debug(2, "Executing shell function %s" % func)
367
368 try:
369 with open(os.devnull, 'r+') as stdin:
370 bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)])
371 except bb.process.CmdError:
372 logfn = d.getVar('BB_LOGFILE', True)
373 raise FuncFailed(func, logfn)
374 finally:
375 os.unlink(fifopath)
340 376
341 bb.debug(2, "Shell function %s finished" % func) 377 bb.debug(2, "Shell function %s finished" % func)
342 378