Skip to content

Commit

Permalink
Merge pull request SCons#4184 from platformio/master
Browse files Browse the repository at this point in the history
Strip shell's backslashes from the computed include
  • Loading branch information
bdbaddog authored Jul 17, 2022
2 parents 767abe6 + d9192db commit c910030
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions SCons/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ def resolve_include(self, t):
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)

Expand Down
8 changes: 7 additions & 1 deletion SCons/cppTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include XXX_FILE5
#include XXX_FILE6
#include SHELL_ESCAPED_H
"""


Expand Down Expand Up @@ -441,7 +443,8 @@
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"""
Expand Down Expand Up @@ -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):
Expand All @@ -546,6 +550,7 @@ class PreProcessorTestCase(cppAllTestCase):
('include', '<', 'file4-yes'),
('include', '"', 'file5-yes'),
('include', '<', 'file6-yes'),
('include', '"', 'file-shell-computed-yes'),
]

ifdef_expect = [
Expand Down Expand Up @@ -647,6 +652,7 @@ class DumbPreProcessorTestCase(cppAllTestCase):
('include', '<', 'file4-yes'),
('include', '"', 'file5-yes'),
('include', '<', 'file6-yes'),
('include', '"', 'file-shell-computed-yes'),
]

ifdef_expect = [
Expand Down

0 comments on commit c910030

Please sign in to comment.