summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script/Main.py
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2013-11-02 21:34:02 (GMT)
committerGary Oberbrunner <garyo@oberbrunner.com>2013-11-02 21:34:02 (GMT)
commit540f32bcd903747165947dd998f5c8e426bd9d69 (patch)
tree59a41e432d00e7f454e9996aa77b8cf94f714b67 /src/engine/SCons/Script/Main.py
parentcc202cdc15cd156c458ad9a2f94b2e9145be3ec2 (diff)
parent7fdab2a7cae767172f4dcea67c3ab4d1a37926e2 (diff)
downloadSCons-540f32bcd903747165947dd998f5c8e426bd9d69.zip
SCons-540f32bcd903747165947dd998f5c8e426bd9d69.tar.gz
SCons-540f32bcd903747165947dd998f5c8e426bd9d69.tar.bz2
Merge pull request #88 (for real this time). Prev commit was actually #87.
* Allow multiple options to be specified with --debug=a,b,c * Add support for a readonly cache (--cache-readonly) * Always print stats if requested * Generally try harder to print out a message on build errors
Diffstat (limited to 'src/engine/SCons/Script/Main.py')
-rw-r--r--src/engine/SCons/Script/Main.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index a81ac98..7c21519 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
@@ -272,6 +277,9 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask):
(EnvironmentError, SCons.Errors.StopError,
SCons.Errors.UserError))):
type, value, trace = buildError.exc_info
+ if tb and print_stacktrace:
+ sys.stderr.write("scons: internal stack trace:\n")
+ traceback.print_tb(tb, file=sys.stderr)
traceback.print_exception(type, value, trace)
elif tb and print_stacktrace:
sys.stderr.write("scons: internal stack trace:\n")
@@ -986,9 +994,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 +1082,8 @@ 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
def _build_targets(fs, options, targets, target_top):
@@ -1093,6 +1103,7 @@ def _build_targets(fs, options, targets, target_top):
SCons.Node.FS.set_diskcheck(options.diskcheck)
SCons.CacheDir.cache_enabled = not options.cache_disable
+ SCons.CacheDir.cache_readonly = options.cache_readonly
SCons.CacheDir.cache_debug = options.cache_debug
SCons.CacheDir.cache_force = options.cache_force
SCons.CacheDir.cache_show = options.cache_show
@@ -1302,12 +1313,8 @@ def _exec_main(parser, values):
prof = Profile()
try:
prof.runcall(_main, parser)
- except SConsPrintHelpException, e:
+ finally:
prof.dump_stats(options.profile_file)
- raise e
- except SystemExit:
- pass
- prof.dump_stats(options.profile_file)
else:
_main(parser)
@@ -1345,7 +1352,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
@@ -1362,6 +1372,7 @@ def main():
parser.print_help()
exit_status = 0
except SCons.Errors.BuildError, e:
+ print e
exit_status = e.exitstatus
except:
# An exception here is likely a builtin Python exception Python