3
3
# See LICENSE for details
4
4
#
5
5
6
+ from __future__ import annotations
7
+
6
8
import os
7
9
import re
8
10
import shutil
9
11
import sys
12
+ from typing import TYPE_CHECKING
10
13
11
14
from invoke import Collection , task
12
15
13
16
from .gdb import gdb_build_cmd
14
17
18
+ if TYPE_CHECKING :
19
+ from tasks .lib .invoke_utils import Context
20
+
15
21
TASKS_DIR = os .path .dirname (__file__ )
16
22
MEMFAULT_SDK_ROOT = os .path .join (TASKS_DIR , ".." )
17
23
ESP32_PLATFORM_ROOT = os .path .join (MEMFAULT_SDK_ROOT , "examples" , "esp32" )
25
31
OPENOCD_GDB_PORT_DEFAULT = 3333
26
32
27
33
28
- def _run_idf_script (ctx , * args , ** kwargs ) :
34
+ def _run_idf_script (ctx : "Context" , * args : str , ** kwargs : object ) -> None :
29
35
# allow selecting a specific python interpreter instead of the active one.
30
36
# this is necessary in CI, because the mbed build task modifies the python
31
37
# environment 😖, and idf.py runs a pkg_resources.require() which fails if
@@ -52,7 +58,7 @@ def _run_idf_script(ctx, *args, **kwargs):
52
58
53
59
54
60
@task
55
- def run_xtensa_toolchain_check (ctx ) :
61
+ def run_xtensa_toolchain_check (ctx : "Context" ) -> None :
56
62
if sys .version_info .major < 3 :
57
63
# shutil which is only available for python3
58
64
return
@@ -70,19 +76,19 @@ def run_xtensa_toolchain_check(ctx):
70
76
71
77
72
78
@task (pre = [run_xtensa_toolchain_check ])
73
- def esp32_app_build (ctx ) :
79
+ def esp32_app_build (ctx : "Context" ) -> None :
74
80
"""Build the ESP32 test app"""
75
81
_run_idf_script (ctx , "build" )
76
82
77
83
78
84
@task
79
- def esp32_app_clean (ctx ) :
85
+ def esp32_app_clean (ctx : "Context" ) -> None :
80
86
"""Clean the ESP32 test app"""
81
87
_run_idf_script (ctx , "fullclean" )
82
88
83
89
84
90
@task (pre = [run_xtensa_toolchain_check ])
85
- def esp32s2_app_build (ctx ) :
91
+ def esp32s2_app_build (ctx : "Context" ) -> None :
86
92
"""Build the ESP32-S2 test app"""
87
93
# !NOTE! 'set-target' was added in ESP-IDF v4.1. If you are using an older
88
94
# version of ESP-IDF, building for the ESP32-S2 + ESP32-S3 won't work.
@@ -91,32 +97,32 @@ def esp32s2_app_build(ctx):
91
97
92
98
93
99
@task (pre = [run_xtensa_toolchain_check ])
94
- def esp32s3_app_build (ctx ) :
100
+ def esp32s3_app_build (ctx : "Context" ) -> None :
95
101
"""Build the ESP32-S3 test app"""
96
102
_run_idf_script (ctx , "set-target esp32s3" )
97
103
_run_idf_script (ctx , "build" )
98
104
99
105
100
106
@task
101
- def esp32_app_flash (ctx ) :
107
+ def esp32_app_flash (ctx : "Context" ) -> None :
102
108
"""Flash the ESP32 test app"""
103
109
_run_idf_script (ctx , "flash" )
104
110
105
111
106
112
@task
107
- def esp32_console (ctx ) :
113
+ def esp32_console (ctx : "Context" ) -> None :
108
114
"""Flash the ESP32 test app"""
109
115
_run_idf_script (ctx , "monitor" )
110
116
111
117
112
118
@task
113
- def esp32_app_menuconfig (ctx ) :
119
+ def esp32_app_menuconfig (ctx : "Context" ) -> None :
114
120
"""Run menuconfig for the ESP32 test app"""
115
121
_run_idf_script (ctx , "menuconfig" , pty = True )
116
122
117
123
118
124
@task
119
- def esp32_openocd (ctx ) :
125
+ def esp32_openocd (ctx : "Context" ) -> None :
120
126
"""Launch openocd"""
121
127
if "ESP32_OPENOCD" not in os .environ :
122
128
print ("Set ESP32_OPENOCD environment variable to point to openocd-esp32 root directory!" )
@@ -134,7 +140,7 @@ def esp32_openocd(ctx):
134
140
135
141
136
142
@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 :
138
144
"""Launches xtensa-gdb with app elf and connects to openocd gdb server"""
139
145
if gdb is None :
140
146
gdb = OPENOCD_GDB_PORT_DEFAULT
@@ -146,7 +152,9 @@ def esp32_app_gdb(ctx, gdb=None, reset=False):
146
152
147
153
148
154
@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 :
150
158
"""Decode a backtrace emitted by ESP-IDF panic handling
151
159
152
160
The backtrace_str should be passed as a string of separated address pairs
0 commit comments