summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/build.py
diff options
context:
space:
mode:
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