diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2021-04-05 15:29:15 (GMT) |
---|---|---|
committer | Daniel Moody <daniel.moody@mongodb.com> | 2021-04-05 15:29:15 (GMT) |
commit | ce9ea2580fa5e4bb143d5ada308c42e40512be19 (patch) | |
tree | c69516e94832f2126509ed79f31241523e021dd6 /SCons/Environment.py | |
parent | 97ccb53b8b8c8058904ce4c295affc5a99630ca5 (diff) | |
download | SCons-ce9ea2580fa5e4bb143d5ada308c42e40512be19.zip SCons-ce9ea2580fa5e4bb143d5ada308c42e40512be19.tar.gz SCons-ce9ea2580fa5e4bb143d5ada308c42e40512be19.tar.bz2 |
improved DoubleCacheDir test, added extra cachedir validation check.
Diffstat (limited to 'SCons/Environment.py')
-rw-r--r-- | SCons/Environment.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/SCons/Environment.py b/SCons/Environment.py index 35b5d3c..eefd8da 100644 --- a/SCons/Environment.py +++ b/SCons/Environment.py @@ -1031,22 +1031,31 @@ class Base(SubstitutionEnvironment): except KeyError: return None + def validate_CacheDir_class(self, custom_class=None): + """Validate the passed custom CacheDir class, or if no args are passed, + validate the custom CacheDir class from the environment. + """ + + if custom_class is None: + custom_class = self.get("CACHEDIR_CLASS", SCons.CacheDir.CacheDir) + if not issubclass(custom_class, SCons.CacheDir.CacheDir): + raise UserError("Custom CACHEDIR_CLASS %s not derived from CacheDir" % str(custom_class)) + return custom_class + def get_CacheDir(self): try: path = self._CacheDir_path except AttributeError: path = SCons.Defaults.DefaultEnvironment()._CacheDir_path + + cachedir_class = self.validate_CacheDir_class() try: if (path == self._last_CacheDir_path - and self.get("CACHEDIR_CLASS", SCons.CacheDir.CacheDir) == type(self._last_CacheDir)): + and cachedir_class is type(self._last_CacheDir)): return self._last_CacheDir except AttributeError: pass - cachedir_class = self.get("CACHEDIR_CLASS", SCons.CacheDir.CacheDir) - if not issubclass(cachedir_class, SCons.CacheDir.CacheDir): - raise UserError("Custom CACHEDIR_CLASS %s not derived from CacheDir" % str(cachedir_class)) - cd = cachedir_class(path) self._last_CacheDir_path = path self._last_CacheDir = cd @@ -1994,7 +2003,7 @@ class Base(SubstitutionEnvironment): self._CacheDir_path = path if custom_class: - self['CACHEDIR_CLASS'] = custom_class + self['CACHEDIR_CLASS'] = self.validate_CacheDir_class(custom_class) if SCons.Action.execute_actions: # Only initialize the CacheDir if -n/-no_exec was NOT specified. |