summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2006-11-04 05:31:24 (GMT)
committerSteven Knight <knight@baldmt.com>2006-11-04 05:31:24 (GMT)
commitc36a10f28f1c38541757cbbe96d67cd87a2096e7 (patch)
tree6631963b4e4521d9a9a643edc1269409083e4651 /src/engine/SCons
parent6fcc7d78858a5ca068e3deea183d35295b7dd88e (diff)
downloadSCons-c36a10f28f1c38541757cbbe96d67cd87a2096e7.zip
SCons-c36a10f28f1c38541757cbbe96d67cd87a2096e7.tar.gz
SCons-c36a10f28f1c38541757cbbe96d67cd87a2096e7.tar.bz2
Merged revisions 1667-1674 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r1672 | stevenknight | 2006-11-03 23:11:52 -0600 (Fri, 03 Nov 2006) | 1 line 0.96.D480 - Don't use UNIX logic to detect an executable qmtest.py on Windows. ........ r1673 | stevenknight | 2006-11-03 23:18:59 -0600 (Fri, 03 Nov 2006) | 1 line 0.96.D481 - Remove the print statement from the previous checkin. ........ r1674 | stevenknight | 2006-11-03 23:25:43 -0600 (Fri, 03 Nov 2006) | 1 line 0.96.D482 - Create a env.Clone() method and encourage its use in favor of env.Copy(). ........
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/ActionTests.py22
-rw-r--r--src/engine/SCons/Environment.py9
-rw-r--r--src/engine/SCons/EnvironmentTests.py56
-rw-r--r--src/engine/SCons/SConfTests.py8
-rw-r--r--src/engine/SCons/Subst.py2
5 files changed, 56 insertions, 41 deletions
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 57910de..2c6d915 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -152,7 +152,7 @@ class Environment:
return self.d.items()
def Dictionary(self):
return self.d
- def Copy(self, **kw):
+ def Clone(self, **kw):
res = Environment()
res.d = SCons.Environment.our_deepcopy(self.d)
for k, v in kw.items():
@@ -908,7 +908,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd1 = r'%s %s %s xyzzy' % (_python_, act_py, outfile)
act = SCons.Action.CommandAction(cmd1)
- r = act([], [], env.Copy())
+ r = act([], [], env.Clone())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'xyzzy'\n", c
@@ -916,7 +916,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd2 = r'%s %s %s $TARGET' % (_python_, act_py, outfile)
act = SCons.Action.CommandAction(cmd2)
- r = act(DummyNode('foo'), [], env.Copy())
+ r = act(DummyNode('foo'), [], env.Clone())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'foo'\n", c
@@ -924,7 +924,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd3 = r'%s %s %s ${TARGETS}' % (_python_, act_py, outfile)
act = SCons.Action.CommandAction(cmd3)
- r = act(map(DummyNode, ['aaa', 'bbb']), [], env.Copy())
+ r = act(map(DummyNode, ['aaa', 'bbb']), [], env.Clone())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'aaa' 'bbb'\n", c
@@ -932,7 +932,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd4 = r'%s %s %s $SOURCES' % (_python_, act_py, outfile)
act = SCons.Action.CommandAction(cmd4)
- r = act([], [DummyNode('one'), DummyNode('two')], env.Copy())
+ r = act([], [DummyNode('one'), DummyNode('two')], env.Clone())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'one' 'two'\n", c
@@ -941,7 +941,7 @@ class CommandActionTestCase(unittest.TestCase):
act = SCons.Action.CommandAction(cmd4)
sources = [DummyNode('three'), DummyNode('four'), DummyNode('five')]
- env2 = env.Copy()
+ env2 = env.Clone()
r = act([], source = sources, env = env2)
assert r == 0
c = test.read(outfile, 'r')
@@ -964,7 +964,7 @@ class CommandActionTestCase(unittest.TestCase):
act = SCons.Action.CommandAction(cmd5)
r = act(target = DummyNode('out5'),
source = [],
- env = env.Copy(ENV = {'XYZZY' : 'xyzzy5',
+ env = env.Clone(ENV = {'XYZZY' : 'xyzzy5',
'PATH' : PATH}))
assert r == 0
c = test.read(outfile, 'r')
@@ -985,7 +985,7 @@ class CommandActionTestCase(unittest.TestCase):
act = SCons.Action.CommandAction(cmd6)
r = act(target = [Obj('111'), Obj('222')],
source = [Obj('333'), Obj('444'), Obj('555')],
- env = env.Copy())
+ env = env.Clone())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: '222' '111' '333' '444'\n", c
@@ -1004,18 +1004,18 @@ class CommandActionTestCase(unittest.TestCase):
# Test that a nonexistent command returns 127
act = SCons.Action.CommandAction(python + "_no_such_command_")
- r = act([], [], env.Copy(out = outfile))
+ r = act([], [], env.Clone(out = outfile))
assert r == expect_nonexistent, "r == %d" % r
# Test that trying to execute a directory returns 126
dir, tail = os.path.split(python)
act = SCons.Action.CommandAction(dir)
- r = act([], [], env.Copy(out = outfile))
+ r = act([], [], env.Clone(out = outfile))
assert r == expect_nonexecutable, "r == %d" % r
# Test that trying to execute a non-executable file returns 126
act = SCons.Action.CommandAction(outfile)
- r = act([], [], env.Copy(out = outfile))
+ r = act([], [], env.Clone(out = outfile))
assert r == expect_nonexecutable, "r == %d" % r
act = SCons.Action.CommandAction('%s %s 1' % (_python_, exit_py))
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 7aa1909..a5bffc8 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -474,7 +474,7 @@ class SubstitutionEnvironment:
the overrides dictionaries. "overrides" is a dictionary that
will override the variables of this environment.
- This function is much more efficient than Copy() or creating
+ This function is much more efficient than Clone() or creating
a new Environment because it doesn't copy the construction
environment dictionary, it just wraps the underlying construction
environment, and doesn't even create a wrapper object if there
@@ -999,7 +999,7 @@ class Base(SubstitutionEnvironment):
self._dict[key] = self._dict[key] + val
self.scanner_map_delete(kw)
- def Copy(self, tools=[], toolpath=None, **kw):
+ def Clone(self, tools=[], toolpath=None, **kw):
"""Return a copy of a construction Environment. The
copy is like a Python "deep copy"--that is, independent
copies are made recursively of each objects--except that
@@ -1023,9 +1023,12 @@ class Base(SubstitutionEnvironment):
for key, value in kw.items():
new[key] = SCons.Subst.scons_subst_once(value, self, key)
apply(clone.Replace, (), new)
- if __debug__: logInstanceCreation(self, 'Environment.EnvironmentCopy')
+ if __debug__: logInstanceCreation(self, 'Environment.EnvironmentClone')
return clone
+ def Copy(self, *args, **kw):
+ return apply(self.Clone, args, kw)
+
def Detect(self, progs):
"""Return the first available program in progs. __cacheable__
"""
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 52aac23..edf3740 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -834,7 +834,7 @@ class BaseTestCase(unittest.TestCase,TestEnvironmentFixture):
assert built_it['out2']
assert built_it['out3']
- env4 = env3.Copy()
+ env4 = env3.Clone()
assert env4.builder1.env is env4, "builder1.env (%s) == env3 (%s)?" % (env4.builder1.env, env3)
assert env4.builder2.env is env4, "builder2.env (%s) == env3 (%s)?" % (env4.builder1.env, env3)
@@ -915,7 +915,7 @@ class BaseTestCase(unittest.TestCase,TestEnvironmentFixture):
s = map(env.get_scanner, suffixes)
assert s == [s1, s1, None, s2, s3], s
- env = env.Copy(SCANNERS = [s2])
+ env = env.Clone(SCANNERS = [s2])
s = map(env.get_scanner, suffixes)
assert s == [None, None, None, s2, None], s
@@ -1468,19 +1468,19 @@ def exists(env):
assert isinstance(result, CLVar), repr(result)
assert result == ['bar'], result
- def test_Copy(self):
+ def test_Clone(self):
"""Test construction environment copying
Update the copy independently afterwards and check that
the original remains intact (that is, no dangling
references point to objects in the copied environment).
- Copy the original with some construction variable
+ Clone the original with some construction variable
updates and check that the original remains intact
and the copy has the updated values.
"""
env1 = self.TestEnvironment(XXX = 'x', YYY = 'y')
- env2 = env1.Copy()
- env1copy = env1.Copy()
+ env2 = env1.Clone()
+ env1copy = env1.Clone()
assert env1copy == env1copy
assert env2 == env2
env2.Replace(YYY = 'yyy')
@@ -1488,7 +1488,7 @@ def exists(env):
assert env1 != env2
assert env1 == env1copy
- env3 = env1.Copy(XXX = 'x3', ZZZ = 'z3')
+ env3 = env1.Clone(XXX = 'x3', ZZZ = 'z3')
assert env3 == env3
assert env3.Dictionary('XXX') == 'x3'
assert env3.Dictionary('YYY') == 'y'
@@ -1501,7 +1501,7 @@ def exists(env):
pass
env1 = self.TestEnvironment(XXX=TestA(), YYY = [ 1, 2, 3 ],
ZZZ = { 1:2, 3:4 })
- env2=env1.Copy()
+ env2=env1.Clone()
env2.Dictionary('YYY').append(4)
env2.Dictionary('ZZZ')[5] = 6
assert env1.Dictionary('XXX') is env2.Dictionary('XXX')
@@ -1514,7 +1514,7 @@ def exists(env):
env1 = self.TestEnvironment(BUILDERS = {'b1' : 1})
assert hasattr(env1, 'b1'), "env1.b1 was not set"
assert env1.b1.env == env1, "b1.env doesn't point to env1"
- env2 = env1.Copy(BUILDERS = {'b2' : 2})
+ env2 = env1.Clone(BUILDERS = {'b2' : 2})
assert env2 is env2
assert env2 == env2
assert hasattr(env1, 'b1'), "b1 was mistakenly cleared from env1"
@@ -1529,8 +1529,8 @@ def exists(env):
def bar(env): env['BAR'] = 2
def baz(env): env['BAZ'] = 3
env1 = self.TestEnvironment(tools=[foo])
- env2 = env1.Copy()
- env3 = env1.Copy(tools=[bar, baz])
+ env2 = env1.Clone()
+ env3 = env1.Clone(tools=[bar, baz])
assert env1.get('FOO') is 1
assert env1.get('BAR') is None
@@ -1545,7 +1545,7 @@ def exists(env):
# Ensure that recursive variable substitution when copying
# environments works properly.
env1 = self.TestEnvironment(CCFLAGS = '-DFOO', XYZ = '-DXYZ')
- env2 = env1.Copy(CCFLAGS = '$CCFLAGS -DBAR',
+ env2 = env1.Clone(CCFLAGS = '$CCFLAGS -DBAR',
XYZ = ['-DABC', 'x $XYZ y', '-DDEF'])
x = env2.get('CCFLAGS')
assert x == '-DFOO -DBAR', x
@@ -1557,7 +1557,7 @@ def exists(env):
env1 = self.TestEnvironment(FLAGS = CLVar('flag1 flag2'))
x = env1.get('FLAGS')
assert x == ['flag1', 'flag2'], x
- env2 = env1.Copy()
+ env2 = env1.Clone()
env2.Append(FLAGS = 'flag3 flag4')
x = env2.get('FLAGS')
assert x == ['flag1', 'flag2', 'flag3', 'flag4'], x
@@ -1582,9 +1582,21 @@ def generate(env):
env = self.TestEnvironment(tools=['xxx'], toolpath=[test.workpath('')])
assert env['XXX'] == 'one', env['XXX']
- env = env.Copy(tools=['yyy'])
+ env = env.Clone(tools=['yyy'])
assert env['YYY'] == 'two', env['YYY']
+ def test_Copy(self):
+ """Test copying using the old env.Copy() method"""
+ env1 = self.TestEnvironment(XXX = 'x', YYY = 'y')
+ env2 = env1.Copy()
+ env1copy = env1.Copy()
+ assert env1copy == env1copy
+ assert env2 == env2
+ env2.Replace(YYY = 'yyy')
+ assert env2 == env2
+ assert env1 != env2
+ assert env1 == env1copy
+
def test_Detect(self):
"""Test Detect()ing tools"""
test = TestCmd.TestCmd(workdir = '')
@@ -3166,11 +3178,11 @@ def generate(env):
for x in added:
assert env.has_key(x), bad_msg % x
- copy = env.Copy(TARGETS = 'targets',
- SOURCES = 'sources',
- SOURCE = 'source',
- TARGET = 'target',
- COPY = 'copy')
+ copy = env.Clone(TARGETS = 'targets',
+ SOURCES = 'sources',
+ SOURCE = 'source',
+ TARGET = 'target',
+ COPY = 'copy')
for x in reserved:
assert not copy.has_key(x), env[x]
for x in added + ['COPY']:
@@ -3341,10 +3353,10 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):
# SourceSignatures()
# TargetSignatures()
- # It's unlikely Copy() will ever be called this way, so let the
+ # It's unlikely Clone() will ever be called this way, so let the
# other methods test that handling overridden values works.
- #def test_Copy(self):
- # """Test the OverrideEnvironment Copy() method"""
+ #def test_Clone(self):
+ # """Test the OverrideEnvironment Clone() method"""
# pass
def test_FindIxes(self):
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py
index 0acbee3..3ad4cc7 100644
--- a/src/engine/SCons/SConfTests.py
+++ b/src/engine/SCons/SConfTests.py
@@ -386,7 +386,7 @@ int main() {
def libs(env):
return env.get('LIBS', [])
- env = sconf.env.Copy()
+ env = sconf.env.Clone()
try:
r = sconf.CheckLib( existing_lib, "main", autoadd=1 )
@@ -395,7 +395,7 @@ int main() {
got = libs(sconf.env)
assert got == expect, "LIBS: expected %s, got %s" % (expect, got)
- sconf.env = env.Copy()
+ sconf.env = env.Clone()
r = sconf.CheckLib( existing_lib, "main", autoadd=0 )
assert r, "did not find main in %s" % existing_lib
expect = libs(env)
@@ -449,7 +449,7 @@ int main() {
def libs(env):
return env.get('LIBS', [])
- env = sconf.env.Copy()
+ env = sconf.env.Clone()
try:
r = sconf.CheckLibWithHeader( existing_lib, "math.h", "C", autoadd=1 )
@@ -458,7 +458,7 @@ int main() {
got = libs(sconf.env)
assert got == expect, "LIBS: expected %s, got %s" % (expect, got)
- sconf.env = env.Copy()
+ sconf.env = env.Clone()
r = sconf.CheckLibWithHeader( existing_lib, "math.h", "C", autoadd=0 )
assert r, "did not find math.h with %s" % existing_lib
expect = libs(env)
diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py
index eff8f97..b100473 100644
--- a/src/engine/SCons/Subst.py
+++ b/src/engine/SCons/Subst.py
@@ -795,7 +795,7 @@ def scons_subst_once(strSubst, env, key):
in an Environment. We want to capture (expand) the old value before
we override it, so people can do things like:
- env2 = env.Copy(CCFLAGS = '$CCFLAGS -g')
+ env2 = env.Clone(CCFLAGS = '$CCFLAGS -g')
We do this with some straightforward, brute-force code here...
"""