From 43951354c851255d6f85686814cd3e679ca7703c Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 7 Feb 2004 13:19:34 +0000 Subject: [PATCH] Move the __env__ construction variable into the Environment itself, not created in the subst_dict each time. git-svn-id: http://scons.tigris.org/svn/scons/trunk@891 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Action.py | 2 +- src/engine/SCons/Environment.py | 1 + src/engine/SCons/Util.py | 12 ++++-------- src/engine/SCons/UtilTests.py | 11 +++-------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index d9dbca13..6759b02b 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -440,7 +440,7 @@ class ListAction(ActionBase): Simple concatenation of the signatures of the elements. """ - dict = SCons.Util.subst_dict(target, source, env) + dict = SCons.Util.subst_dict(target, source) return string.join(map(lambda x, t=target, s=source, e=env, d=dict: x.get_contents(t, s, e, d), self.list), diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 43cb2c31..46897ef9 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -218,6 +218,7 @@ class Base: self.lookup_list = SCons.Node.arg2nodes_lookups self._dict = our_deepcopy(SCons.Defaults.ConstructionEnvironment) + self._dict['__env__'] = self self._dict['BUILDERS'] = BuilderDict(self._dict['BUILDERS'], self) if platform is None: diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 594274a5..66433938 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -440,7 +440,7 @@ class Target_or_Source: return '' return repr(nl0) -def subst_dict(target, source, env): +def subst_dict(target, source): """Create a dictionary for substitution of special construction variables. @@ -453,12 +453,8 @@ def subst_dict(target, source, env): source - the source (object or array of objects), used to generate the SOURCES and SOURCE construction variables - - env - the construction Environment used for this - build, which is made available as the __env__ - construction variable """ - dict = { '__env__' : env, } + dict = {} if target: tnl = NLWrapper(target, lambda x: x.get_subst_proxy()) @@ -603,7 +599,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No return self.expand(args, lvars) if dict is None: - dict = subst_dict(target, source, env) + dict = subst_dict(target, source) ss = StringSubber(env, mode, target, source) result = ss.substitute(strSubst, dict) @@ -785,7 +781,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di self.in_strip = None if dict is None: - dict = subst_dict(target, source, env) + dict = subst_dict(target, source) ls = ListSubber(env, mode, target, source) ls.substitute(strSubst, dict, 0) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 64689496..687d464c 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -1133,14 +1133,9 @@ class UtilTestCase(unittest.TestCase): def test_subst_dict(self): """Test substituting dictionary values in an Action """ - env = DummyEnv({'a' : 'A', 'b' : 'B'}) - d = subst_dict([], [], env) - assert d['__env__'] is env, d['__env__'] - t = DummyNode('t') s = DummyNode('s') - env = DummyEnv() - d = subst_dict(target=t, source=s, env=env) + d = subst_dict(target=t, source=s) assert str(d['TARGETS'][0]) == 't', d['TARGETS'] assert str(d['TARGET']) == 't', d['TARGET'] assert str(d['SOURCES'][0]) == 's', d['SOURCES'] @@ -1150,7 +1145,7 @@ class UtilTestCase(unittest.TestCase): t2 = DummyNode('t2') s1 = DummyNode('s1') s2 = DummyNode('s2') - d = subst_dict(target=[t1, t2], source=[s1, s2], env=env) + d = subst_dict(target=[t1, t2], source=[s1, s2]) TARGETS = map(lambda x: str(x), d['TARGETS']) TARGETS.sort() assert TARGETS == ['t1', 't2'], d['TARGETS'] @@ -1174,7 +1169,7 @@ class UtilTestCase(unittest.TestCase): t4 = DummyNode('t4') s3 = DummyNode('s3') s4 = N('s4') - d = subst_dict(target=[t3, t4], source=[s3, s4], env=env) + d = subst_dict(target=[t3, t4], source=[s3, s4]) TARGETS = map(lambda x: str(x), d['TARGETS']) TARGETS.sort() assert TARGETS == ['t3', 't4'], d['TARGETS'] -- 2.26.2