diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-07-09 16:22:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-09 16:22:49 (GMT) |
commit | 3d6ab8bfba859ac5ffb1cfc1052c4d7726d4bc72 (patch) | |
tree | 08009dc4e54f76321a693fa694eaa06ed904814c | |
parent | 46136a6865894112f74ff9550336a7de5c3c55b0 (diff) | |
parent | d13584b4110cf9b725c862919baf7b773933d096 (diff) | |
download | SCons-3d6ab8bfba859ac5ffb1cfc1052c4d7726d4bc72.zip SCons-3d6ab8bfba859ac5ffb1cfc1052c4d7726d4bc72.tar.gz SCons-3d6ab8bfba859ac5ffb1cfc1052c4d7726d4bc72.tar.bz2 |
Merge pull request #3401 from chasinglogic/inherit-overrides
Allow builders to inherit from OverrideEnvironments
-rwxr-xr-x | src/CHANGES.txt | 4 | ||||
-rwxr-xr-x | src/RELEASE.txt | 8 | ||||
-rw-r--r-- | src/engine/SCons/Environment.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 11 |
4 files changed, 37 insertions, 1 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a491ba5..965bc28 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/RELEASE.txt b/src/RELEASE.txt index efa35eb..c95c336 100755 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -54,6 +54,14 @@ ->Implicit Old:/usr/bin/python New:/usr/bin/python + + - Changed: Pseudo-builders now inherit OverrideEnvironments. For + example when calling a pseudo-builder from another + pseudo-builder the override variables passed to the first + pseudo-builder call had to be explicitly passed on to the + internal pseudo-builder call. Now the second pseudo-builder call + will automatically inherit these override values. + FIXES - List fixes of outright bugs diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 7f9a76c..395a6a7 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 1a75a90..834cfd1 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 |