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:
@@ -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...")
|
||||
|
Reference in New Issue
Block a user