summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-05-06 22:27:28 (GMT)
committerSteven Knight <knight@baldmt.com>2002-05-06 22:27:28 (GMT)
commita2ceacbe77db1b308f26454477ae3b1f1139eac8 (patch)
tree8f1532baef4ea475eb5ff7bff4e74b15e7d48a27 /src/engine/SCons/Script
parent06b66d7da2547d860be7a124c54d3ddf2ee964e1 (diff)
downloadSCons-a2ceacbe77db1b308f26454477ae3b1f1139eac8.zip
SCons-a2ceacbe77db1b308f26454477ae3b1f1139eac8.tar.gz
SCons-a2ceacbe77db1b308f26454477ae3b1f1139eac8.tar.bz2
Raise an error if a builder is called multiple times for a given target, unless the builder is marked as multicall safe. (Anthony Roach)
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r--src/engine/SCons/Script/__init__.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 105c28f..d0b17d4 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -179,13 +179,36 @@ def _scons_syntax_error(e):
sys.stderr.write(line+'\n')
sys.exit(2)
+def find_deepest_user_frame(tb):
+ """
+ Find the deepest stack frame that is not part of SCons.
+ """
+
+ stack = [tb]
+ while tb.tb_next is not None:
+ tb = tb.tb_next
+ stack.append(tb)
+
+ stack.reverse()
+
+ # find the deepest traceback frame that is not part
+ # of SCons:
+ for frame in stack:
+ filename = frame.tb_frame.f_code.co_filename
+ if string.find(filename, os.sep+'SCons'+os.sep) == -1:
+ tb = frame
+ break
+
+ return tb
+
def _scons_user_error(e):
"""Handle user errors. Print out a message and a description of the
- error, along with the line number and routine where it occured.
+ error, along with the line number and routine where it occured.
+ The file and line number will be the deepest stack frame that is
+ not part of SCons itself.
"""
etype, value, tb = sys.exc_info()
- while tb.tb_next is not None:
- tb = tb.tb_next
+ tb = find_deepest_user_frame(tb)
lineno = traceback.tb_lineno(tb)
filename = tb.tb_frame.f_code.co_filename
routine = tb.tb_frame.f_code.co_name
@@ -196,10 +219,11 @@ def _scons_user_error(e):
def _scons_user_warning(e):
"""Handle user warnings. Print out a message and a description of
the warning, along with the line number and routine where it occured.
+ The file and line number will be the deepest stack frame that is
+ not part of SCons itself.
"""
etype, value, tb = sys.exc_info()
- while tb.tb_next is not None:
- tb = tb.tb_next
+ tb = find_deepest_user_frame(tb)
lineno = traceback.tb_lineno(tb)
filename = tb.tb_frame.f_code.co_filename
routine = tb.tb_frame.f_code.co_name