1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-17 02:32:20 +01:00

[core] Trigger clean build when components are removed from configuration (#10235)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
J. Nick Koston
2025-08-14 17:50:03 -05:00
committed by GitHub
parent 4f29b3c7aa
commit 8ea1a3ed64
2 changed files with 234 additions and 4 deletions

View File

@@ -80,13 +80,16 @@ def replace_file_content(text, pattern, repl):
return content_new, count
def storage_should_clean(old: StorageJSON, new: StorageJSON) -> bool:
def storage_should_clean(old: StorageJSON | None, new: StorageJSON) -> bool:
if old is None:
return True
if old.src_version != new.src_version:
return True
return old.build_path != new.build_path
if old.build_path != new.build_path:
return True
# Check if any components have been removed
return bool(old.loaded_integrations - new.loaded_integrations)
def storage_should_update_cmake_cache(old: StorageJSON, new: StorageJSON) -> bool:
@@ -100,7 +103,7 @@ def storage_should_update_cmake_cache(old: StorageJSON, new: StorageJSON) -> boo
return False
def update_storage_json():
def update_storage_json() -> None:
path = storage_path()
old = StorageJSON.load(path)
new = StorageJSON.from_esphome_core(CORE, old)
@@ -108,7 +111,14 @@ def update_storage_json():
return
if storage_should_clean(old, new):
_LOGGER.info("Core config, version changed, cleaning build files...")
if old is not None and old.loaded_integrations - new.loaded_integrations:
removed = old.loaded_integrations - new.loaded_integrations
_LOGGER.info(
"Components removed (%s), cleaning build files...",
", ".join(sorted(removed)),
)
else:
_LOGGER.info("Core config or version changed, cleaning build files...")
clean_build()
elif storage_should_update_cmake_cache(old, new):
_LOGGER.info("Integrations changed, cleaning cmake cache...")