Do not build project when only "monitor" target is passed

This commit is contained in:
Ivan Kravets
2023-03-18 22:41:14 -06:00
parent d9ff250f82
commit 8d33a3d151
3 changed files with 69 additions and 69 deletions

View File

@ -17,10 +17,11 @@ PlatformIO Core 6
6.1.7 (2023-??-??)
~~~~~~~~~~~~~~~~~~
* Show detailed library dependency tree only in the `verbose mode <https://docs.platformio.org/en/latest/core/userguide/cmd_run.html#cmdoption-pio-run-v>`__ (`issue #4517 <https://github.com/platformio/platformio-core/issues/4517>`_)
* Prevented shell injection when converting INO file to CPP (`issue #4532 <https://github.com/platformio/platformio-core/issues/4532>`_)
* Restored project generator for `NetBeans IDE <https://docs.platformio.org/en/latest/integration/ide/netbeans.html>`__
* Improved source file filtering functionality for `Static Code Analysis <https://docs.platformio.org/en/latest/advanced/static-code-analysis/index.html>`__ feature
* Improved source file filtering functionality for the `Static Code Analysis <https://docs.platformio.org/en/latest/advanced/static-code-analysis/index.html>`__ feature, making it easier to analyze only the code you need to
* Added the ability to show a detailed library dependency tree only in `verbose mode <https://docs.platformio.org/en/latest/core/userguide/cmd_run.html#cmdoption-pio-run-v>`__, which can help you understand the relationship between libraries and troubleshoot issues more effectively (`issue #4517 <https://github.com/platformio/platformio-core/issues/4517>`_)
* Added the ability to run only the `device monitor <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html>`__ when using the `pio run -t monitor <https://docs.platformio.org/en/latest/core/userguide/cmd_run.html>`__ command, saving you time and resources by skipping the build process
* Implemented a fix for shell injection vulnerabilities when converting INO files to CPP, ensuring your code is safe and secure (`issue #4532 <https://github.com/platformio/platformio-core/issues/4532>`_)
* Restored the project generator for the `NetBeans IDE <https://docs.platformio.org/en/latest/integration/ide/netbeans.html>`__, providing you with more flexibility and options for your development workflow
6.1.6 (2023-01-23)
~~~~~~~~~~~~~~~~~~

2
docs

Submodule docs updated: e9b309b593...ea46b38c80

View File

@ -104,6 +104,8 @@ def cli(
is_test_running = CTX_META_TEST_IS_RUNNING in ctx.meta
results = []
only_monitor = "monitor" in target and len(target) == 1
command_failed = False
with fs.cd(project_dir):
config = ProjectConfig.get_instance(project_conf)
config.validate(environment)
@ -111,65 +113,75 @@ def cli(
if list_targets:
return print_target_list(list(environment) or config.envs())
# clean obsolete build dir
if not disable_auto_clean:
build_dir = config.get("platformio", "build_dir")
try:
clean_build_dir(build_dir, config)
except ProjectError as exc:
raise exc
except: # pylint: disable=bare-except
click.secho(
"Can not remove temporary directory `%s`. Please remove "
"it manually to avoid build issues" % build_dir,
fg="yellow",
if not only_monitor:
# clean obsolete build dir
if not disable_auto_clean:
build_dir = config.get("platformio", "build_dir")
try:
clean_build_dir(build_dir, config)
except ProjectError as exc:
raise exc
except: # pylint: disable=bare-except
click.secho(
"Can not remove temporary directory `%s`. Please remove "
"it manually to avoid build issues" % build_dir,
fg="yellow",
)
handle_legacy_libdeps(project_dir, config)
default_envs = config.default_envs()
for env in config.envs():
skipenv = any(
[
environment and env not in environment,
not environment and default_envs and env not in default_envs,
]
)
if skipenv:
results.append({"env": env})
continue
# print empty line between multi environment project
if not silent and any(r.get("succeeded") is not None for r in results):
click.echo()
results.append(
process_env(
ctx,
env,
config,
target,
upload_port,
jobs,
program_args,
is_test_running,
silent,
verbose,
)
)
handle_legacy_libdeps(project_dir, config)
default_envs = config.default_envs()
for env in config.envs():
skipenv = any(
[
environment and env not in environment,
not environment and default_envs and env not in default_envs,
]
)
if skipenv:
results.append({"env": env})
continue
# print empty line between multi environment project
if not silent and any(r.get("succeeded") is not None for r in results):
click.echo()
results.append(
process_env(
ctx,
env,
config,
environment,
target,
upload_port,
monitor_port,
jobs,
program_args,
is_test_running,
silent,
verbose,
)
)
command_failed = any(r.get("succeeded") is False for r in results)
if not is_test_running and (command_failed or not silent) and len(results) > 1:
print_processing_summary(results, verbose)
command_failed = any(r.get("succeeded") is False for r in results)
if (
not is_test_running
and (command_failed or not silent)
and len(results) > 1
):
print_processing_summary(results, verbose)
# Reset custom project config
app.set_session_var("custom_project_conf", None)
if command_failed:
raise exception.ReturnErrorCode(1)
if "monitor" in target and "nobuild" not in target:
ctx.invoke(
device_monitor_cmd,
port=monitor_port,
environment=environment[0] if environment else None,
)
return True
@ -177,10 +189,8 @@ def process_env(
ctx,
name,
config,
environments,
targets,
upload_port,
monitor_port,
jobs,
program_args,
is_test_running,
@ -208,17 +218,6 @@ def process_env(
if not is_test_running and (not silent or not result["succeeded"]):
print_processing_footer(result)
if (
result["succeeded"]
and "monitor" in ep.get_build_targets()
and "nobuild" not in ep.get_build_targets()
):
ctx.invoke(
device_monitor_cmd,
port=monitor_port,
environment=environments[0] if environments else None,
)
return result