diff options
| author | Steven Knight <knight@baldmt.com> | 2001-12-11 04:32:16 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2001-12-11 04:32:16 (GMT) |
| commit | 8daebfdc7cdbded48bfd8621ef22fbfc379aaac8 (patch) | |
| tree | 0024016baada614c3b287e0b7f6d6c69329d9547 /src/engine/SCons/Util.py | |
| parent | 1bf8ca0f93778fe5a9392bdd0ac3048dfa31914c (diff) | |
| download | SCons-8daebfdc7cdbded48bfd8621ef22fbfc379aaac8.zip SCons-8daebfdc7cdbded48bfd8621ef22fbfc379aaac8.tar.gz SCons-8daebfdc7cdbded48bfd8621ef22fbfc379aaac8.tar.bz2 | |
Move autogeneration of PATH-based variables from Environment initialization to variable interpolation.
Diffstat (limited to 'src/engine/SCons/Util.py')
| -rw-r--r-- | src/engine/SCons/Util.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 9108f14..b8286d1 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -254,3 +254,62 @@ def find_files(filenames, paths, pass return nodes + + + +# See the documentation for the __autogenerate() method +# for an explanation of this variable... +AUTO_GEN_VARS = ( ( '_LIBFLAGS', + 'LIBS', + 'LIBLINKPREFIX', + 'LIBLINKSUFFIX' ), + ( '_LIBDIRFLAGS', + 'LIBPATH', + 'LIBDIRPREFIX', + 'LIBDIRSUFFIX' ), + ( '_INCFLAGS', + 'CPPPATH', + 'INCPREFIX', + 'INCSUFFIX' ) ) + +def autogenerate(dict): + """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 AUTO_GEN_VARS: + if dict.has_key(strSrc): + src_var = 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(dict[strPref]) + except KeyError: + prefix='' + + try: + suffix = str(dict[strSuff]) + except KeyError: + suffix ='' + + dict[strVarAuto] = map(lambda x, suff=suffix, pref=prefix: \ + pref + os.path.normpath(str(x)) + suff, + src_var) |
