Minor improvements // Issue #4710

This commit is contained in:
Ivan Kravets
2024-02-16 17:06:50 +02:00
parent aa06d21abe
commit 7606dd4faf
4 changed files with 28 additions and 28 deletions

View File

@ -54,7 +54,7 @@ def GetBuildType(env):
modes.append("debug")
if "__test" in COMMAND_LINE_TARGETS or env.GetProjectOption("build_type") == "test":
modes.append("test")
return "+".join(modes or ["release"])
return ", ".join(modes or ["release"])
def BuildProgram(env):

View File

@ -148,7 +148,9 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes
)
def _load_build_data(self):
data = load_build_metadata(os.getcwd(), self.env_name, cache=True, debug=True)
data = load_build_metadata(
os.getcwd(), self.env_name, cache=True, build_type="debug"
)
if not data:
raise DebugInvalidOptionsError("Could not load a build configuration")
return data

View File

@ -131,27 +131,27 @@ def compute_project_checksum(config):
return checksum.hexdigest()
def load_build_metadata(project_dir, env_or_envs, cache=False, debug=False):
def load_build_metadata(project_dir, env_or_envs, cache=False, build_type=None):
assert env_or_envs
env_names = env_or_envs
if not isinstance(env_names, list):
env_names = [env_names]
with fs.cd(project_dir):
result = _get_cached_build_metadata(project_dir, env_names) if cache else {}
result = _get_cached_build_metadata(env_names) if cache else {}
# incompatible build-type data
for name in list(result.keys()):
build_type = result[name].get("build_type", "")
outdated_conds = [
not build_type,
debug and "debug" not in build_type,
not debug and "debug" in build_type,
]
if any(outdated_conds):
del result[name]
for env_name in list(result.keys()):
if build_type is None:
build_type = ProjectConfig.get_instance().get(
f"env:{env_name}", "build_type"
)
if result[env_name].get("build_type", "") != build_type:
del result[env_name]
missed_env_names = set(env_names) - set(result.keys())
if missed_env_names:
result.update(_load_build_metadata(project_dir, missed_env_names, debug))
result.update(
_load_build_metadata(project_dir, missed_env_names, build_type)
)
if not isinstance(env_or_envs, list) and env_or_envs in result:
return result[env_or_envs]
@ -162,14 +162,16 @@ def load_build_metadata(project_dir, env_or_envs, cache=False, debug=False):
load_project_ide_data = load_build_metadata
def _load_build_metadata(project_dir, env_names, debug=False):
def _load_build_metadata(project_dir, env_names, build_type=None):
# pylint: disable=import-outside-toplevel
from platformio import app
from platformio.run.cli import cli as cmd_run
args = ["--project-dir", project_dir, "--target", "__idedata"]
if debug:
if build_type == "debug":
args.extend(["--target", "__debug"])
# if build_type == "test":
# args.extend(["--target", "__test"])
for name in env_names:
args.extend(["-e", name])
app.set_session_var("pause_telemetry", True)
@ -181,16 +183,16 @@ def _load_build_metadata(project_dir, env_names, debug=False):
raise result.exception
if '"includes":' not in result.output:
raise exception.UserSideException(result.output)
return _get_cached_build_metadata(project_dir, env_names)
return _get_cached_build_metadata(env_names)
def _get_cached_build_metadata(project_dir, env_names):
build_dir = ProjectConfig.get_instance(
os.path.join(project_dir, "platformio.ini")
).get("platformio", "build_dir")
def _get_cached_build_metadata(env_names):
build_dir = ProjectConfig.get_instance().get("platformio", "build_dir")
result = {}
for name in env_names:
if not os.path.isfile(os.path.join(build_dir, name, "idedata.json")):
for env_name in env_names:
if not os.path.isfile(os.path.join(build_dir, env_name, "idedata.json")):
continue
result[name] = fs.load_json(os.path.join(build_dir, name, "idedata.json"))
result[env_name] = fs.load_json(
os.path.join(build_dir, env_name, "idedata.json")
)
return result

View File

@ -184,10 +184,6 @@ void unityOutputComplete(void) { unittest_uart_end(); }
),
)
def __init__(self, *args, **kwargs):
"""Delete when Unity > 2.5.2 is released"""
super().__init__(*args, **kwargs)
def get_unity_framework_config(self):
if not self.platform.is_embedded():
return self.UNITY_FRAMEWORK_CONFIG["native"]