diff options
| author | Steven Knight <knight@baldmt.com> | 2001-11-15 03:52:55 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2001-11-15 03:52:55 (GMT) |
| commit | 9508d219188fcd2ad8eb2d24606d1b9c611e9ed2 (patch) | |
| tree | 880af73f3034f4cd6df91d19e94a96a834305a7e /src/engine/SCons/Environment.py | |
| parent | 7f3b3a97f05532ed158371e42edf7b57c0f7b08e (diff) | |
| download | SCons-9508d219188fcd2ad8eb2d24606d1b9c611e9ed2.zip SCons-9508d219188fcd2ad8eb2d24606d1b9c611e9ed2.tar.gz SCons-9508d219188fcd2ad8eb2d24606d1b9c611e9ed2.tar.bz2 | |
LIBS and LIBPATH work, variable substitution changes.
Diffstat (limited to 'src/engine/SCons/Environment.py')
| -rw-r--r-- | src/engine/SCons/Environment.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 5bf31b4..e603b43 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -37,6 +37,7 @@ import types import SCons.Util import SCons.Builder from SCons.Errors import UserError +from UserList import UserList def Command(): pass # XXX @@ -71,6 +72,17 @@ class Environment: Environment. """ + # See the documentation for the __autogenerate() method + # for an explanation of this variable... + AUTO_GEN_VARS = ( ( '_LIBFLAGS', + 'LIBS', + 'LIBLINKPREFIX', + 'LIBLINKSUFFIX' ), + ( '_LIBDIRFLAGS', + 'LIBPATH', + 'LIBDIRPREFIX', + 'LIBDIRSUFFIX' ) ) + def __init__(self, **kw): import SCons.Defaults self._dict = copy.deepcopy(SCons.Defaults.ConstructionEnvironment) @@ -79,6 +91,7 @@ class Environment: if kw.has_key('SCANNERS') and type(kw['SCANNERS']) != type([]): kw['SCANNERS'] = [kw['SCANNERS']] self._dict.update(copy.deepcopy(kw)) + self.__autogenerate() class BuilderWrapper: """Wrapper class that allows an environment to @@ -108,6 +121,48 @@ class Environment: for s in self._dict['SCANNERS']: setattr(self, s.name, s) + def __autogenerate(self): + """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 strVarAuto, strSrc, strPref, strSuff, in self.AUTO_GEN_VARS: + if self._dict.has_key(strSrc): + src_var = self._dict[strSrc] + if type(src_var) is types.ListType or \ + isinstance(src_var, UserList): + src_var = map(str, src_var) + else: + src_var = [ str(src_var), ] + else: + src_var = [] + + try: + prefix = str(self._dict[strPref]) + except KeyError: + prefix='' + + try: + suffix = str(self._dict[strSuff]) + except KeyError: + suffix ='' + + self._dict[strVarAuto] = map(lambda x, suff=suffix, pref=prefix: \ + pref + str(x) + suff, + src_var) + def __cmp__(self, other): return cmp(self._dict, other._dict) @@ -134,6 +189,7 @@ class Environment: construction variables and/or values. """ self._dict.update(copy.deepcopy(kw)) + self.__autogenerate() def Depends(self, target, dependency): """Explicity specify that 'target's depend on 'dependency'.""" |
