diff options
Diffstat (limited to 'src/engine/SCons/Options/__init__.py')
-rw-r--r-- | src/engine/SCons/Options/__init__.py | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/engine/SCons/Options/__init__.py b/src/engine/SCons/Options/__init__.py index e2ad80f..3dc7772 100644 --- a/src/engine/SCons/Options/__init__.py +++ b/src/engine/SCons/Options/__init__.py @@ -29,8 +29,11 @@ customizable variables to an SCons build. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.compat + import os.path import string +import sys import SCons.Errors import SCons.Util @@ -64,6 +67,7 @@ class Options: else: files = [] self.files = files + self.unknown = {} # create the singleton instance if is_global: @@ -158,16 +162,29 @@ class Options: # next set the value specified in the options file for filename in self.files: if os.path.exists(filename): - execfile(filename, values) - - # finally set the values specified on the command line + dir = os.path.split(os.path.abspath(filename))[0] + if dir: + sys.path.insert(0, dir) + try: + values['__name__'] = filename + execfile(filename, {}, values) + finally: + if dir: + del sys.path[0] + del values['__name__'] + + # set the values specified on the command line if args is None: args = self.args for arg, value in args.items(): - for option in self.options: - if arg in option.aliases + [ option.key ]: - values[option.key]=value + added = False + for option in self.options: + if arg in option.aliases + [ option.key ]: + values[option.key] = value + added = True + if not added: + self.unknown[arg] = value # put the variables in the environment: # (don't copy over variables that are not declared as options) @@ -195,6 +212,13 @@ class Options: if option.validator and values.has_key(option.key): option.validator(option.key, env.subst('${%s}'%option.key), env) + def UnknownOptions(self): + """ + Returns any options in the specified arguments lists that + were not known, declared options in this object. + """ + return self.unknown + def Save(self, filename, env): """ Saves all the options in the given file. This file can |