Tools: Fix idf.py hints to be enabled all the time and being able to disable them

This commit is contained in:
Roland Dobai
2022-08-12 14:01:30 +02:00
parent f11de46bfc
commit 152ce8884b
4 changed files with 8 additions and 10 deletions

View File

@@ -146,7 +146,7 @@ or partition table as applicable.
Hints on how to resolve errors Hints on how to resolve errors
============================== ==============================
``idf.py`` will try to suggest hints on how to resolve errors. It works with a database of hints stored in :idf_file:`tools/idf_py_actions/hints.yml` and the hints will be printed if a match is found for the given error. ``idf.py menuconfig`` is not supported by automatic hints on resolving errors. ``idf.py`` will try to suggest hints on how to resolve errors. It works with a database of hints stored in :idf_file:`tools/idf_py_actions/hints.yml` and the hints will be printed if a match is found for the given error. The menuconfig, gdb and openocd targets are not supported at the moment by automatic hints on resolving errors.
The ``--no-hints`` argument of ``idf.py`` can be used to turn the hints off in case they are not desired. The ``--no-hints`` argument of ``idf.py`` can be used to turn the hints off in case they are not desired.

View File

@@ -30,9 +30,8 @@ def action_extensions(base_actions: Dict, project_path: str) -> Any:
Calls ensure_build_directory() which will run cmake to generate a build Calls ensure_build_directory() which will run cmake to generate a build
directory (with the specified generator) as needed. directory (with the specified generator) as needed.
""" """
hints = not args.no_hints
ensure_build_directory(args, ctx.info_name) ensure_build_directory(args, ctx.info_name)
run_target(target_name, args, force_progression=GENERATORS[args.generator].get('force_progression', False), hints=hints) run_target(target_name, args, force_progression=GENERATORS[args.generator].get('force_progression', False))
def size_target(target_name: str, ctx: Context, args: PropertyDict) -> None: def size_target(target_name: str, ctx: Context, args: PropertyDict) -> None:
""" """
@@ -45,10 +44,9 @@ def action_extensions(base_actions: Dict, project_path: str) -> Any:
def tool_error_handler(e: int, stdout: str, stderr: str) -> None: def tool_error_handler(e: int, stdout: str, stderr: str) -> None:
print_hints(stdout, stderr) print_hints(stdout, stderr)
hints = not args.no_hints
ensure_build_directory(args, ctx.info_name) ensure_build_directory(args, ctx.info_name)
run_target('all', args, force_progression=GENERATORS[args.generator].get('force_progression', False), run_target('all', args, force_progression=GENERATORS[args.generator].get('force_progression', False),
custom_error_handler=tool_error_handler, hints=hints) custom_error_handler=tool_error_handler)
run_target(target_name, args) run_target(target_name, args)
def list_build_system_targets(target_name: str, ctx: Context, args: PropertyDict) -> None: def list_build_system_targets(target_name: str, ctx: Context, args: PropertyDict) -> None:

View File

@@ -175,7 +175,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
ensure_build_directory(args, ctx.info_name) ensure_build_directory(args, ctx.info_name)
esptool_args = _get_esptool_args(args) esptool_args = _get_esptool_args(args)
esptool_args += ['erase_flash'] esptool_args += ['erase_flash']
RunTool('esptool.py', esptool_args, args.build_dir)() RunTool('esptool.py', esptool_args, args.build_dir, hints=not args.no_hints)()
def global_callback(ctx: click.core.Context, global_args: Dict, tasks: PropertyDict) -> None: 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]) encryption = any([task.name in ('encrypted-flash', 'encrypted-app-flash') for task in tasks])

View File

@@ -117,7 +117,7 @@ def fit_text_in_terminal(out: str) -> str:
class RunTool: class RunTool:
def __init__(self, tool_name: str, args: List, cwd: str, env: Dict=None, custom_error_handler: FunctionType=None, build_dir: str=None, def __init__(self, tool_name: str, args: List, cwd: str, env: Dict=None, custom_error_handler: FunctionType=None, build_dir: str=None,
hints: bool=False, force_progression: bool=False, interactive: bool=False) -> None: hints: bool=True, force_progression: bool=False, interactive: bool=False) -> None:
self.tool_name = tool_name self.tool_name = tool_name
self.args = args self.args = args
self.cwd = cwd self.cwd = cwd
@@ -234,12 +234,12 @@ class RunTool:
def run_tool(*args: Any, **kwargs: Any) -> None: def run_tool(*args: Any, **kwargs: Any) -> None:
# Added in case some one use run_tool externally in a idf.py extensions # Added in case someone uses run_tool externally in idf.py extensions
return RunTool(*args, **kwargs)() return RunTool(*args, **kwargs)()
def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None, def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None,
custom_error_handler: FunctionType=None, force_progression: bool=False, hints: bool=False, interactive: bool=False) -> None: custom_error_handler: FunctionType=None, force_progression: bool=False, interactive: bool=False) -> None:
"""Run target in build directory.""" """Run target in build directory."""
if env is None: if env is None:
env = {} env = {}
@@ -250,7 +250,7 @@ def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None,
if args.verbose: if args.verbose:
generator_cmd += [GENERATORS[args.generator]['verbose_flag']] generator_cmd += [GENERATORS[args.generator]['verbose_flag']]
RunTool(generator_cmd[0], generator_cmd + [target_name], args.build_dir, env, custom_error_handler, hints=hints, RunTool(generator_cmd[0], generator_cmd + [target_name], args.build_dir, env, custom_error_handler, hints=not args.no_hints,
force_progression=force_progression, interactive=interactive)() force_progression=force_progression, interactive=interactive)()