From 158aabbdf23ed1ff8f5e3f01fb4ef1723a78d3bb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 24 Aug 2022 12:54:35 +0300 Subject: [PATCH] Improved caching of build metadata in debug mode --- HISTORY.rst | 5 +++++ platformio/builder/tools/piointegration.py | 3 ++- platformio/debug/config/base.py | 2 +- platformio/project/helpers.py | 20 ++++++++++++++++---- platformio/telemetry.py | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c59180be..6cacb13e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,6 +13,11 @@ PlatformIO Core 6 **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** +6.1.5 (2022-??-??) +~~~~~~~~~~~~~~~~~~ + +* Improved caching of build metadata in debug mode + 6.1.4 (2022-08-12) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/tools/piointegration.py b/platformio/builder/tools/piointegration.py index d02d980f..3e27dd36 100644 --- a/platformio/builder/tools/piointegration.py +++ b/platformio/builder/tools/piointegration.py @@ -24,7 +24,7 @@ from platformio.proc import exec_command, where_is_program def IsIntegrationDump(_): - return set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS) + return set(["__idedata", "idedata"]) & set(COMMAND_LINE_TARGETS) def DumpIntegrationIncludes(env): @@ -147,6 +147,7 @@ def _subst_cmd(env, cmd): def DumpIntegrationData(*args): projenv, globalenv = args[0:2] # pylint: disable=unbalanced-tuple-unpacking data = { + "build_type": globalenv.GetBuildType(), "env_name": globalenv["PIOENV"], "libsource_dirs": [ globalenv.subst(item) for item in globalenv.GetLibSourceDirs() diff --git a/platformio/debug/config/base.py b/platformio/debug/config/base.py index a5867340..24e20516 100644 --- a/platformio/debug/config/base.py +++ b/platformio/debug/config/base.py @@ -145,7 +145,7 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes ) def _load_build_data(self): - data = load_build_metadata(os.getcwd(), self.env_name, cache=True) + data = load_build_metadata(os.getcwd(), self.env_name, cache=True, debug=True) if data: return data raise DebugInvalidOptionsError("Could not load a build configuration") diff --git a/platformio/project/helpers.py b/platformio/project/helpers.py index d8fb5822..200321f2 100644 --- a/platformio/project/helpers.py +++ b/platformio/project/helpers.py @@ -121,7 +121,7 @@ def compute_project_checksum(config): return checksum.hexdigest() -def load_build_metadata(project_dir, env_or_envs, cache=False): +def load_build_metadata(project_dir, env_or_envs, cache=False, debug=False): assert env_or_envs env_names = env_or_envs if not isinstance(env_names, list): @@ -129,9 +129,19 @@ def load_build_metadata(project_dir, env_or_envs, cache=False): with fs.cd(project_dir): result = _get_cached_build_metadata(project_dir, 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] missed_env_names = set(env_names) - set(result.keys()) if missed_env_names: - result.update(_load_build_metadata(project_dir, missed_env_names)) + result.update(_load_build_metadata(project_dir, missed_env_names, debug)) if not isinstance(env_or_envs, list) and env_or_envs in result: return result[env_or_envs] @@ -142,11 +152,13 @@ def load_build_metadata(project_dir, env_or_envs, cache=False): load_project_ide_data = load_build_metadata -def _load_build_metadata(project_dir, env_names): +def _load_build_metadata(project_dir, env_names, debug=False): # pylint: disable=import-outside-toplevel from platformio.run.cli import cli as cmd_run - args = ["--project-dir", project_dir, "--target", "_idedata"] + args = ["--project-dir", project_dir, "--target", "__idedata"] + if debug: + args.extend(["--target", "__debug"]) for name in env_names: args.extend(["-e", name]) result = CliRunner().invoke(cmd_run, args) diff --git a/platformio/telemetry.py b/platformio/telemetry.py index a3aded5a..3e4b0c6f 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -183,7 +183,7 @@ class MeasurementProtocol(TelemetryBase): def _ignore_hit(self): if not app.get_setting("enable_telemetry"): return True - if self["ea"] in ("Idedata", "_Idedata"): + if self["ea"] in ("Idedata", "__Idedata"): return True return False