mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Minor improvements // Issue #4710
This commit is contained in:
@ -54,7 +54,7 @@ def GetBuildType(env):
|
|||||||
modes.append("debug")
|
modes.append("debug")
|
||||||
if "__test" in COMMAND_LINE_TARGETS or env.GetProjectOption("build_type") == "test":
|
if "__test" in COMMAND_LINE_TARGETS or env.GetProjectOption("build_type") == "test":
|
||||||
modes.append("test")
|
modes.append("test")
|
||||||
return "+".join(modes or ["release"])
|
return ", ".join(modes or ["release"])
|
||||||
|
|
||||||
|
|
||||||
def BuildProgram(env):
|
def BuildProgram(env):
|
||||||
|
@ -148,7 +148,9 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _load_build_data(self):
|
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:
|
if not data:
|
||||||
raise DebugInvalidOptionsError("Could not load a build configuration")
|
raise DebugInvalidOptionsError("Could not load a build configuration")
|
||||||
return data
|
return data
|
||||||
|
@ -131,27 +131,27 @@ def compute_project_checksum(config):
|
|||||||
return checksum.hexdigest()
|
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
|
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):
|
||||||
env_names = [env_names]
|
env_names = [env_names]
|
||||||
|
|
||||||
with fs.cd(project_dir):
|
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
|
# incompatible build-type data
|
||||||
for name in list(result.keys()):
|
for env_name in list(result.keys()):
|
||||||
build_type = result[name].get("build_type", "")
|
if build_type is None:
|
||||||
outdated_conds = [
|
build_type = ProjectConfig.get_instance().get(
|
||||||
not build_type,
|
f"env:{env_name}", "build_type"
|
||||||
debug and "debug" not in build_type,
|
)
|
||||||
not debug and "debug" in build_type,
|
if result[env_name].get("build_type", "") != build_type:
|
||||||
]
|
del result[env_name]
|
||||||
if any(outdated_conds):
|
|
||||||
del result[name]
|
|
||||||
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_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:
|
if not isinstance(env_or_envs, list) and env_or_envs in result:
|
||||||
return result[env_or_envs]
|
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
|
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
|
# pylint: disable=import-outside-toplevel
|
||||||
from platformio import app
|
from platformio import app
|
||||||
from platformio.run.cli import cli as cmd_run
|
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:
|
if build_type == "debug":
|
||||||
args.extend(["--target", "__debug"])
|
args.extend(["--target", "__debug"])
|
||||||
|
# if build_type == "test":
|
||||||
|
# args.extend(["--target", "__test"])
|
||||||
for name in env_names:
|
for name in env_names:
|
||||||
args.extend(["-e", name])
|
args.extend(["-e", name])
|
||||||
app.set_session_var("pause_telemetry", True)
|
app.set_session_var("pause_telemetry", True)
|
||||||
@ -181,16 +183,16 @@ def _load_build_metadata(project_dir, env_names, debug=False):
|
|||||||
raise result.exception
|
raise result.exception
|
||||||
if '"includes":' not in result.output:
|
if '"includes":' not in result.output:
|
||||||
raise exception.UserSideException(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):
|
def _get_cached_build_metadata(env_names):
|
||||||
build_dir = ProjectConfig.get_instance(
|
build_dir = ProjectConfig.get_instance().get("platformio", "build_dir")
|
||||||
os.path.join(project_dir, "platformio.ini")
|
|
||||||
).get("platformio", "build_dir")
|
|
||||||
result = {}
|
result = {}
|
||||||
for name in env_names:
|
for env_name in env_names:
|
||||||
if not os.path.isfile(os.path.join(build_dir, name, "idedata.json")):
|
if not os.path.isfile(os.path.join(build_dir, env_name, "idedata.json")):
|
||||||
continue
|
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
|
return result
|
||||||
|
@ -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):
|
def get_unity_framework_config(self):
|
||||||
if not self.platform.is_embedded():
|
if not self.platform.is_embedded():
|
||||||
return self.UNITY_FRAMEWORK_CONFIG["native"]
|
return self.UNITY_FRAMEWORK_CONFIG["native"]
|
||||||
|
Reference in New Issue
Block a user