Skip to content

Commit bfb1730

Browse files
authored
better handling of complex Macros from cmake model
1 parent 8a841d8 commit bfb1730

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

builder/frameworks/espidf.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ def _normalize_define(define_string):
321321
define_string = define_string.strip()
322322
if "=" in define_string:
323323
define, value = define_string.split("=", maxsplit=1)
324-
if '"' in value and not value.startswith("\\"):
325-
# Escape only raw values
324+
if any(char in value for char in (' ', '<', '>')):
325+
value = f'"{value}"'
326+
elif '"' in value and not value.startswith("\\"):
326327
value = value.replace('"', '\\"')
327328
return (define, value)
328329
return define_string
@@ -333,8 +334,11 @@ def _normalize_define(define_string):
333334
]
334335

335336
for f in compile_group.get("compileCommandFragments", []):
336-
if f.get("fragment", "").startswith("-D"):
337-
result.append(_normalize_define(f["fragment"][2:]))
337+
fragment = f.get("fragment", "").strip()
338+
if fragment.startswith('"'):
339+
fragment = fragment.strip('"')
340+
if fragment.startswith("-D"):
341+
result.append(_normalize_define(fragment[2:]))
338342

339343
return result
340344

0 commit comments

Comments
 (0)