mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 12:33:10 +00:00
[esp32] Make ESP-IDF the default toolchain (#16910)
This commit is contained in:
@@ -964,7 +964,7 @@ def _resolve_toolchain(value: ConfigType) -> ConfigType:
|
|||||||
# Runs before _detect_variant so downstream validators can rely on
|
# Runs before _detect_variant so downstream validators can rely on
|
||||||
# CORE.toolchain instead of re-resolving it from the config dict.
|
# CORE.toolchain instead of re-resolving it from the config dict.
|
||||||
if CORE.toolchain is None:
|
if CORE.toolchain is None:
|
||||||
CORE.toolchain = value.get(CONF_TOOLCHAIN, Toolchain.PLATFORMIO)
|
CORE.toolchain = value.get(CONF_TOOLCHAIN, Toolchain.ESP_IDF)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ esp32:
|
|||||||
board: esp32dev
|
board: esp32dev
|
||||||
flash_mode: qio
|
flash_mode: qio
|
||||||
flash_frequency: 80MHz
|
flash_frequency: 80MHz
|
||||||
|
toolchain: platformio
|
||||||
framework:
|
framework:
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|||||||
@@ -64,6 +64,38 @@ def test_esp32_config(
|
|||||||
assert VARIANT_FRIENDLY[variant].lower() in config["board"]
|
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(
|
@pytest.mark.parametrize(
|
||||||
("config", "error_match"),
|
("config", "error_match"),
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user