summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-09-18 23:02:56 (GMT)
committerSteven Knight <knight@baldmt.com>2004-09-18 23:02:56 (GMT)
commita965b2ed53e58047b417e28c41a0f0c0f98b82b7 (patch)
tree96f741d3e308c022c801036190067eab0d115b20 /src
parentaeb8fd273afe8db3b98ad991d6afb94a6007c293 (diff)
downloadSCons-a965b2ed53e58047b417e28c41a0f0c0f98b82b7.zip
SCons-a965b2ed53e58047b417e28c41a0f0c0f98b82b7.tar.gz
SCons-a965b2ed53e58047b417e28c41a0f0c0f98b82b7.tar.bz2
Fix --debug=explain when the action is a Python function.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Action.py10
-rw-r--r--src/engine/SCons/Executor.py20
-rw-r--r--src/engine/SCons/ExecutorTests.py10
-rw-r--r--src/engine/SCons/Node/__init__.py13
5 files changed, 47 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index d7b6693..ee2c546 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -53,6 +53,10 @@ RELEASE 0.97 - XXX
(already supported by Conftest.py) to specify text at the top of
the compiled test file.
+ - Fix the --debug=explain output when a Python function action changed
+ so it prints a meaningful string, not the binary representation of
+ the function contents.
+
From Elliot Murphy:
- Enhance the tests to guarantee persistence of ListOption
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index e110d60..c131693 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -37,6 +37,11 @@ other modules:
to compare the actions used to build a target last time and
this time.
+ strfunction()
+ Returns a substituted string representation of the Action.
+ This is used by the ActionBase.show() command to display the
+ command/function that will be executed to generate the target(s).
+
Subclasses also supply the following methods for internal use within
this module:
@@ -46,11 +51,6 @@ this module:
the pre-substitution command whenever the --debug=presub option
is used.
- strfunction()
- Returns a substituted string representation of the Action.
- This is used by the ActionBase.show() command to display the
- command/function that will be executed to generate the target(s).
-
execute()
The internal method that really, truly, actually handles the
execution of a command or Python function. This is used so
diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py
index b3e6f88..bfb1a65 100644
--- a/src/engine/SCons/Executor.py
+++ b/src/engine/SCons/Executor.py
@@ -137,6 +137,26 @@ class Executor:
self.get_build_env())
return self.string
+ def strfunction(self):
+ try:
+ return self.string
+ except AttributeError:
+ action = self.action
+ build_env = self.get_build_env()
+ if action.strfunction is None:
+ # This instance has strfunction set to None to suppress
+ # printing of the action. Call the method directly
+ # through the class instead.
+ self._strfunc = action.__class__.strfunction(action,
+ self.targets,
+ self.sources,
+ build_env)
+ else:
+ self._strfunc = action.strfunction(self.targets,
+ self.sources,
+ build_env)
+ return self._strfunc
+
def get_raw_contents(self):
"""Fetch the raw signature contents. This, along with
get_contents(), is the real reason this class exists, so we can
diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py
index c4a5552..c391543 100644
--- a/src/engine/SCons/ExecutorTests.py
+++ b/src/engine/SCons/ExecutorTests.py
@@ -48,6 +48,8 @@ class MyAction:
self.actions = actions
def get_actions(self):
return self.actions
+ def strfunction(self, target, source, env):
+ return string.join(['STRFUNCTION'] + self.actions + target + source)
def genstring(self, target, source, env):
return string.join(['GENSTRING'] + self.actions + target + source)
def get_raw_contents(self, target, source, env):
@@ -195,6 +197,14 @@ class ExecutorTestCase(unittest.TestCase):
c = str(x)
assert c == 'GENSTRING action1 action2 t s', c
+ def test_strfunction(self):
+ """Test the strfunction() method"""
+ env = MyEnvironment(S='string')
+
+ x = SCons.Executor.Executor(MyAction(), env, [], ['t'], ['s'])
+ s = x.strfunction()
+ assert s == 'STRFUNCTION action1 action2 t s', s
+
def test_get_raw_contents(self):
"""Test fetching the raw signatures contents"""
env = MyEnvironment(RC='raw contents')
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 0638375..47139fc 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -545,7 +545,7 @@ class Node:
if self.has_builder():
executor = self.get_executor()
- binfo.bact = executor.get_contents()
+ binfo.bact = executor.strfunction()
binfo.bactsig = calc.module.signature(executor)
sigs.append(binfo.bactsig)
@@ -899,10 +899,13 @@ class Node:
if len(lines) == 0:
newact, newactsig = self.binfo.bact, self.binfo.bactsig
- if old.bact != newact:
- lines.append("the build action changed:\n" +
- "%sold: %s\n" % (' '*15, old.bact) +
- "%snew: %s\n" % (' '*15, newact))
+ if old.bactsig != newactsig:
+ if old.bact == newact:
+ lines.append("the contents of the build action changed\n")
+ else:
+ lines.append("the build action changed:\n" +
+ "%sold: %s\n" % (' '*15, old.bact) +
+ "%snew: %s\n" % (' '*15, newact))
if len(lines) == 0:
return "rebuilding `%s' for unknown reasons" % self