diff options
author | Steven Knight <knight@baldmt.com> | 2010-06-15 21:04:47 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2010-06-15 21:04:47 (GMT) |
commit | fabff06e1ff1863ded70136f0797814a676a86d4 (patch) | |
tree | c13f47a573efee1038ead7d21149454a70b0dc52 /src | |
parent | 1e73529341eb9559a7ded9e2bb327182f7748305 (diff) | |
download | SCons-fabff06e1ff1863ded70136f0797814a676a86d4.zip SCons-fabff06e1ff1863ded70136f0797814a676a86d4.tar.gz SCons-fabff06e1ff1863ded70136f0797814a676a86d4.tar.bz2 |
Issue 2390: Support appending to $*FLAGS values (CLVar instances) in a
copied construction environment without also affecting the value in
the original construction environment. (Matt Hughes)
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 6 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 14 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 18 |
3 files changed, 27 insertions, 11 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 2dda4d1..f6a38e1 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -12,6 +12,12 @@ RELEASE 2.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - Fix explicit dependencies (Depends()) on Nodes that don't have attached Builders. + From Matt Hughes: + + - Fix the ability to append to default $*FLAGS values (which are + implemented as CLVar instances) in a copied construction environment + without affecting the original construction environment's value. + RELEASE 2.0.0.beta.20100605 - Sat, 05 Jun 2010 21:02:48 -0700 diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index ec69607..7feb76d 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1806,6 +1806,20 @@ def exists(env): env2.Append(FLAGS = 'flag3 flag4') x = env2.get('FLAGS') assert x == ['flag1', 'flag2', 'flag3', 'flag4'], x + x = env1.get('FLAGS') + assert x == ['flag1', 'flag2'], x + + # Ensure that appending directly to a copied CLVar + # doesn't modify the original. + env1 = self.TestEnvironment(FLAGS = CLVar('flag1 flag2')) + x = env1.get('FLAGS') + assert x == ['flag1', 'flag2'], x + env2 = env1.Clone() + env2['FLAGS'] += ['flag3', 'flag4'] + x = env2.get('FLAGS') + assert x == ['flag1', 'flag2', 'flag3', 'flag4'], x + x = env1.get('FLAGS') + assert x == ['flag1', 'flag2'], x # Test that the environment stores the toolpath and # re-uses it for copies. diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index cc6c95e..7a6cb51 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -459,22 +459,18 @@ def _semi_deepcopy_tuple(x): return tuple(map(semi_deepcopy, x)) d[tuple] = _semi_deepcopy_tuple -def _semi_deepcopy_inst(x): - if hasattr(x, '__semi_deepcopy__'): - return x.__semi_deepcopy__() - elif isinstance(x, UserDict): - return x.__class__(_semi_deepcopy_dict(x)) - elif isinstance(x, UserList): - return x.__class__(_semi_deepcopy_list(x)) - else: - return x -d[InstanceType] = _semi_deepcopy_inst - def semi_deepcopy(x): copier = _semi_deepcopy_dispatch.get(type(x)) if copier: return copier(x) else: + if hasattr(x, '__semi_deepcopy__'): + return x.__semi_deepcopy__() + elif isinstance(x, UserDict): + return x.__class__(_semi_deepcopy_dict(x)) + elif isinstance(x, UserList): + return x.__class__(_semi_deepcopy_list(x)) + return x |