Compare commits

..

2 Commits

Author SHA1 Message Date
J. Nick Koston
e351c65c93 [core] Fix platform subcomponents not filtering source files 2026-01-14 07:30:56 -10:00
J. Nick Koston
ea4e714f62 [core] Fix platform subcomponents not filtering source files 2026-01-14 07:24:54 -10:00
8 changed files with 25 additions and 77 deletions

View File

@@ -9,44 +9,10 @@ ESPHOME_COMPONENT_PATTERN = re.compile(r"esphome::([a-zA-Z0-9_]+)::")
# Maps standard section names to their various platform-specific variants
# Note: Order matters! More specific patterns (.bss) must come before general ones (.dram)
# because ESP-IDF uses names like ".dram0.bss" which would match ".dram" otherwise
#
# Platform-specific sections:
# - ESP8266/ESP32: .iram*, .dram*
# - LibreTiny RTL87xx: .xip.code_* (flash), .ram.code_* (RAM)
# - LibreTiny BK7231: .itcm.code (fast RAM), .vectors (interrupt vectors)
# - LibreTiny LN882X: .flash_text, .flash_copy* (flash code)
SECTION_MAPPING = {
".text": frozenset(
[
".text",
".iram",
# LibreTiny RTL87xx XIP (eXecute In Place) flash code
".xip.code",
# LibreTiny RTL87xx RAM code
".ram.code_text",
# LibreTiny BK7231 fast RAM code and vectors
".itcm.code",
".vectors",
# LibreTiny LN882X flash code
".flash_text",
".flash_copy",
]
),
".rodata": frozenset(
[
".rodata",
# LibreTiny RTL87xx read-only data in RAM
".ram.code_rodata",
]
),
# .bss patterns - must be before .data to catch ".dram0.bss"
".bss": frozenset(
[
".bss",
# LibreTiny LN882X BSS
".bss_ram",
]
),
".text": frozenset([".text", ".iram"]),
".rodata": frozenset([".rodata"]),
".bss": frozenset([".bss"]), # Must be before .data to catch ".dram0.bss"
".data": frozenset([".data", ".dram"]),
}

View File

@@ -17,7 +17,11 @@ from esphome.const import (
UNIT_PERCENT,
)
from . import CONF_DEBUG_ID, DebugComponent
from . import ( # noqa: F401 pylint: disable=unused-import
CONF_DEBUG_ID,
FILTER_SOURCE_FILES,
DebugComponent,
)
DEPENDENCIES = ["debug"]

View File

@@ -8,7 +8,11 @@ from esphome.const import (
ICON_RESTART,
)
from . import CONF_DEBUG_ID, DebugComponent
from . import ( # noqa: F401 pylint: disable=unused-import
CONF_DEBUG_ID,
FILTER_SOURCE_FILES,
DebugComponent,
)
DEPENDENCIES = ["debug"]

View File

