33# See LICENSE for details
44#
55
6+ from __future__ import annotations
7+
68import os
79import re
810import shutil
911import sys
12+ from typing import TYPE_CHECKING
1013
1114from invoke import Collection , task
1215
1316from .gdb import gdb_build_cmd
1417
18+ if TYPE_CHECKING :
19+ from tasks .lib .invoke_utils import Context
20+
1521TASKS_DIR = os .path .dirname (__file__ )
1622MEMFAULT_SDK_ROOT = os .path .join (TASKS_DIR , ".." )
1723ESP32_PLATFORM_ROOT = os .path .join (MEMFAULT_SDK_ROOT , "examples" , "esp32" )
2531OPENOCD_GDB_PORT_DEFAULT = 3333
2632
2733
28- def _run_idf_script (ctx , * args , ** kwargs ) :
34+ def _run_idf_script (ctx : "Context" , * args : str , ** kwargs : object ) -> None :
2935 # allow selecting a specific python interpreter instead of the active one.
3036 # this is necessary in CI, because the mbed build task modifies the python
3137 # environment 😖, and idf.py runs a pkg_resources.require() which fails if
@@ -52,7 +58,7 @@ def _run_idf_script(ctx, *args, **kwargs):
5258
5359
5460@task
55- def run_xtensa_toolchain_check (ctx ) :
61+ def run_xtensa_toolchain_check (ctx : "Context" ) -> None :
5662 if sys .version_info .major < 3 :
5763 # shutil which is only available for python3
5864 return
@@ -70,19 +76,19 @@ def run_xtensa_toolchain_check(ctx):
7076
7177
7278@task (pre = [run_xtensa_toolchain_check ])
73- def esp32_app_build (ctx ) :
79+ def esp32_app_build (ctx : "Context" ) -> None :
7480 """Build the ESP32 test app"""
7581 _run_idf_script (ctx , "build" )
7682
7783
7884@task
79- def esp32_app_clean (ctx ) :
85+ def esp32_app_clean (ctx : "Context" ) -> None :
8086 """Clean the ESP32 test app"""
8187 _run_idf_script (ctx , "fullclean" )
8288
8389
8490@task (pre = [run_xtensa_toolchain_check ])
85- def esp32s2_app_build (ctx ) :
91+ def esp32s2_app_build (ctx : "Context" ) -> None :
8692 """Build the ESP32-S2 test app"""
8793 # !NOTE! 'set-target' was added in ESP-IDF v4.1. If you are using an older
8894 # version of ESP-IDF, building for the ESP32-S2 + ESP32-S3 won't work.
@@ -91,32 +97,32 @@ def esp32s2_app_build(ctx):
9197
9298
9399@task (pre = [run_xtensa_toolchain_check ])
94- def esp32s3_app_build (ctx ) :
100+ def esp32s3_app_build (ctx : "Context" ) -> None :
95101 """Build the ESP32-S3 test app"""
96102 _run_idf_script (ctx , "set-target esp32s3" )
97103 _run_idf_script (ctx , "build" )
98104
99105
100106@task
101- def esp32_app_flash (ctx ) :
107+ def esp32_app_flash (ctx : "Context" ) -> None :
102108 """Flash the ESP32 test app"""
103109 _run_idf_script (ctx , "flash" )
104110
105111
106112@task
107- def esp32_console (ctx ) :
113+ def esp32_console (ctx : "Context" ) -> None :
108114 """Flash the ESP32 test app"""
109115 _run_idf_script (ctx , "monitor" )
110116
111117
112118@task
113- def esp32_app_menuconfig (ctx ) :
119+ def esp32_app_menuconfig (ctx : "Context" ) -> None :
114120 """Run menuconfig for the ESP32 test app"""
115121 _run_idf_script (ctx , "menuconfig" , pty = True )
116122
117123
118124@task
119- def esp32_openocd (ctx ) :
125+ def esp32_openocd (ctx : "Context" ) -> None :
120126 """Launch openocd"""
121127 if "ESP32_OPENOCD" not in os .environ :
122128 print ("Set ESP32_OPENOCD environment variable to point to openocd-esp32 root directory!" )
@@ -134,7 +140,7 @@ def esp32_openocd(ctx):
134140
135141
136142@task
137- def esp32_app_gdb (ctx , gdb = None , reset = False ):
143+ def esp32_app_gdb (ctx : "Context" , gdb : int | None = None , reset : bool = False ) -> None :
138144 """Launches xtensa-gdb with app elf and connects to openocd gdb server"""
139145 if gdb is None :
140146 gdb = OPENOCD_GDB_PORT_DEFAULT
@@ -146,7 +152,9 @@ def esp32_app_gdb(ctx, gdb=None, reset=False):
146152
147153
148154@task
149- def esp32_decode_backtrace (ctx , backtrace_str , symbol_file , verbose = False ):
155+ def esp32_decode_backtrace (
156+ ctx : "Context" , backtrace_str : str , symbol_file : str , verbose : bool = False
157+ ) -> None :
150158 """Decode a backtrace emitted by ESP-IDF panic handling
151159
152160 The backtrace_str should be passed as a string of separated address pairs
0 commit comments