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

This commit is contained in:
Ivan Kravets committed 2023-03-18 22:41:14 -06:00
1 parent d9ff250f82
commit 8d33a3d151
3 files changed
+69 -69

No files matched your search

+63 -64
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