summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Util.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-03-05 09:49:04 (GMT)
committerSteven Knight <knight@baldmt.com>2004-03-05 09:49:04 (GMT)
commit36e1b72b7892962fce34bab8ab0d76e93d38ec75 (patch)
treebc5b96fdcd04e1f2bda812416b47d940dfe828ed /src/engine/SCons/Util.py
parent10080da07085cce6fbb702bb0b13b0a4b994bc0d (diff)
downloadSCons-36e1b72b7892962fce34bab8ab0d76e93d38ec75.zip
SCons-36e1b72b7892962fce34bab8ab0d76e93d38ec75.tar.gz
SCons-36e1b72b7892962fce34bab8ab0d76e93d38ec75.tar.bz2
Fix use of things like ${TARGET.dir} in *PATH expansions.
Diffstat (limited to 'src/engine/SCons/Util.py')
-rw-r--r--src/engine/SCons/Util.py35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 97ba8b5..1722f3a 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -501,7 +501,7 @@ _separate_args = re.compile(r'(\$[\$\(\)]|\$[_a-zA-Z][\.\w]*|\${[^}]*}|\s+|[^\s\
# space characters in the string result from the scons_subst() function.
_space_sep = re.compile(r'[\t ]+(?![^{]*})')
-def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=None):
+def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=None, conv=None):
"""Expand a string containing construction variable substitutions.
This is the work-horse function for substitutions in file names
@@ -516,14 +516,14 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No
source with two methods (substitute() and expand()) that handle
the expansion.
"""
- def __init__(self, env, mode, target, source):
+ def __init__(self, env, mode, target, source, conv):
self.env = env
self.mode = mode
self.target = target
self.source = source
self.gvars = env.Dictionary()
- self.str = _strconv[mode]
+ self.conv = conv
def expand(self, s, lvars):
"""Expand a single "token" as necessary, returning an
@@ -570,7 +570,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No
elif is_List(s):
r = []
for l in s:
- r.append(self.str(self.substitute(l, lvars)))
+ r.append(self.conv(self.substitute(l, lvars)))
return string.join(r)
elif callable(s):
s = s(target=self.target,
@@ -593,15 +593,21 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No
args = _separate_args.findall(args)
result = []
for a in args:
- result.append(self.str(self.expand(a, lvars)))
- return string.join(result, '')
+ result.append(self.conv(self.expand(a, lvars)))
+ try:
+ result = string.join(result, '')
+ except TypeError:
+ pass
+ return result
else:
return self.expand(args, lvars)
if dict is None:
dict = subst_dict(target, source)
+ if conv is None:
+ conv = _strconv[mode]
- ss = StringSubber(env, mode, target, source)
+ ss = StringSubber(env, mode, target, source, conv)
result = ss.substitute(strSubst, dict)
if is_String(result):
@@ -617,7 +623,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No
return result
-def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=None):
+def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=None, conv=None):
"""Substitute construction variables in a string (or list or other
object) and separate the arguments into a command list.
@@ -641,7 +647,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di
and the rest of the object takes care of doing the right thing
internally.
"""
- def __init__(self, env, mode, target, source):
+ def __init__(self, env, mode, target, source, conv):
UserList.UserList.__init__(self, [])
self.env = env
self.mode = mode
@@ -654,7 +660,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di
self.add_strip = lambda x, s=self: s.append(x)
else:
self.add_strip = lambda x, s=self: None
- self.str = _strconv[mode]
+ self.conv = conv
self.in_strip = None
self.next_line()
@@ -768,7 +774,10 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di
literal = None
else:
literal = l()
- self[-1].append(CmdStringHolder(self.str(x), literal))
+ x = self.conv(x)
+ if is_String(x):
+ x = CmdStringHolder(x, literal)
+ self[-1].append(x)
self.append = self.add_to_current_word
def open_strip(self, x):
@@ -782,8 +791,10 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di
if dict is None:
dict = subst_dict(target, source)
+ if conv is None:
+ conv = _strconv[mode]
- ls = ListSubber(env, mode, target, source)
+ ls = ListSubber(env, mode, target, source, conv)
ls.substitute(strSubst, dict, 0)
return ls.data