summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathew Robinson <chasinglogic@gmail.com>2019-06-28 14:34:48 -0400
committerMathew Robinson <chasinglogic@gmail.com>2019-07-09 11:13:14 -0400
commit9668453b90f94019074ef65aaf29863e3d23602f (patch)
tree3a3f9db7c7cbaf9894f1cb72e323896078130c38
parent46136a6865894112f74ff9550336a7de5c3c55b0 (diff)
downloadscons-git-9668453b90f94019074ef65aaf29863e3d23602f.tar.gz
Allow builders to inherit from OverrideEnvironments
-rwxr-xr-xsrc/CHANGES.txt4
-rw-r--r--src/engine/SCons/Environment.py15
-rw-r--r--src/engine/SCons/EnvironmentTests.py11
3 files changed, 29 insertions, 1 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index a491ba53b..965bc28be 100755
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -79,6 +79,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Fix more re patterns that contain \ but not specified as raw strings
(affects scanners for D, LaTeX, swig)
+ From Mathew Robinson:
+ - Update cache debug output to include cache hit rate.
+ - No longer unintentionally hide exceptions in Action.py
+ - Allow builders and pseudo-builders to inherit from OverrideEnvironments
RELEASE 3.0.5 - Mon, 26 Mar 2019 15:04:42 -0700
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 7f9a76c5e..395a6a79f 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -2305,7 +2305,20 @@ class OverrideEnvironment(Base):
# Methods that make this class act like a proxy.
def __getattr__(self, name):
- return getattr(self.__dict__['__subject'], name)
+ attr = getattr(self.__dict__['__subject'], name)
+ # Here we check if attr is one of the Wrapper classes. For
+ # example when a pseudo-builder is being called from an
+ # OverrideEnvironment.
+ #
+ # These wrappers when they're constructed capture the
+ # Environment they are being constructed with and so will not
+ # have access to overrided values. So we rebuild them with the
+ # OverrideEnvironment so they have access to overrided values.
+ if isinstance(attr, (MethodWrapper, BuilderWrapper)):
+ return attr.clone(self)
+ else:
+ return attr
+
def __setattr__(self, name, value):
setattr(self.__dict__['__subject'], name, value)
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 1a75a90fa..834cfd17e 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -3587,6 +3587,10 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):
def setUp(self):
env = Environment()
env._dict = {'XXX' : 'x', 'YYY' : 'y'}
+ def verify_value(env, key, value, *args, **kwargs):
+ """Verifies that key is value on the env this is called with."""
+ assert env[key] == value
+ env.AddMethod(verify_value)
env2 = OverrideEnvironment(env, {'XXX' : 'x2'})
env3 = OverrideEnvironment(env2, {'XXX' : 'x3', 'YYY' : 'y3', 'ZZZ' : 'z3'})
self.envs = [ env, env2, env3 ]
@@ -3777,6 +3781,13 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):
# """Test the OverrideEnvironment WhereIs() method"""
# pass
+ def test_PseudoBuilderInherits(self):
+ """Test that pseudo-builders inherit the overrided values."""
+ env, env2, env3 = self.envs
+ env.verify_value('XXX', 'x')
+ env2.verify_value('XXX', 'x2')
+ env3.verify_value('XXX', 'x3')
+
def test_Dir(self):
"""Test the OverrideEnvironment Dir() method"""
env, env2, env3 = self.envs