summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script/Main.py
diff options
context:
space:
mode:
authorTom Tanner <ttanner2@bloomberg.net>2013-10-01 12:21:08 (GMT)
committerTom Tanner <ttanner2@bloomberg.net>2013-10-01 12:21:08 (GMT)
commit0359ca7ad334f499031aacb46c0e1a6b33789024 (patch)
treeb59ef236e8e0030e306a246bacaa05ac6ad66d46 /src/engine/SCons/Script/Main.py
parentc9e2d5a843115f68e37c3e0f00c2594f83150f3b (diff)
downloadSCons-0359ca7ad334f499031aacb46c0e1a6b33789024.zip
SCons-0359ca7ad334f499031aacb46c0e1a6b33789024.tar.gz
SCons-0359ca7ad334f499031aacb46c0e1a6b33789024.tar.bz2
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.
Diffstat (limited to 'src/engine/SCons/Script/Main.py')
-rw-r--r--src/engine/SCons/Script/Main.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 9c2e0b9..1651d1e 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