diff options
author | William Deegan <bill@baddogconsulting.com> | 2022-07-17 18:15:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-17 18:15:42 (GMT) |
commit | c9100308647861f69b567f86b997f4862789e627 (patch) | |
tree | bb15ad4f7a7a20090e1e9918756177e20541e085 | |
parent | 767abe618f636e2e00b614f0510f2eaa208fb28e (diff) | |
parent | d9192dbf0c4380043759262147e6e06b0caf590e (diff) | |
download | SCons-c9100308647861f69b567f86b997f4862789e627.zip SCons-c9100308647861f69b567f86b997f4862789e627.tar.gz SCons-c9100308647861f69b567f86b997f4862789e627.tar.bz2 |
Merge pull request #4184 from platformio/master
Strip shell's backslashes from the computed include
-rwxr-xr-x | CHANGES.txt | 3 | ||||
-rw-r--r-- | SCons/cpp.py | 3 | ||||
-rw-r--r-- | SCons/cppTests.py | 8 |
3 files changed, 13 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index bea5838..b516ff2 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -207,6 +207,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added MSVC_USE_SCRIPT_ARGS variable to pass arguments to MSVC_USE_SCRIPT. - Added Configure.CheckMember() checker to check if struct/class has the specified member. + From Ivan Kravets, PlatformIO: + - Conditional C/C++ Preprocessor: Strip shell's backslashes from the computed include (-DFOO_H=\"foo.h\") + RELEASE 4.3.0 - Tue, 16 Nov 2021 18:12:46 -0700 From Jacob Cassagnol: diff --git a/SCons/cpp.py b/SCons/cpp.py index 353aa70..144f498 100644 --- a/SCons/cpp.py +++ b/SCons/cpp.py @@ -591,6 +591,9 @@ class PreProcessor: while not s[0] in '<"': try: s = self.cpp_namespace[s] + # strip backslashes from the computed include (-DFOO_H=\"foo.h\") + for c in '<">': + s = s.replace(f"\\{c}", c) except KeyError: m = function_name.search(s) diff --git a/SCons/cppTests.py b/SCons/cppTests.py index f20c302..f781e81 100644 --- a/SCons/cppTests.py +++ b/SCons/cppTests.py @@ -55,6 +55,8 @@ substitution_input = """ #include XXX_FILE5 #include XXX_FILE6 + +#include SHELL_ESCAPED_H """ @@ -441,7 +443,8 @@ if_no_space_input = """ class cppTestCase(unittest.TestCase): def setUp(self): self.cpp = self.cpp_class(current = ".", - cpppath = ['/usr/include']) + cpppath = ['/usr/include'], + dict={"SHELL_ESCAPED_H": '\\"file-shell-computed-yes\\"'}) def test_basic(self): """Test basic #include scanning""" @@ -531,6 +534,7 @@ class cppAllTestCase(cppTestCase): def setUp(self): self.cpp = self.cpp_class(current = ".", cpppath = ['/usr/include'], + dict={"SHELL_ESCAPED_H": '\\"file-shell-computed-yes\\"'}, all=1) class PreProcessorTestCase(cppAllTestCase): @@ -546,6 +550,7 @@ class PreProcessorTestCase(cppAllTestCase): ('include', '<', 'file4-yes'), ('include', '"', 'file5-yes'), ('include', '<', 'file6-yes'), + ('include', '"', 'file-shell-computed-yes'), ] ifdef_expect = [ @@ -647,6 +652,7 @@ class DumbPreProcessorTestCase(cppAllTestCase): ('include', '<', 'file4-yes'), ('include', '"', 'file5-yes'), ('include', '<', 'file6-yes'), + ('include', '"', 'file-shell-computed-yes'), ] ifdef_expect = [ |