diff options
author | Steven Knight <knight@baldmt.com> | 2004-02-24 06:19:49 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-02-24 06:19:49 (GMT) |
commit | 7e47444082fbd90c50717050873e7c2b3b00a6ea (patch) | |
tree | 21ab8d3cc408214f1e550bf4df7a27c3b45115fe /src/engine/SCons/Util.py | |
parent | 027b93825c3b594b46e5edb9bf33af8089cbf7a4 (diff) | |
download | SCons-7e47444082fbd90c50717050873e7c2b3b00a6ea.zip SCons-7e47444082fbd90c50717050873e7c2b3b00a6ea.tar.gz SCons-7e47444082fbd90c50717050873e7c2b3b00a6ea.tar.bz2 |
Handle recursive substitution in overrides.
Diffstat (limited to 'src/engine/SCons/Util.py')
-rw-r--r-- | src/engine/SCons/Util.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 6643393..4ca25b2 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -788,6 +788,55 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di return ls.data +def scons_subst_once(strSubst, env, key): + """Perform single (non-recursive) substitution of a single + construction variable keyword. + + This is used when setting a variable when copying or overriding values + in an Environment. We want to capture (expand) the old value before + we override it, so people can do things like: + + env2 = env.Copy(CCFLAGS = '$CCFLAGS -g') + + We do this with some straightforward, brute-force code here... + """ + matchlist = ['$' + key, '${' + key + '}'] + if is_List(strSubst): + result = [] + for arg in strSubst: + if is_String(arg): + if arg in matchlist: + arg = env[key] + if is_List(arg): + result.extend(arg) + else: + result.append(arg) + else: + r = [] + for a in _separate_args.findall(arg): + if a in matchlist: + a = env[key] + if is_List(a): + r.extend(string.join(map(str, a))) + else: + r.append(str(a)) + result.append(string.join(r, '')) + else: + result.append(arg) + return result + elif is_String(strSubst): + result = [] + for a in _separate_args.findall(strSubst): + if a in matchlist: + a = env[key] + if is_List(a): + result.extend(string.join(map(str, a))) + else: + result.append(str(a)) + return string.join(result, '') + else: + return strSubst + def render_tree(root, child_func, prune=0, margin=[0], visited={}): """ Render a tree of nodes into an ASCII tree view. |