Skip to content

Commit 87d27ab

Browse files
authored
better handling of complex Macros from cmake model
1 parent dbd7731 commit 87d27ab

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
@@ -324,8 +324,9 @@ def _normalize_define(define_string):
324324
define_string = define_string.strip()
325325
if "=" in define_string:
326326
define, value = define_string.split("=", maxsplit=1)
327-
if '"' in value and not value.startswith("\\"):
328-
# Escape only raw values
327+
if any(char in value for char in (' ', '<', '>')):
328+
value = f'"{value}"'
329+
elif '"' in value and not value.startswith("\\"):
329330
value = value.replace('"', '\\"')
330331
return (define, value)
331332
return define_string
@@ -336,8 +337,11 @@ def _normalize_define(define_string):
336337
]
337338

338339
for f in compile_group.get("compileCommandFragments", []):
339-
if f.get("fragment", "").startswith("-D"):
340-
result.append(_normalize_define(f["fragment"][2:]))
340+
fragment = f.get("fragment", "").strip()
341+
if fragment.startswith('"'):
342+
fragment = fragment.strip('"')
343+
if fragment.startswith("-D"):
344+
result.append(_normalize_define(fragment[2:]))
341345

342346
return result
343347

0 commit comments

Comments
 (0)