diff options
author | Ludwig Hähne <pankrat@tigris.org> | 2008-09-12 18:17:06 (GMT) |
---|---|---|
committer | Ludwig Hähne <pankrat@tigris.org> | 2008-09-12 18:17:06 (GMT) |
commit | 0362515ef75b8cefe0222e2c079316e2f8285c40 (patch) | |
tree | 12cea11d007fb56ecc450ee2d2e3a045412c7ec8 | |
parent | 03e8064ca29643a22c0f37fda4e8ff6cbd7acf1d (diff) | |
download | SCons-0362515ef75b8cefe0222e2c079316e2f8285c40.zip SCons-0362515ef75b8cefe0222e2c079316e2f8285c40.tar.gz SCons-0362515ef75b8cefe0222e2c079316e2f8285c40.tar.bz2 |
Issue 2179: Null Executor memory reductions
-rw-r--r-- | src/engine/SCons/Executor.py | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 435b54c..0c198e2 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -322,10 +322,25 @@ class Executor: result.extend(act.get_implicit_deps(self.targets, self.get_sources(), build_env)) return result +nullenv = None -_Executor = Executor +def get_NullEnvironment(): + """Use singleton pattern for Null Environments.""" + global nullenv -class Null(_Executor): + import SCons.Util + class NullEnvironment(SCons.Util.Null): + import SCons.CacheDir + _CacheDir_path = None + _CacheDir = SCons.CacheDir.CacheDir(None) + def get_CacheDir(self): + return self._CacheDir + + if not nullenv: + nullenv = NullEnvironment() + return nullenv + +class Null: """A null Executor, with a null build Environment, that does nothing when the rest of the methods call it. @@ -335,20 +350,40 @@ class Null(_Executor): """ def __init__(self, *args, **kw): if __debug__: logInstanceCreation(self, 'Executor.Null') - kw['action'] = [] - apply(_Executor.__init__, (self,), kw) + self.targets = kw['targets'] def get_build_env(self): - import SCons.Util - class NullEnvironment(SCons.Util.Null): - import SCons.CacheDir - _CacheDir_path = None - _CacheDir = SCons.CacheDir.CacheDir(None) - def get_CacheDir(self): - return self._CacheDir - return NullEnvironment() + return get_NullEnvironment() def get_build_scanner_path(self): return None def cleanup(self): pass def prepare(self): pass + def get_unignored_sources(self, *args, **kw): + return tuple() + def get_action_list(self): + return [] + def __call__(self, *args, **kw): + return 0 + def get_contents(self): + return '' + + def _morph(self): + """Morph this Null executor to a real Executor object.""" + self.__class__ = Executor + self.__init__([], targets=self.targets) + + # The following methods require morphing this Null Executor to a + # real Executor object. + + def add_pre_action(self, action): + self._morph() + self.add_pre_action(action) + def add_post_action(self, action): + self._morph() + self.add_post_action(action) + def set_action_list(self, action): + self._morph() + self.set_action_list(action) + + |