diff options
author | Tom Tanner <ttanner2@bloomberg.net> | 2013-10-01 13:21:08 +0100 |
---|---|---|
committer | Tom Tanner <ttanner2@bloomberg.net> | 2013-10-01 13:21:08 +0100 |
commit | af5ceec23d3481ba40bd9ccb03ed39d001365d65 (patch) | |
tree | 68a354a4ec85fae273ccae609b65b6110ae0d04e | |
parent | da33d39d5174d73f82384559a5855fc966b12db7 (diff) | |
download | scons-af5ceec23d3481ba40bd9ccb03ed39d001365d65.tar.gz |
Revert stdout/stderr to the initial ones in a few places.
There are some situations where scons error messages can just disappear,
and sometimes it's because a build rule or an SConscript or something has
temporarily redirected stdout/stderr.
-rw-r--r-- | src/engine/SCons/Script/Main.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 9c2e0b9e..1651d1eb 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -79,7 +79,12 @@ def fetch_win32_parallel_msg(): import SCons.Platform.win32 return SCons.Platform.win32.parallel_msg -# +def revert_io(): + # This call is added to revert stderr and stdout to the original + # ones just in case some build rule or something else in the system + # has redirected them elsewhere. + sys.stderr = sys.__stderr__ + sys.stdout = sys.__stdout__ class SConsPrintHelpException(Exception): pass @@ -986,9 +991,9 @@ def _main(parser): # reading SConscript files and haven't started building # things yet, stop regardless of whether they used -i or -k # or anything else. + revert_io() sys.stderr.write("scons: *** %s Stop.\n" % e) - exit_status = 2 - sys.exit(exit_status) + sys.exit(2) global sconscript_time sconscript_time = time.time() - start_time @@ -1074,6 +1079,7 @@ def _main(parser): # Build the targets nodes = _build_targets(fs, options, targets, target_top) if not nodes: + revert_io() print 'Found nothing to build' exit_status = 2 @@ -1342,7 +1348,10 @@ def main(): OptionsParser = parser try: - _exec_main(parser, values) + try: + _exec_main(parser, values) + finally: + revert_io() except SystemExit, s: if s: exit_status = s |