Skip to content

Commit 5b7b8ff

Browse files
authored
refactor check tools install
1 parent f98b05d commit 5b7b8ff

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

platform.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def install_tool(TOOL):
115115
if mcu == "esp32c2":
116116
self.packages["framework-arduino-c2-skeleton-lib"]["optional"] = False
117117

118-
mcu_toolchain_mapping = {
118+
MCU_TOOLCHAIN_MAPPING = {
119119
# Xtensa based and FSM toolchain
120120
("esp32", "esp32s2", "esp32s3"): {
121121
"toolchains": ["toolchain-xtensa-esp-elf"],
@@ -129,9 +129,8 @@ def install_tool(TOOL):
129129
"debug_tools": ["tool-riscv32-esp-elf-gdb"]
130130
}
131131
}
132-
133132
# Iterate through MCU mappings
134-
for supported_mcus, toolchain_data in mcu_toolchain_mapping.items():
133+
for supported_mcus, toolchain_data in MCU_TOOLCHAIN_MAPPING.items():
135134
if mcu in supported_mcus:
136135
# Set mandatory toolchains
137136
for toolchain in toolchain_data["toolchains"]:
@@ -160,10 +159,17 @@ def install_tool(TOOL):
160159
for package in COMMON_IDF_PACKAGES:
161160
self.packages[package]["optional"] = False
162161

163-
# Enable check tools only when "check_tool" is active
164-
for p in self.packages:
165-
if p in ("tool-cppcheck", "tool-clangtidy", "tool-pvs-studio"):
166-
self.packages[p]["optional"] = False if str(variables.get("check_tool")).strip("['']") in p else True
162+
CHECK_PACKAGES = [
163+
"tool-cppcheck",
164+
"tool-clangtidy",
165+
"tool-pvs-studio"
166+
]
167+
# Install check tool listed in pio entry "check_tool"
168+
if variables.get("check_tool") is not None:
169+
for package in CHECK_PACKAGES:
170+
for check_tool in variables.get("check_tool", ""):
171+
if check_tool in package:
172+
self.packages[package]["optional"] = False
167173

168174
if "buildfs" in targets:
169175
filesystem = variables.get("board_build.filesystem", "littlefs")
@@ -226,7 +232,6 @@ def _add_dynamic_options(self, board):
226232
# A special case for the Kaluga board that has a separate interface config
227233
if board.id == "esp32-s2-kaluga-1":
228234
supported_debug_tools.append("ftdi")
229-
230235
if board.get("build.mcu", "") in ("esp32c3", "esp32c5", "esp32c6", "esp32s3", "esp32h2", "esp32p4"):
231236
supported_debug_tools.append("esp-builtin")
232237

0 commit comments

Comments
 (0)