diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-07-04 20:58:53 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-07-04 20:58:53 (GMT) |
commit | d2c1e938aecf0aa1a3729bf75cfd56458f6d7319 (patch) | |
tree | 2e0f78f0860c3483ca93ebd0f9bd4f45ab34027f /src | |
parent | b82ceff0a9c3b2cdb1f67c8c56bdbbd8dad7861d (diff) | |
download | SCons-d2c1e938aecf0aa1a3729bf75cfd56458f6d7319.zip SCons-d2c1e938aecf0aa1a3729bf75cfd56458f6d7319.tar.gz SCons-d2c1e938aecf0aa1a3729bf75cfd56458f6d7319.tar.bz2 |
Merged in veon/scons (pull request #149).
Merged manually since original was on named branch.
Actual commit author is veon on bitbucket.
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/cpp.py | 7 | ||||
-rw-r--r-- | src/engine/SCons/cppTests.py | 32 |
3 files changed, 39 insertions, 3 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index dca9901..4821e40 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -6,6 +6,9 @@ RELEASE 2.3.2.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE + From veon on bitbucket: + - Fixed handling of nested ifs in CPP scanner PreProcessor class. + From Michael Haubenwallner: - Respect user's CC/CXX values; don't always overwrite in generate() - Delegate linker Tool.exists() to CC/CXX Tool.exists(). diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 0ba10f5..60cfcea 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -395,9 +395,10 @@ class PreProcessor(object): """ d = self.dispatch_table - d['import'] = self.do_import - d['include'] = self.do_include - d['include_next'] = self.do_include + p = self.stack[-1] if self.stack else self.default_table + + for k in ('import', 'include', 'include_next'): + d[k] = p[k] def stop_handling_includes(self, t=None): """ diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 5a06bee..37b4aae 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -327,6 +327,22 @@ no_space_input = """ """ +nested_ifs_input = """ +#define DEFINED + +#ifdef NOT_DEFINED + #include "file7-no" + #ifdef DEFINED + #include "file8-no" + #else + #include "file9-no" + #endif +#else + #include "file7-yes" +#endif +""" + + # pp_class = PreProcessor # #pp_class = DumbPreProcessor @@ -403,6 +419,11 @@ class cppTestCase(unittest.TestCase): result = self.cpp.process_contents(no_space_input) assert expect == result, (expect, result) + def test_nested_ifs(self): + expect = self.nested_ifs_expect + result = self.cpp.process_contents(nested_ifs_input) + assert expect == result, (expect, result) + class cppAllTestCase(cppTestCase): def setUp(self): self.cpp = self.cpp_class(current = ".", @@ -486,6 +507,10 @@ class PreProcessorTestCase(cppAllTestCase): ('include', '"', 'file44-yes'), ] + nested_ifs_expect = [ + ('include', '"', 'file7-yes'), + ] + class DumbPreProcessorTestCase(cppAllTestCase): cpp_class = cpp.DumbPreProcessor @@ -591,6 +616,13 @@ class DumbPreProcessorTestCase(cppAllTestCase): ('include', '"', 'file44-yes'), ] + nested_ifs_expect = [ + ('include', '"', 'file7-no'), + ('include', '"', 'file8-no'), + ('include', '"', 'file9-no'), + ('include', '"', 'file7-yes') + ] + import os |