Rename "load_project_ide_data" to the "load_build_metadata"

This commit is contained in:
Ivan Kravets
2022-05-14 16:29:41 +03:00
parent 40e4e38e0c
commit af5a820862
7 changed files with 19 additions and 17 deletions

View File

@ -232,7 +232,7 @@ if set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS):
except: # pylint: disable=bare-except except: # pylint: disable=bare-except
projenv = env projenv = env
data = projenv.DumpIntegrationData(env) data = projenv.DumpIntegrationData(env)
# dump to file for the further reading by project.helpers.load_project_ide_data # dump to file for the further reading by project.helpers.load_build_metadata
with open( with open(
projenv.subst(os.path.join("$BUILD_DIR", "idedata.json")), projenv.subst(os.path.join("$BUILD_DIR", "idedata.json")),
mode="w", mode="w",

View File

@ -22,7 +22,7 @@ from platformio import fs, proc
from platformio.commands.check.defect import DefectItem from platformio.commands.check.defect import DefectItem
from platformio.package.manager.core import get_core_package_dir from platformio.package.manager.core import get_core_package_dir
from platformio.package.meta import PackageSpec from platformio.package.meta import PackageSpec
from platformio.project.helpers import load_project_ide_data from platformio.project.helpers import load_build_metadata
class CheckToolBase(object): # pylint: disable=too-many-instance-attributes class CheckToolBase(object): # pylint: disable=too-many-instance-attributes
@ -57,7 +57,7 @@ class CheckToolBase(object): # pylint: disable=too-many-instance-attributes
] ]
def _load_cpp_data(self, project_dir): def _load_cpp_data(self, project_dir):
data = load_project_ide_data(project_dir, self.envname) data = load_build_metadata(project_dir, self.envname)
if not data: if not data:
return return
self.cc_flags = click.parser.split_arg_string(data.get("cc_flags", "")) self.cc_flags = click.parser.split_arg_string(data.get("cc_flags", ""))

View File

