summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-01-11 00:02:51 (GMT)
committerSteven Knight <knight@baldmt.com>2002-01-11 00:02:51 (GMT)
commit726f4a0214cd69aae4b5ca5104bcac483cd9e6f0 (patch)
treeae581e6d6f1ef1ceeeb3a7767c58cd012bcaf7b4
parent3856fae9d787b6da0a3d0cf6eea33193454cd78a (diff)
downloadSCons-726f4a0214cd69aae4b5ca5104bcac483cd9e6f0.zip
SCons-726f4a0214cd69aae4b5ca5104bcac483cd9e6f0.tar.gz
SCons-726f4a0214cd69aae4b5ca5104bcac483cd9e6f0.tar.bz2
Add the InstallAs() method (Charles Crain).
-rw-r--r--doc/man/scons.125
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Environment.py11
-rw-r--r--src/engine/SCons/EnvironmentTests.py11
4 files changed, 50 insertions, 1 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index c19641b..c249162 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -582,6 +582,31 @@ env.Depends('foo.c', 'foo.h')
.PP
.fi
+Additional methods include:
+
+.IP Install
+Installs one or more files in a destination directory.
+The file names remain the same.
+.IP
+.nf
+env.Install(dir = '/usr/local/bin', source = 'foo bar')
+.PP
+.fi
+
+.IP InstallAs
+Installs one or more files as specific file names.
+This allows changing a file name as part of the
+installation:
+.IP
+.nf
+env.Install(dir = '/usr/local/bin/foo', source = 'foo_debug')
+env.Install(target = '../lib/libfoo.a ../lib/libbar.a',
+ source = 'libFOO.a libBAR.a')
+.PP
+.fi
+It is an error if the target and source
+list different numbers of files.
+
.SS Construction Variables
A construction environment has an associated dictionary of construction
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index e739fea..43860f1 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -14,6 +14,8 @@ RELEASE 0.03 -
- Performance improvements in the Node.FS and Sig.Calculator classes.
+ - Add the InstallAs() method.
+
From Steven Knight:
- Search both /usr/lib and /usr/local/lib for scons directories by
@@ -45,6 +47,8 @@ RELEASE 0.03 -
- Use one CPlusPlusAction in the Object Builder's action dictionary,
instead of letting it create multiple identical instances.
+ - Document the Install() and InstallAs() methods.
+
From Steve Leblanc:
- Require that a Builder be given a name argument, supplying a
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 6f77354..612ae9a 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -204,6 +204,17 @@ class Environment:
tgt = tgt[0]
return tgt
+ def InstallAs(self, target, source):
+ """Install sources as targets."""
+ sources = SCons.Util.scons_str2nodes(source)
+ targets = SCons.Util.scons_str2nodes(target)
+ ret = []
+ for src, tgt in map(lambda x, y: (x, y), sources, targets):
+ ret.append(InstallBuilder(self, tgt, src))
+ if len(ret) == 1:
+ ret = ret[0]
+ return ret
+
def subst(self, string):
"""Recursively interpolates construction variables from the
Environment into the specified string, returning the expanded
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 878e736..a65cc33 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -215,7 +215,7 @@ class EnvironmentTestCase(unittest.TestCase):
assert env1 == env2
def test_Install(self):
- """Test Install method"""
+ """Test Install and InstallAs methods"""
env=Environment()
tgt = env.Install('export', [ 'build/foo1', 'build/foo2' ])
paths = map(str, tgt)
@@ -225,6 +225,15 @@ class EnvironmentTestCase(unittest.TestCase):
for tnode in tgt:
assert tnode.builder == InstallBuilder
+ tgt = env.InstallAs(target='foo1 foo2', source='bar1 bar2')
+ assert len(tgt) == 2, len(tgt)
+ paths = map(lambda x: str(x.sources[0]), tgt)
+ paths.sort()
+ expect = map(os.path.normpath, [ 'bar1', 'bar2' ])
+ assert paths == expect, paths
+ for tnode in tgt:
+ assert tnode.builder == InstallBuilder
+
def test_InstallAs(self):
pass # XXX