better handling of complex cmake macros

This commit is contained in:
Jason2866
2024-09-09 19:15:13 +02:00
committed by GitHub
parent e79eb2f683
commit 5848b235cd
+15 -22
View File
@@ -53,6 +53,9 @@ if os.environ.get("PYTHONPATH"):
env = DefaultEnvironment()
env.SConscript("_embed_files.py", exports="env")
# Allow changes in folders of managed components
os.environ["IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS"] = "1"
platform = env.PioPlatform()
board = env.BoardConfig()
mcu = board.get("build.mcu", "esp32")
@@ -252,9 +255,6 @@ def populate_idf_env_vars(idf_env):
os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
)
# if IS_WINDOWS:
# additional_packages.append(platform.get_package_dir("tool-mconf"))
idf_env["PATH"] = os.pathsep.join(additional_packages + [idf_env["PATH"]])
# Some users reported that the `IDF_TOOLS_PATH` var can seep into the
@@ -321,8 +321,9 @@ def extract_defines(compile_group):
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
@@ -333,8 +334,11 @@ def extract_defines(compile_group):
]
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
@@ -420,8 +424,8 @@ def get_app_flags(app_config, default_config):
for cg in config["compileGroups"]:
flags[cg["language"]] = []
for ccfragment in cg["compileCommandFragments"]:
fragment = ccfragment.get("fragment", "")
if not fragment.strip() or fragment.startswith("-D"):
fragment = ccfragment.get("fragment", "").strip("\" ")
if not fragment or fragment.startswith("-D"):
continue
flags[cg["language"]].extend(
click.parser.split_arg_string(fragment.strip())
@@ -706,7 +710,7 @@ def prepare_build_envs(config, default_env, debug_allowed=True):
build_env = default_env.Clone()
build_env.SetOption("implicit_cache", 1)
for cc in compile_commands:
build_flags = cc.get("fragment")
build_flags = cc.get("fragment", "").strip("\" ")
if not build_flags.startswith("-D"):
if build_flags.startswith("-include") and ".." in build_flags:
source_index = cg.get("sourceIndexes")[0]
@@ -1255,7 +1259,7 @@ def install_python_deps():
"future": ">=0.18.3",
"pyparsing": ">=3.1.0,<4" if IDF5 else ">=2.0.3,<2.4.0",
"kconfiglib": "~=14.1.0" if IDF5 else "~=13.7.1",
"idf-component-manager": "~=1.5.2" if IDF5 else "~=1.0",
"idf-component-manager": "~=2.0.1" if IDF5 else "~=1.0",
"esp-idf-kconfig": ">=1.4.2,<2.0.0"
}
@@ -1292,17 +1296,6 @@ def install_python_deps():
)
)
# # A special "esp-windows-curses" python package is required on Windows
# # for Menuconfig on IDF <5
# if not IDF5 and "esp-windows-curses" not in installed_packages:
# env.Execute(
# env.VerboseAction(
# '"%s" -m pip install "file://%s/tools/kconfig_new/esp-windows-curses"'
# % (python_exe_path, FRAMEWORK_DIR),
# "Installing windows-curses package",
# )
# )
def get_idf_venv_dir():
# The name of the IDF venv contains the IDF version to avoid possible conflicts and