Skip to content

Commit 5848b23

Browse files
authored
better handling of complex cmake macros
1 parent e79eb2f commit 5848b23

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

builder/frameworks/espidf.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
env = DefaultEnvironment()
5454
env.SConscript("_embed_files.py", exports="env")
5555

56+
# Allow changes in folders of managed components
57+
os.environ["IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS"] = "1"
58+
5659
platform = env.PioPlatform()
5760
board = env.BoardConfig()
5861
mcu = board.get("build.mcu", "esp32")
@@ -252,9 +255,6 @@ def populate_idf_env_vars(idf_env):
252255
os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
253256
)
254257

255-
# if IS_WINDOWS:
256-
# additional_packages.append(platform.get_package_dir("tool-mconf"))
257-
258258
idf_env["PATH"] = os.pathsep.join(additional_packages + [idf_env["PATH"]])
259259

260260
# Some users reported that the `IDF_TOOLS_PATH` var can seep into the
@@ -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

@@ -420,8 +424,8 @@ def _extract_flags(config):
420424
for cg in config["compileGroups"]:
421425
flags[cg["language"]] = []
422426
for ccfragment in cg["compileCommandFragments"]:
423-
fragment = ccfragment.get("fragment", "")
424-
if not fragment.strip() or fragment.startswith("-D"):
427+
fragment = ccfragment.get("fragment", "").strip("\" ")
428+
if not fragment or fragment.startswith("-D"):
425429
continue
426430
flags[cg["language"]].extend(
427431
click.parser.split_arg_string(fragment.strip())
@@ -706,7 +710,7 @@ def prepare_build_envs(config, default_env, debug_allowed=True):
706710
build_env = default_env.Clone()
707711
build_env.SetOption("implicit_cache", 1)
708712
for cc in compile_commands:
709-
build_flags = cc.get("fragment")
713+
build_flags = cc.get("fragment", "").strip("\" ")
710714
if not build_flags.startswith("-D"):
711715
if build_flags.startswith("-include") and ".." in build_flags:
712716
source_index = cg.get("sourceIndexes")[0]
@@ -1255,7 +1259,7 @@ def _get_installed_pip_packages(python_exe_path):
12551259
"future": ">=0.18.3",
12561260
"pyparsing": ">=3.1.0,<4" if IDF5 else ">=2.0.3,<2.4.0",
12571261
"kconfiglib": "~=14.1.0" if IDF5 else "~=13.7.1",
1258-
"idf-component-manager": "~=1.5.2" if IDF5 else "~=1.0",
1262+
"idf-component-manager": "~=2.0.1" if IDF5 else "~=1.0",
12591263
"esp-idf-kconfig": ">=1.4.2,<2.0.0"
12601264
}
12611265

@@ -1292,17 +1296,6 @@ def _get_installed_pip_packages(python_exe_path):
12921296
)
12931297
)
12941298

1295-
# # A special "esp-windows-curses" python package is required on Windows
1296-
# # for Menuconfig on IDF <5
1297-
# if not IDF5 and "esp-windows-curses" not in installed_packages:
1298-
# env.Execute(
1299-
# env.VerboseAction(
1300-
# '"%s" -m pip install "file://%s/tools/kconfig_new/esp-windows-curses"'
1301-
# % (python_exe_path, FRAMEWORK_DIR),
1302-
# "Installing windows-curses package",
1303-
# )
1304-
# )
1305-
13061299

13071300
def get_idf_venv_dir():
13081301
# The name of the IDF venv contains the IDF version to avoid possible conflicts and

0 commit comments

Comments
 (0)