summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2010-06-15 21:04:47 +0000
committerSteven Knight <knight@baldmt.com>2010-06-15 21:04:47 +0000
commitdd8fe6f847d5ad5059f6b3752c904f956ec56c67 (patch)
treec13f47a573efee1038ead7d21149454a70b0dc52 /src
parente93ccd80add56640acbc325439a2f6f5c5ff032e (diff)
downloadscons-dd8fe6f847d5ad5059f6b3752c904f956ec56c67.tar.gz
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.txt6
-rw-r--r--src/engine/SCons/EnvironmentTests.py14
-rw-r--r--src/engine/SCons/Util.py18
3 files changed, 27 insertions, 11 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 2dda4d15..f6a38e1c 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 ec696072..7feb76db 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 cc6c95e0..7a6cb515 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