Skip to content

Commit 919bd1e

Browse files
authored
better handling of complex Macros from cmake model
1 parent 7caa067 commit 919bd1e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

builder/frameworks/espidf.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,9 @@ def _normalize_define(define_string):
326326
define_string = define_string.strip()
327327
if "=" in define_string:
328328
define, value = define_string.split("=", maxsplit=1)
329-
if '"' in value and not value.startswith("\\"):
330-
# Escape only raw values
329+
if any(char in value for char in (' ', '<', '>')):
330+
value = f'"{value}"'
331+
elif '"' in value and not value.startswith("\\"):
331332
value = value.replace('"', '\\"')
332333
return (define, value)
333334
return define_string
@@ -338,8 +339,11 @@ def _normalize_define(define_string):
338339
]
339340

340341
for f in compile_group.get("compileCommandFragments", []):
341-
if f.get("fragment", "").startswith("-D"):
342-
result.append(_normalize_define(f["fragment"][2:]))
342+
fragment = f.get("fragment", "").strip()
343+
if fragment.startswith('"'):
344+
fragment = fragment.strip('"')
345+
if fragment.startswith("-D"):
346+
result.append(_normalize_define(fragment[2:]))
343347

344348
return result
345349

0 commit comments

Comments
 (0)