idf.py: Add automated hints on how to resolve errors

This commit is contained in:
simon.chupin
2021-12-08 18:29:14 +01:00
parent dd24639215
commit c6a6eaeb60
11 changed files with 283 additions and 79 deletions

View File

@@ -10,7 +10,7 @@ import click
from idf_monitor_base.output_helpers import yellow_print
from idf_py_actions.errors import FatalError, NoSerialPortFoundError
from idf_py_actions.global_options import global_options
from idf_py_actions.tools import PropertyDict, ensure_build_directory, get_sdkconfig_value, run_target, run_tool
from idf_py_actions.tools import PropertyDict, RunTool, ensure_build_directory, get_sdkconfig_value, run_target
PYTHON = sys.executable
@@ -83,7 +83,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
return result
def monitor(action: str, ctx: click.core.Context, args: PropertyDict, print_filter: str, monitor_baud: str, encrypted: bool,
no_reset: bool, timestamps: bool, timestamp_format: str) -> None:
no_reset: bool, timestamps: bool, timestamp_format: str, force_color: bool) -> None:
"""
Run idf_monitor.py to watch build output
"""
@@ -149,10 +149,14 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
if timestamp_format:
monitor_args += ['--timestamp-format', timestamp_format]
if force_color or os.name == 'nt':
monitor_args += ['--force-color']
idf_py = [PYTHON] + _get_commandline_options(ctx) # commands to re-run idf.py
monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)]
hints = not args.no_hints
run_tool('idf_monitor', monitor_args, args.project_dir)
RunTool('idf_monitor', monitor_args, args.project_dir, build_dir=args.build_dir, hints=hints)()
def flash(action: str, ctx: click.core.Context, args: PropertyDict) -> None:
"""
@@ -171,7 +175,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
ensure_build_directory(args, ctx.info_name)
esptool_args = _get_esptool_args(args)
esptool_args += ['erase_flash']
run_tool('esptool.py', esptool_args, args.build_dir)
RunTool('esptool.py', esptool_args, args.build_dir)()
def global_callback(ctx: click.core.Context, global_args: Dict, tasks: PropertyDict) -> None:
encryption = any([task.name in ('encrypted-flash', 'encrypted-app-flash') for task in tasks])
@@ -285,6 +289,10 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
'help': ('Set the formatting of timestamps compatible with strftime(). '
'For example, "%Y-%m-%d %H:%M:%S".'),
'default': None
}, {
'names': ['--force-color'],
'is_flag': True,
'help': 'Always print ANSI for colors',
}
],