diff options
author | Steven Knight <knight@baldmt.com> | 2002-03-22 14:39:01 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-03-22 14:39:01 (GMT) |
commit | 8587b92b72c166857467b2f718560148a9549ad3 (patch) | |
tree | 0e5cf1df71d84bfc5399675debcccc8ed7e1bde5 /src/engine/SCons/Util.py | |
parent | d3dc04b8b7031da1a83f752aa77e23e0919512e5 (diff) | |
download | SCons-8587b92b72c166857467b2f718560148a9549ad3.zip SCons-8587b92b72c166857467b2f718560148a9549ad3.tar.gz SCons-8587b92b72c166857467b2f718560148a9549ad3.tar.bz2 |
Move autogenerate() from SCons.Util.py to SCons.Environmentpy.
Diffstat (limited to 'src/engine/SCons/Util.py')
-rw-r--r-- | src/engine/SCons/Util.py | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 3fb56d9..5175ac5 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -232,138 +232,6 @@ def scons_subst(strSubst, globals, locals, remove=None): cmd_list = scons_subst_list(strSubst, globals, locals, remove) return string.join(map(string.join, cmd_list), '\n') -class VarInterpolator: - def __init__(self, dest, src, prefix, suffix): - self.dest = dest - self.src = src - self.prefix = prefix - self.suffix = suffix - - def prepareSrc(self, dict): - src = dict[self.src] - if is_String(src): - src = string.split(src) - elif not is_List(src): - src = [ src ] - - def prepare(x, dict=dict): - if isinstance(x, SCons.Node.Node): - return x - else: - return scons_subst(x, {}, dict) - - return map(prepare, src) - - def generate(self, dict): - if not dict.has_key(self.src): - dict[self.dest] = '' - return - - src = filter(lambda x: not x is None, self.prepareSrc(dict)) - - if not src: - dict[self.dest] = '' - return - - try: - prefix = str(dict[self.prefix]) - except KeyError: - prefix='' - - try: - suffix = str(dict[self.suffix]) - except KeyError: - suffix ='' - - def autogenFunc(x, suff=suffix, pref=prefix): - """Generate the interpolated variable. If the prefix - ends in a space, or the suffix begins in a space, - leave it as a separate element of the list.""" - ret = [ str(x) ] - if pref and pref[-1] == ' ': - ret.insert(0, pref[:-1]) - else: - ret[0] = pref + ret[0] - if suff and suff[0] == ' ': - ret.append(suff[1:]) - else: - ret[-1] = ret[-1] + suff - return ret - dict[self.dest] = reduce(lambda x, y: x+y, - map(autogenFunc, - src)) - - def instance(self, dir, fs): - return self - -class DirVarInterp(VarInterpolator): - def __init__(self, dest, src, prefix, suffix): - VarInterpolator.__init__(self, dest, src, prefix, suffix) - self.fs = None - self.Dir = None - self.dictInstCache = {} - - def prepareSrc(self, dict): - src = VarInterpolator.prepareSrc(self, dict) - - def prepare(x, self=self): - if isinstance(x, SCons.Node.Node): - return x - elif str(x): - return self.fs.Dir(str(x), directory=self.dir) - else: - return None - - return map(prepare, src) - - def instance(self, dir, fs): - try: - ret = self.dictInstCache[(dir, fs)] - except KeyError: - ret = copy.copy(self) - ret.fs = fs - ret.dir = dir - self.dictInstCache[(dir, fs)] = ret - return ret - - def generate(self, dict): - VarInterpolator.generate(self, dict) - if dict[self.dest]: - dict[self.dest] = ['$('] + dict[self.dest] + ['$)'] - -AUTO_GEN_VARS = ( VarInterpolator('_LIBFLAGS', - 'LIBS', - 'LIBLINKPREFIX', - 'LIBLINKSUFFIX'), - DirVarInterp('_LIBDIRFLAGS', - 'LIBPATH', - 'LIBDIRPREFIX', - 'LIBDIRSUFFIX' ), - DirVarInterp('_INCFLAGS', - 'CPPPATH', - 'INCPREFIX', - 'INCSUFFIX') ) - -def autogenerate(dict, fs = SCons.Node.FS.default_fs, dir = None): - """Autogenerate the "interpolated" environment variables. - We read a static structure that tells us how. AUTO_GEN_VARS - is a tuple of tuples. Each inner tuple has four elements, - each strings referring to an environment variable, and describing - how to autogenerate a particular variable. The elements are: - - 0 - The variable to generate - 1 - The "source" variable, usually a list - 2 - The "prefix" variable - 3 - The "suffix" variable - - The autogenerated variable is a list, consisting of every - element of the source list, or a single element if the source - is a string, with the prefix and suffix - concatenated.""" - - for interp in AUTO_GEN_VARS: - interp.instance(dir, fs).generate(dict) - def render_tree(root, child_func, margin=[0], visited={}): """ Render a tree of nodes into an ASCII tree view. |