1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-22 19:53:46 +01:00
This commit is contained in:
J. Nick Koston
2025-10-17 13:43:05 -10:00
parent 9d081795e8
commit 6d2c700c43

View File

@@ -1,6 +1,7 @@
"""Memory usage analyzer for ESPHome compiled binaries."""
from collections import defaultdict
from functools import cache
import json
import logging
from pathlib import Path
@@ -13,6 +14,7 @@ _LOGGER = logging.getLogger(__name__)
# Get the list of actual ESPHome components by scanning the components directory
@cache
def get_esphome_components():
"""Get set of actual ESPHome components from the components directory."""
components = set()
@@ -34,10 +36,6 @@ def get_esphome_components():
return components
# Cache the component list
ESPHOME_COMPONENTS = get_esphome_components()
class MemorySection:
"""Represents a memory section with its symbols."""
@@ -285,7 +283,7 @@ class MemoryAnalyzer:
if "esphome::" in demangled:
# Check for special component classes that include component name in the class
# For example: esphome::ESPHomeOTAComponent -> ota component
for component_name in ESPHOME_COMPONENTS:
for component_name in get_esphome_components():
# Check various naming patterns
component_upper = component_name.upper()
component_camel = component_name.replace("_", "").title()
@@ -307,7 +305,7 @@ class MemoryAnalyzer:
component_name = component_name.rstrip("_")
# Check if this is an actual component in the components directory
if component_name in ESPHOME_COMPONENTS:
if component_name in get_esphome_components():
return f"[esphome]{component_name}"
# Check if this is a known external component from the config
if component_name in self.external_components: