Преглед изворни кода

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

Roland Dobai пре 3 година
родитељ
комит
152ce8884b

+ 1 - 1
docs/en/api-guides/tools/idf-py.rst

@@ -146,7 +146,7 @@ or partition table as applicable.
 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.
 

+ 2 - 4
tools/idf_py_actions/core_ext.py

@@ -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
         directory (with the specified generator) as needed.
         """
-        hints = not args.no_hints
         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:
         """
@@ -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:
             print_hints(stdout, stderr)
 
-        hints = not args.no_hints
         ensure_build_directory(args, ctx.info_name)
         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)
 
     def list_build_system_targets(target_name: str, ctx: Context, args: PropertyDict) -> None:

+ 1 - 1
tools/idf_py_actions/serial_ext.py

@@ -175,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']
-        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:
         encryption = any([task.name in ('encrypted-flash', 'encrypted-app-flash') for task in tasks])

+ 4 - 4
tools/idf_py_actions/tools.py

@@ -117,7 +117,7 @@ def fit_text_in_terminal(out: str) -> str:
 
 class RunTool:
     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.args = args
         self.cwd = cwd
@@ -234,12 +234,12 @@ class RunTool:
 
 
 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)()
 
 
 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."""
     if env is None:
         env = {}
@@ -250,7 +250,7 @@ def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None,
     if args.verbose:
         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)()