diff options
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r-- | bitbake/lib/bb/build.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index a0a764a7cb..85ad8ea689 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -163,12 +163,35 @@ class LogTee(object): | |||
163 | 163 | ||
164 | def __repr__(self): | 164 | def __repr__(self): |
165 | return '<LogTee {0}>'.format(self.name) | 165 | return '<LogTee {0}>'.format(self.name) |
166 | |||
166 | def flush(self): | 167 | def flush(self): |
167 | self.outfile.flush() | 168 | self.outfile.flush() |
168 | 169 | ||
170 | |||
171 | class StdoutNoopContextManager: | ||
172 | """ | ||
173 | This class acts like sys.stdout, but adds noop __enter__ and __exit__ methods. | ||
174 | """ | ||
175 | def __enter__(self): | ||
176 | return sys.stdout | ||
177 | |||
178 | def __exit__(self, *exc_info): | ||
179 | pass | ||
180 | |||
181 | def write(self, string): | ||
182 | return sys.stdout.write(string) | ||
183 | |||
184 | def flush(self): | ||
185 | sys.stdout.flush() | ||
186 | |||
187 | @property | ||
188 | def name(self): | ||
189 | return sys.stdout.name | ||
190 | |||
191 | |||
169 | # | 192 | # |
170 | # pythonexception allows the python exceptions generated to be raised | 193 | # pythonexception allows the python exceptions generated to be raised |
171 | # as the real exceptions (not FuncFailed) and without a backtrace at the | 194 | # as the real exceptions (not FuncFailed) and without a backtrace at the |
172 | # origin of the failure. | 195 | # origin of the failure. |
173 | # | 196 | # |
174 | def exec_func(func, d, dirs = None, pythonexception=False): | 197 | def exec_func(func, d, dirs = None, pythonexception=False): |
@@ -375,9 +398,9 @@ exit $ret | |||
375 | cmd = [fakerootcmd, runfile] | 398 | cmd = [fakerootcmd, runfile] |
376 | 399 | ||
377 | if bb.msg.loggerDefaultVerbose: | 400 | if bb.msg.loggerDefaultVerbose: |
378 | logfile = LogTee(logger, sys.stdout) | 401 | logfile = LogTee(logger, StdoutNoopContextManager()) |
379 | else: | 402 | else: |
380 | logfile = sys.stdout | 403 | logfile = StdoutNoopContextManager() |
381 | 404 | ||
382 | progress = d.getVarFlag(func, 'progress') | 405 | progress = d.getVarFlag(func, 'progress') |
383 | if progress: | 406 | if progress: |
@@ -433,7 +456,7 @@ exit $ret | |||
433 | bb.debug(2, "Executing shell function %s" % func) | 456 | bb.debug(2, "Executing shell function %s" % func) |
434 | 457 | ||
435 | try: | 458 | try: |
436 | with open(os.devnull, 'r+') as stdin: | 459 | with open(os.devnull, 'r+') as stdin, logfile: |
437 | bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)]) | 460 | bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)]) |
438 | except bb.process.CmdError: | 461 | except bb.process.CmdError: |
439 | logfn = d.getVar('BB_LOGFILE') | 462 | logfn = d.getVar('BB_LOGFILE') |