summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-11-06 03:25:46 (GMT)
committerSteven Knight <knight@baldmt.com>2005-11-06 03:25:46 (GMT)
commitc780f70aebdf0fa9d7142303216e11bd68ae59cd (patch)
tree109573cb233feccb33e0e796ec58361ddbff69b3
parent84b4920ce6d6faac79ff97a588893f8f26920091 (diff)
downloadSCons-c780f70aebdf0fa9d7142303216e11bd68ae59cd.zip
SCons-c780f70aebdf0fa9d7142303216e11bd68ae59cd.tar.gz
SCons-c780f70aebdf0fa9d7142303216e11bd68ae59cd.tar.bz2
Fix AppendUnique and PrependUnique concatenating strings to lists. (Patrick Mezard)
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Environment.py8
-rw-r--r--src/engine/SCons/EnvironmentTests.py24
3 files changed, 33 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index de7bf8e..5688178 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -417,6 +417,9 @@ RELEASE 0.97 - XXX
one in the build directory, too, to avoid dangling files left
over from previous runs when a source file is removed.
+ - Allow AppendUnique() and PrependUnique() to append strings (and
+ other atomic objects) to lists.
+
From Georg Mischler:
- Remove the space after the -o option when invoking the Borland
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index ce8e374..3834636 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -747,8 +747,10 @@ class Base(SubstitutionEnvironment):
else:
dk = self._dict[key]
if SCons.Util.is_List(dk):
+ # By elimination, val is not a list. Since dk is a
+ # list, wrap val in a list first.
if not val in dk:
- self._dict[key] = dk + val
+ self._dict[key] = dk + [val]
else:
self._dict[key] = self._dict[key] + val
self.scanner_map_delete(kw)
@@ -1044,8 +1046,10 @@ class Base(SubstitutionEnvironment):
else:
dk = self._dict[key]
if SCons.Util.is_List(dk):
+ # By elimination, val is not a list. Since dk is a
+ # list, wrap val in a list first.
if not val in dk:
- self._dict[key] = val + dk
+ self._dict[key] = [val] + dk
else:
self._dict[key] = val + dk
self.scanner_map_delete(kw)
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index caf8b4a..a397d4f 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -1187,26 +1187,38 @@ def exists(env):
env = Environment(AAA1 = 'a1',
AAA2 = 'a2',
AAA3 = 'a3',
+ AAA4 = 'a4',
+ AAA5 = 'a5',
BBB1 = ['b1'],
BBB2 = ['b2'],
BBB3 = ['b3'],
+ BBB4 = ['b4'],
+ BBB5 = ['b5'],
CCC1 = '',
CCC2 = '')
env.AppendUnique(AAA1 = 'a1',
AAA2 = ['a2'],
AAA3 = ['a3', 'b', 'c', 'a3'],
+ AAA4 = 'a4.new',
+ AAA5 = ['a5.new'],
BBB1 = 'b1',
BBB2 = ['b2'],
BBB3 = ['b3', 'c', 'd', 'b3'],
+ BBB4 = 'b4.new',
+ BBB5 = ['b5.new'],
CCC1 = 'c1',
CCC2 = ['c2'])
assert env['AAA1'] == 'a1a1', env['AAA1']
assert env['AAA2'] == ['a2'], env['AAA2']
assert env['AAA3'] == ['a3', 'b', 'c'], env['AAA3']
+ assert env['AAA4'] == 'a4a4.new', env['AAA4']
+ assert env['AAA5'] == ['a5', 'a5.new'], env['AAA5']
assert env['BBB1'] == ['b1'], env['BBB1']
assert env['BBB2'] == ['b2'], env['BBB2']
assert env['BBB3'] == ['b3', 'c', 'd'], env['BBB3']
+ assert env['BBB4'] == ['b4', 'b4.new'], env['BBB4']
+ assert env['BBB5'] == ['b5', 'b5.new'], env['BBB5']
assert env['CCC1'] == 'c1', env['CCC1']
assert env['CCC2'] == ['c2'], env['CCC2']
@@ -1720,25 +1732,37 @@ f5: \
env = Environment(AAA1 = 'a1',
AAA2 = 'a2',
AAA3 = 'a3',
+ AAA4 = 'a4',
+ AAA5 = 'a5',
BBB1 = ['b1'],
BBB2 = ['b2'],
BBB3 = ['b3'],
+ BBB4 = ['b4'],
+ BBB5 = ['b5'],
CCC1 = '',
CCC2 = '')
env.PrependUnique(AAA1 = 'a1',
AAA2 = ['a2'],
AAA3 = ['a3', 'b', 'c', 'a3'],
+ AAA4 = 'a4.new',
+ AAA5 = ['a5.new'],
BBB1 = 'b1',
BBB2 = ['b2'],
BBB3 = ['b3', 'b', 'c', 'b3'],
+ BBB4 = 'b4.new',
+ BBB5 = ['b5.new'],
CCC1 = 'c1',
CCC2 = ['c2'])
assert env['AAA1'] == 'a1a1', env['AAA1']
assert env['AAA2'] == ['a2'], env['AAA2']
assert env['AAA3'] == ['b', 'c', 'a3'], env['AAA3']
+ assert env['AAA4'] == 'a4.newa4', env['AAA4']
+ assert env['AAA5'] == ['a5.new', 'a5'], env['AAA5']
assert env['BBB1'] == ['b1'], env['BBB1']
assert env['BBB2'] == ['b2'], env['BBB2']
assert env['BBB3'] == ['b', 'c', 'b3'], env['BBB3']
+ assert env['BBB4'] == ['b4.new', 'b4'], env['BBB4']
+ assert env['BBB5'] == ['b5.new', 'b5'], env['BBB5']
assert env['CCC1'] == 'c1', env['CCC1']
assert env['CCC2'] == ['c2'], env['CCC2']