Skip to content

Commit

Permalink
better handling of complex cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Sep 6, 2024
1 parent 84c5896 commit 3f52134
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ def _normalize_define(define_string):
define_string = define_string.strip()
if "=" in define_string:
define, value = define_string.split("=", maxsplit=1)
if '"' in value and not value.startswith("\\"):
# Escape only raw values
if any(char in value for char in (' ', '<', '>')):
value = f'"{value}"'
elif '"' in value and not value.startswith("\\"):
value = value.replace('"', '\\"')
return (define, value)
return define_string
Expand All @@ -333,8 +334,11 @@ def _normalize_define(define_string):
]

for f in compile_group.get("compileCommandFragments", []):
if f.get("fragment", "").startswith("-D"):
result.append(_normalize_define(f["fragment"][2:]))
fragment = f.get("fragment", "").strip()
if fragment.startswith('"'):
fragment = fragment.strip('"')
if fragment.startswith("-D"):
result.append(_normalize_define(fragment[2:]))

return result

Expand Down

0 comments on commit 3f52134

Please sign in to comment.