@ -26,7 +26,7 @@ from platformio.commands.device.command import device_monitor as cmd_device_moni
from platformio.commands.run.helpers import clean_build_dir, handle_legacy_libdeps from platformio.commands.run.helpers import clean_build_dir, handle_legacy_libdeps
from platformio.commands.run.processor import EnvironmentProcessor from platformio.commands.run.processor import EnvironmentProcessor
from platformio.project.config import ProjectConfig from platformio.project.config import ProjectConfig
from platformio.project.helpers import find_project_dir_above, load_project_ide_data from platformio.project.helpers import find_project_dir_above, load_build_metadata
from platformio.test.runners.base import CTX_META_TEST_IS_RUNNING from platformio.test.runners.base import CTX_META_TEST_IS_RUNNING
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches # pylint: disable=too-many-arguments,too-many-locals,too-many-branches
@ -294,7 +294,7 @@ def print_processing_summary(results, verbose=False):
def print_target_list(envs): def print_target_list(envs):
tabular_data = [] tabular_data = []
for env, data in load_project_ide_data(os.getcwd(), envs).items(): for env, data in load_build_metadata(os.getcwd(), envs).items():
tabular_data.extend( tabular_data.extend(
sorted( sorted(
[ [

View File

@ -20,7 +20,7 @@ from platformio.compat import string_types
from platformio.debug.exception import DebugInvalidOptionsError from platformio.debug.exception import DebugInvalidOptionsError
from platformio.debug.helpers import reveal_debug_port from platformio.debug.helpers import reveal_debug_port
from platformio.project.config import ProjectConfig from platformio.project.config import ProjectConfig
from platformio.project.helpers import load_project_ide_data from platformio.project.helpers import load_build_metadata
from platformio.project.options import ProjectOptions from platformio.project.options import ProjectOptions
@ -147,7 +147,7 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes
) )
def _load_build_data(self): def _load_build_data(self):
data = load_project_ide_data(os.getcwd(), self.env_name, cache=True) data = load_build_metadata(os.getcwd(), self.env_name)
if data: if data:
return data return data
raise DebugInvalidOptionsError("Could not load a build configuration") raise DebugInvalidOptionsError("Could not load a build configuration")

View File

@ -21,7 +21,7 @@ from tabulate import tabulate
from platformio import fs from platformio import fs
from platformio.project.config import ProjectConfig from platformio.project.config import ProjectConfig
from platformio.project.exception import NotPlatformIOProjectError from platformio.project.exception import NotPlatformIOProjectError
from platformio.project.helpers import is_platformio_project, load_project_ide_data from platformio.project.helpers import is_platformio_project, load_build_metadata
@click.command("data", short_help="Dump data intended for IDE extensions/plugins") @click.command("data", short_help="Dump data intended for IDE extensions/plugins")
@ -42,7 +42,7 @@ def project_data_cmd(project_dir, environment, json_output):
environment = list(environment or config.envs()) environment = list(environment or config.envs())
if json_output: if json_output:
return click.echo(json.dumps(load_project_ide_data(project_dir, environment))) return click.echo(json.dumps(load_build_metadata(project_dir, environment)))
for envname in environment: for envname in environment:
click.echo("Environment: " + click.style(envname, fg="cyan", bold=True)) click.echo("Environment: " + click.style(envname, fg="cyan", bold=True))
@ -51,9 +51,7 @@ def project_data_cmd(project_dir, environment, json_output):
tabulate( tabulate(
[ [
(click.style(name, bold=True), "=", json.dumps(value, indent=2)) (click.style(name, bold=True), "=", json.dumps(value, indent=2))
for name, value in load_project_ide_data( for name, value in load_build_metadata(project_dir, envname).items()
project_dir, envname
).items()
], ],
tablefmt="plain", tablefmt="plain",
) )

View File

@ -119,7 +119,7 @@ def compute_project_checksum(config):
return checksum.hexdigest() return checksum.hexdigest()
def load_project_ide_data(project_dir, env_or_envs, cache=False): def load_build_metadata(project_dir, env_or_envs, cache=True):
assert env_or_envs assert env_or_envs
env_names = env_or_envs env_names = env_or_envs
if not isinstance(env_names, list): if not isinstance(env_names, list):
@ -129,14 +129,18 @@ def load_project_ide_data(project_dir, env_or_envs, cache=False):
result = _load_cached_project_ide_data(project_dir, env_names) if cache else {} result = _load_cached_project_ide_data(project_dir, env_names) if cache else {}
missed_env_names = set(env_names) - set(result.keys()) missed_env_names = set(env_names) - set(result.keys())
if missed_env_names: if missed_env_names:
result.update(_load_project_ide_data(project_dir, missed_env_names)) result.update(_load_build_metadata(project_dir, missed_env_names))
if not isinstance(env_or_envs, list) and env_or_envs in result: if not isinstance(env_or_envs, list) and env_or_envs in result:
return result[env_or_envs] return result[env_or_envs]
return result or None return result or None
def _load_project_ide_data(project_dir, env_names): # Backward compatibiility with dev-platforms
load_project_ide_data = load_build_metadata
def _load_build_metadata(project_dir, env_names):
# pylint: disable=import-outside-toplevel # pylint: disable=import-outside-toplevel
from platformio.commands.run.command import cli as cmd_run from platformio.commands.run.command import cli as cmd_run

View File

@ -8,7 +8,7 @@
% import os % import os
% import re % import re
% %
% from platformio.project.helpers import load_project_ide_data % from platformio.project.helpers import load_build_metadata
% %
% def _normalize_path(path): % def _normalize_path(path):
% if project_dir in path: % if project_dir in path:
@ -97,7 +97,7 @@ endif()
% %
% ide_data = {} % ide_data = {}
% if leftover_envs: % if leftover_envs:
% ide_data = load_project_ide_data(project_dir, leftover_envs) % ide_data = load_build_metadata(project_dir, leftover_envs)
% end % end
% %
% for env, data in ide_data.items(): % for env, data in ide_data.items():