From: stevenknight Date: Sun, 27 Apr 2003 04:37:44 +0000 (+0000) Subject: Evaluate Action varlists when calculating signatures. (Steve Christensen) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=124c25f6cba40d1211bcea3ab3a0bf458affdc91;p=scons.git Evaluate Action varlists when calculating signatures. (Steve Christensen) git-svn-id: http://scons.tigris.org/svn/scons/trunk@662 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b77f6a10..7320827c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -38,6 +38,9 @@ RELEASE 0.14 - XXX - Add an optional sort function argument to the GenerateHelpText() Options function. + - Evaluate the "varlist" variables when computing the signature of a + function action. + From Charles Crain: - Parse the source .java files for class names (including inner class diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 9ad925af..764d5279 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -402,8 +402,8 @@ class FunctionAction(ActionBase): except: # "self.execfunction" is a callable object. code = self.execfunction.__call__.im_func.func_code.co_code - return str(code) + string.join(map(lambda v, e=env: str(e[v]), - self.varlist)) + return str(code) + env.subst(string.join(map(lambda v: '${'+v+'}', + self.varlist))) class ListAction(ActionBase): """Class for lists of other actions.""" diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index fb77fe6c..9189b4cf 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -93,7 +93,10 @@ class Environment: return s try: if s[0] == '$': - return self.d.get(s[1:], '') + if s[1] == '{': + return self.d.get(s[2:-1], '') + else: + return self.d.get(s[1:], '') except IndexError: pass return self.d.get(s, s) @@ -844,6 +847,12 @@ class FunctionActionTestCase(unittest.TestCase): c = a.get_contents(target=[], source=[], env=Environment()) assert c == "\177\036\000\177\037\000d\000\000S", repr(c) + a = SCons.Action.FunctionAction(Func, varlist=['XYZ']) + c = a.get_contents(target=[], source=[], env=Environment()) + assert c == "\177\036\000\177\037\000d\000\000S", repr(c) + c = a.get_contents(target=[], source=[], env=Environment(XYZ = 'foo')) + assert c == "\177\036\000\177\037\000d\000\000Sfoo", repr(c) + class ListActionTestCase(unittest.TestCase): def test_init(self):