[esp32] Make ESP-IDF the default toolchain (#16910)

This commit is contained in:
Jonathan Swoboda
2026-06-17 21:45:30 -04:00
committed by GitHub
parent c214a8ce79
commit ac6a0f34ec
3 changed files with 34 additions and 1 deletions

View File

@@ -964,7 +964,7 @@ def _resolve_toolchain(value: ConfigType) -> ConfigType:
# Runs before _detect_variant so downstream validators can rely on
# CORE.toolchain instead of re-resolving it from the config dict.
if CORE.toolchain is None:
CORE.toolchain = value.get(CONF_TOOLCHAIN, Toolchain.PLATFORMIO)
CORE.toolchain = value.get(CONF_TOOLCHAIN, Toolchain.ESP_IDF)
return value

View File

@@ -5,5 +5,6 @@ esp32:
board: esp32dev
flash_mode: qio
flash_frequency: 80MHz
toolchain: platformio
framework:
type: esp-idf

View File

@@ -64,6 +64,38 @@ def test_esp32_config(
assert VARIANT_FRIENDLY[variant].lower() in config["board"]
@pytest.mark.parametrize(
("config_toolchain", "expected"),
[
# No `toolchain:` set -> the new default for esp32.
(None, Toolchain.ESP_IDF),
# An explicit `toolchain:` still wins over the default.
(Toolchain.PLATFORMIO.value, Toolchain.PLATFORMIO),
(Toolchain.ESP_IDF.value, Toolchain.ESP_IDF),
],
)
def test_esp32_default_toolchain_is_esp_idf(
set_core_config: SetCoreConfigCallable,
config_toolchain: str | None,
expected: Toolchain,
) -> None:
"""With no `toolchain:` set (and nothing pinned via the CLI), esp32 resolves
to the ESP-IDF toolchain; an explicit `toolchain:` still wins."""
set_core_config(PlatformFramework.ESP32_IDF)
from esphome.components.esp32 import CONFIG_SCHEMA
# Fresh run: no --toolchain CLI and no prior config pinned CORE.toolchain.
CORE.toolchain = None
config: dict[str, Any] = {"variant": VARIANT_ESP32}
if config_toolchain is not None:
config["toolchain"] = config_toolchain
CONFIG_SCHEMA(config)
assert CORE.toolchain == expected
@pytest.mark.parametrize(
("config", "error_match"),
[