diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-12-14 09:20:33 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-12-14 09:21:38 -0700 |
commit | 1c8be64732fdf4f3a608c090b3dc92065d6058d6 (patch) | |
tree | d6b3ae3faf44737116adf0f0017e8532674e70f3 /lib/bb/build.py | |
parent | 2c8683234acf514706b2b69f5b29405485e664dd (diff) | |
download | bitbake-1c8be64732fdf4f3a608c090b3dc92065d6058d6.tar.gz |
build: fix -D with shell functions
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/build.py')
-rw-r--r-- | lib/bb/build.py | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py index 01da9b3a3..df7bb7d6e 100644 --- a/lib/bb/build.py +++ b/lib/bb/build.py @@ -105,13 +105,27 @@ class InvalidTask(Exception): return "No such task '%s'" % self.task -class tee(file): +class LogTee(object): + def __init__(self, logger, *files): + self.files = files + self.logger = logger + def write(self, string): - logger.plain(string) - file.write(self, string) + self.logger.plain(string) + for f in self.files: + f.write(string) + + def __enter__(self): + for f in self.files: + f.__enter__() + return self + + def __exit__(self, *excinfo): + for f in self.files: + f.__exit__(*excinfo) def __repr__(self): - return "<open[tee] file '{0}'>".format(self.name) + return '<LogTee {0}>'.format(', '.join(repr(f.name) for f in self.files)) def exec_func(func, d, dirs = None): @@ -164,17 +178,13 @@ def exec_func(func, d, dirs = None): except OSError: pass - if logger.getEffectiveLevel() <= logging.DEBUG: - logfile = tee(logfn, 'w') - else: - logfile = open(logfn, 'w') - lockflag = flags.get('lockfiles') if lockflag: lockfiles = [data.expand(f, d) for f in lockflag.split()] else: lockfiles = None + logfile = open(logfn, 'w') with nested(logfile, bb.utils.fileslocked(lockfiles)): try: if ispython: @@ -255,6 +265,9 @@ def exec_func_shell(function, d, runfile, logfile, cwd=None, fakeroot=False): else: cmd = runfile + if logger.getEffectiveLevel() <= logging.DEBUG: + logfile = LogTee(logger, logfile) + try: bb.process.run(cmd, env=env, cwd=cwd, shell=False, stdin=NULL, log=logfile) |