summaryrefslogtreecommitdiffstats
path: root/SCons
diff options
context:
space:
mode:
authorIvan Kravets <me@ikravets.com>2022-07-06 12:34:59 (GMT)
committerIvan Kravets <me@ikravets.com>2022-07-06 12:34:59 (GMT)
commitd9192dbf0c4380043759262147e6e06b0caf590e (patch)
treeba4d48a545d33202d07824a84eae5c46b707215d /SCons
parent07dc10b25b6169c9fb7e16dd78de8bb9ea107be6 (diff)
downloadSCons-d9192dbf0c4380043759262147e6e06b0caf590e.zip
SCons-d9192dbf0c4380043759262147e6e06b0caf590e.tar.gz
SCons-d9192dbf0c4380043759262147e6e06b0caf590e.tar.bz2
Conditional C/C++ Preprocessor: Strip shell's backslashes from the computed include (-DFOO_H=\"foo.h\")
Diffstat (limited to 'SCons')
-rw-r--r--SCons/cpp.py3
-rw-r--r--SCons/cppTests.py8
2 files changed, 10 insertions, 1 deletions
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 = [