@@ -11,7 +11,12 @@ from esphome.const import (
)
from esphome.core import CORE, TimePeriod
from . import Nextion, nextion_ns, nextion_ref
from . import ( # noqa: F401 pylint: disable=unused-import
FILTER_SOURCE_FILES,
Nextion,
nextion_ns,
nextion_ref,
)
from .base_component import (
CONF_AUTO_WAKE_ON_TOUCH,
CONF_COMMAND_SPACING,

View File

@@ -1,5 +1,7 @@
from esphome.components import binary_sensor, remote_base
from . import FILTER_SOURCE_FILES # noqa: F401 pylint: disable=unused-import
DEPENDENCIES = ["remote_receiver"]
CONFIG_SCHEMA = remote_base.validate_binary_sensor

View File

@@ -19,7 +19,7 @@ ruamel.yaml==0.19.1 # dashboard_import
ruamel.yaml.clib==0.2.15 # dashboard_import
esphome-glyphsets==0.2.0
pillow==11.3.0
resvg-py==0.2.6
resvg-py==0.2.5
freetype-py==2.5.1
jinja2==3.1.6
bleak==2.1.1

View File

@@ -90,8 +90,6 @@ class Platform(StrEnum):
ESP32_S2_IDF = "esp32-s2-idf"
ESP32_S3_IDF = "esp32-s3-idf"
BK72XX_ARD = "bk72xx-ard" # LibreTiny BK7231N
RTL87XX_ARD = "rtl87xx-ard" # LibreTiny RTL8720x
LN882X_ARD = "ln882x-ard" # LibreTiny LN882x
RP2040_ARD = "rp2040-ard" # Raspberry Pi Pico
@@ -124,8 +122,8 @@ PLATFORM_SPECIFIC_COMPONENTS = frozenset(
# fastest build times, most sensitive to code size changes
# 3. ESP32 IDF - Primary ESP32 platform, most representative of modern ESPHome
# 4-6. Other ESP32 variants - Less commonly used but still supported
# 7-9. LibreTiny platforms (BK72XX, RTL87XX, LN882X) - good for detecting LibreTiny-specific changes
# 10. RP2040 - Raspberry Pi Pico platform
# 7. BK72XX - LibreTiny platform (good for detecting LibreTiny-specific changes)
# 8. RP2040 - Raspberry Pi Pico platform
MEMORY_IMPACT_PLATFORM_PREFERENCE = [
Platform.ESP32_C6_IDF, # ESP32-C6 IDF (newest, supports Thread/Zigbee)
Platform.ESP8266_ARD, # ESP8266 Arduino (most memory constrained, fastest builds)
@@ -134,8 +132,6 @@ MEMORY_IMPACT_PLATFORM_PREFERENCE = [
Platform.ESP32_S2_IDF, # ESP32-S2 IDF
Platform.ESP32_S3_IDF, # ESP32-S3 IDF
Platform.BK72XX_ARD, # LibreTiny BK7231N
Platform.RTL87XX_ARD, # LibreTiny RTL8720x
Platform.LN882X_ARD, # LibreTiny LN882x
Platform.RP2040_ARD, # Raspberry Pi Pico
]
@@ -415,8 +411,6 @@ def _detect_platform_hint_from_filename(filename: str) -> Platform | None:
- wifi_component_esp8266.cpp, *_esp8266.h -> ESP8266_ARD
- *_esp32*.cpp -> ESP32 IDF (generic)
- *_libretiny.cpp, *_bk72*.* -> BK72XX (LibreTiny)
- *_rtl87*.* -> RTL87XX (LibreTiny Realtek)
- *_ln882*.* -> LN882X (LibreTiny Lightning)
- *_pico.cpp, *_rp2040.* -> RP2040_ARD
Args:
@@ -450,12 +444,7 @@ def _detect_platform_hint_from_filename(filename: str) -> Platform | None:
if "esp32" in filename_lower:
return Platform.ESP32_IDF
# LibreTiny platforms (check specific variants before generic libretiny)
# Check specific variants first to handle paths like libretiny/wifi_rtl87xx.cpp
if "rtl87" in filename_lower:
return Platform.RTL87XX_ARD
if "ln882" in filename_lower:
return Platform.LN882X_ARD
# LibreTiny (via 'libretiny' pattern or BK72xx-specific files)
if "libretiny" in filename_lower or "bk72" in filename_lower:
return Platform.BK72XX_ARD

View File

@@ -1472,24 +1472,6 @@ def test_detect_memory_impact_config_runs_at_component_limit(tmp_path: Path) ->
determine_jobs.Platform.BK72XX_ARD,
),
("esphome/components/ble/ble_bk72xx.cpp", determine_jobs.Platform.BK72XX_ARD),
# RTL87xx (LibreTiny Realtek) detection
(
"tests/components/logger/test.rtl87xx-ard.yaml",
determine_jobs.Platform.RTL87XX_ARD,
),
(
"esphome/components/libretiny/wifi_rtl87xx.cpp",
determine_jobs.Platform.RTL87XX_ARD,
),
# LN882x (LibreTiny Lightning) detection
(
"tests/components/logger/test.ln882x-ard.yaml",
determine_jobs.Platform.LN882X_ARD,
),
(
"esphome/components/libretiny/wifi_ln882x.cpp",
determine_jobs.Platform.LN882X_ARD,
),
# RP2040 / Raspberry Pi Pico detection
("esphome/components/gpio/gpio_rp2040.cpp", determine_jobs.Platform.RP2040_ARD),
("esphome/components/wifi/wifi_rp2040.cpp", determine_jobs.Platform.RP2040_ARD),
@@ -1519,10 +1501,6 @@ def test_detect_memory_impact_config_runs_at_component_limit(tmp_path: Path) ->
"esp32_in_name",
"libretiny",
"bk72xx",
"rtl87xx_test_yaml",
"rtl87xx_wifi",
"ln882x_test_yaml",
"ln882x_wifi",
"rp2040_gpio",
"rp2040_wifi",
"pico_i2c",