diff options
| author | Steven Knight <knight@baldmt.com> | 2004-11-15 12:43:04 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2004-11-15 12:43:04 (GMT) |
| commit | 949becdd3c7437c6f6af345e25c80c24d696d487 (patch) | |
| tree | f78ea2576c829038d84949add151f4a6bee1274c /src/engine | |
| parent | 2822ea95237efa0c8a069e764c3560a3ea221cc0 (diff) | |
| download | SCons-949becdd3c7437c6f6af345e25c80c24d696d487.zip SCons-949becdd3c7437c6f6af345e25c80c24d696d487.tar.gz SCons-949becdd3c7437c6f6af345e25c80c24d696d487.tar.bz2 | |
Easier customization of printable strings for , and .
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/SCons/Action.py | 7 | ||||
| -rw-r--r-- | src/engine/SCons/ActionTests.py | 23 | ||||
| -rw-r--r-- | src/engine/SCons/Defaults.py | 6 |
3 files changed, 32 insertions, 4 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index a8e6c5b..545bd61 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -323,7 +323,7 @@ def _string_from_cmd_list(cmd_list): class CommandAction(_ActionAction): """Class for command-execution actions.""" - def __init__(self, cmd, *args, **kw): + def __init__(self, cmd, cmdstr=None, *args, **kw): # Cmd can actually be a list or a single item; if it's a # single item it should be the command string to execute; if a # list then it should be the words of the command string to @@ -340,6 +340,7 @@ class CommandAction(_ActionAction): raise TypeError, "CommandAction should be given only " \ "a single command" self.cmd_list = cmd + self.cmdstr = cmdstr def __str__(self): if SCons.Util.is_List(self.cmd_list): @@ -347,6 +348,10 @@ class CommandAction(_ActionAction): return str(self.cmd_list) def strfunction(self, target, source, env): + if not self.cmdstr is None: + c = env.subst(self.cmdstr, 0, target, source) + if c: + return c cmd_list = env.subst_list(self.cmd_list, 0, target, source) return _string_from_cmd_list(cmd_list[0]) diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index f52496a..315b1ac 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -674,6 +674,11 @@ class CommandActionTestCase(unittest.TestCase): """ a = SCons.Action.CommandAction(["xyzzy"]) assert a.cmd_list == [ "xyzzy" ], a.cmd_list + assert a.cmdstr is None, a.cmdstr + + a = SCons.Action.CommandAction(["abra"], "cadabra") + assert a.cmd_list == [ "abra" ], a.cmd_list + assert a.cmdstr == "cadabra", a.cmdstr def test___str__(self): """Test fetching the pre-substitution string for command Actions @@ -744,6 +749,15 @@ class CommandActionTestCase(unittest.TestCase): s = act.strfunction([t1, t2], [s1, s2], env) assert s == 'xyzzy t1 s1', s + act = SCons.Action.CommandAction('xyzzy $TARGET $SOURCE', + 'cmdstr - $SOURCE - $TARGET -') + s = act.strfunction([], [], env) + assert s == 'cmdstr - - -', s + s = act.strfunction([t1], [s1], env) + assert s == 'cmdstr - s1 - t1 -', s + s = act.strfunction([t1, t2], [s1, s2], env) + assert s == 'cmdstr - s1 - t1 -', s + act = SCons.Action.CommandAction('xyzzy $TARGETS $SOURCES') s = act.strfunction([], [], env) assert s == 'xyzzy', s @@ -752,6 +766,15 @@ class CommandActionTestCase(unittest.TestCase): s = act.strfunction([t1, t2], [s1, s2], env) assert s == 'xyzzy t1 t2 s1 s2', s + act = SCons.Action.CommandAction('xyzzy $TARGETS $SOURCES', + 'cmdstr = $SOURCES = $TARGETS =') + s = act.strfunction([], [], env) + assert s == 'cmdstr = = =', s + s = act.strfunction([t1], [s1], env) + assert s == 'cmdstr = s1 = t1 =', s + s = act.strfunction([t1, t2], [s1, s2], env) + assert s == 'cmdstr = s1 s2 = t1 t2 =', s + act = SCons.Action.CommandAction(['xyzzy', '$TARGET', '$SOURCE', '$TARGETS', '$SOURCES']) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 8924455..05d0ad8 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -120,13 +120,13 @@ IDLSuffixes = [".idl", ".IDL"] del suffix # Actions for common languages. -CAction = SCons.Action.Action("$CCCOM") +CAction = SCons.Action.Action("$CCCOM", "$CCCOMSTR") DAction = SCons.Action.Action("$DCOM") ShCAction = SCons.Action.Action("$SHCCCOM") -CXXAction = SCons.Action.Action("$CXXCOM") +CXXAction = SCons.Action.Action("$CXXCOM", "$CXXCOMSTR") ShCXXAction = SCons.Action.Action("$SHCXXCOM") -ASAction = SCons.Action.Action("$ASCOM") +ASAction = SCons.Action.Action("$ASCOM", "$ASCOMSTR") ASPPAction = SCons.Action.Action("$ASPPCOM") LinkAction = SCons.Action.Action("$LINKCOM") |
