summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-08-12 22:19:56 (GMT)
committerSteven Knight <knight@baldmt.com>2004-08-12 22:19:56 (GMT)
commit699eed22f57d3cdb919ded2291023652f4c27572 (patch)
treec3b39f557c1af45452f601bf7d81006a95091fbe /src
parentfb16f07bac7dfd01c1d29fd5c12721ead1cc0624 (diff)
downloadSCons-699eed22f57d3cdb919ded2291023652f4c27572.zip
SCons-699eed22f57d3cdb919ded2291023652f4c27572.tar.gz
SCons-699eed22f57d3cdb919ded2291023652f4c27572.tar.bz2
Add a Flatten() function to help the transition to Builders returning lists.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Environment.py3
-rw-r--r--src/engine/SCons/EnvironmentTests.py8
-rw-r--r--src/engine/SCons/Script/SConscript.py1
4 files changed, 15 insertions, 0 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 1c1829d..45d35b9 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -152,6 +152,9 @@ RELEASE 0.96 - XXX
one target. This keeps things consistent and easier to program to
across platforms.
+ - Add a Flatten() function to make it easier to deal with the Builders
+ all returning lists of targets, not individual targets.
+
From Chris Murray:
- Add a .win32 attribute to force file names to expand with
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index e38ebbb..fc4dba0 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -1058,6 +1058,9 @@ class Base:
nodes = self.arg2nodes(dirs, self.fs.Dir)
return SCons.Node.FS.find_file(file, nodes, self.fs.File)
+ def Flatten(self, sequence):
+ return SCons.Util.flatten(sequence)
+
def GetBuildPath(self, files):
result = map(str, self.arg2nodes(files, self.fs.Entry))
if SCons.Util.is_List(files):
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 1b2ceec..e8f3cd8 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -2044,6 +2044,14 @@ class EnvironmentTestCase(unittest.TestCase):
# XXX
+ def test_Flatten(self):
+ """Test the Flatten() method"""
+ env = Environment()
+ l = env.Flatten([1])
+ assert l == [1]
+ l = env.Flatten([1, [2, [3, [4]]]])
+ assert l == [1, 2, 3, 4], l
+
def test_GetBuildPath(self):
"""Test the GetBuildPath() method."""
env = Environment(MAGIC = 'xyzzy')
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 074477f..3146a9c 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -612,6 +612,7 @@ GlobalDefaultEnvironmentFunctions = [
'Execute',
'File',
'FindFile',
+ 'Flatten',
'GetBuildPath',
'Ignore',
'Install',