mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	[config] Clean build on ESP-IDF when component/platform combos change (#9028)
This commit is contained in:
		| @@ -389,6 +389,7 @@ class LoadValidationStep(ConfigValidationStep): | ||||
|                 result.add_str_error(f"Platform not found: '{p_domain}'", path) | ||||
|                 continue | ||||
|             CORE.loaded_integrations.add(p_name) | ||||
|             CORE.loaded_platforms.add(f"{self.domain}/{p_name}") | ||||
|  | ||||
|             # Process AUTO_LOAD | ||||
|             for load in platform.auto_load: | ||||
|   | ||||
| @@ -512,6 +512,8 @@ class EsphomeCore: | ||||
|         self.platformio_options: dict[str, str | list[str]] = {} | ||||
|         # A set of strings of names of loaded integrations, used to find namespace ID conflicts | ||||
|         self.loaded_integrations = set() | ||||
|         # A set of strings for platform/integration combos | ||||
|         self.loaded_platforms: set[str] = set() | ||||
|         # A set of component IDs to track what Component subclasses are declared | ||||
|         self.component_ids = set() | ||||
|         # Whether ESPHome was started in verbose mode | ||||
|   | ||||
| @@ -46,15 +46,16 @@ class StorageJSON: | ||||
|         storage_version: int, | ||||
|         name: str, | ||||
|         friendly_name: str, | ||||
|         comment: str, | ||||
|         esphome_version: str, | ||||
|         comment: str | None, | ||||
|         esphome_version: str | None, | ||||
|         src_version: int | None, | ||||
|         address: str, | ||||
|         web_port: int | None, | ||||
|         target_platform: str, | ||||
|         build_path: str, | ||||
|         firmware_bin_path: str, | ||||
|         build_path: str | None, | ||||
|         firmware_bin_path: str | None, | ||||
|         loaded_integrations: set[str], | ||||
|         loaded_platforms: set[str], | ||||
|         no_mdns: bool, | ||||
|         framework: str | None = None, | ||||
|         core_platform: str | None = None, | ||||
| @@ -86,6 +87,8 @@ class StorageJSON: | ||||
|         self.firmware_bin_path = firmware_bin_path | ||||
|         # A set of strings of names of loaded integrations | ||||
|         self.loaded_integrations = loaded_integrations | ||||
|         # A set of strings for platform/integration combos | ||||
|         self.loaded_platforms = loaded_platforms | ||||
|         # Is mDNS disabled | ||||
|         self.no_mdns = no_mdns | ||||
|         # The framework used to compile the firmware | ||||
| @@ -107,6 +110,7 @@ class StorageJSON: | ||||
|             "build_path": self.build_path, | ||||
|             "firmware_bin_path": self.firmware_bin_path, | ||||
|             "loaded_integrations": sorted(self.loaded_integrations), | ||||
|             "loaded_platforms": sorted(self.loaded_platforms), | ||||
|             "no_mdns": self.no_mdns, | ||||
|             "framework": self.framework, | ||||
|             "core_platform": self.core_platform, | ||||
| @@ -138,6 +142,7 @@ class StorageJSON: | ||||
|             build_path=esph.build_path, | ||||
|             firmware_bin_path=esph.firmware_bin, | ||||
|             loaded_integrations=esph.loaded_integrations, | ||||
|             loaded_platforms=esph.loaded_platforms, | ||||
|             no_mdns=( | ||||
|                 CONF_MDNS in esph.config | ||||
|                 and CONF_DISABLED in esph.config[CONF_MDNS] | ||||
| @@ -164,6 +169,7 @@ class StorageJSON: | ||||
|             build_path=None, | ||||
|             firmware_bin_path=None, | ||||
|             loaded_integrations=set(), | ||||
|             loaded_platforms=set(), | ||||
|             no_mdns=False, | ||||
|             framework=None, | ||||
|             core_platform=platform.lower(), | ||||
| @@ -187,6 +193,7 @@ class StorageJSON: | ||||
|         build_path = storage.get("build_path") | ||||
|         firmware_bin_path = storage.get("firmware_bin_path") | ||||
|         loaded_integrations = set(storage.get("loaded_integrations", [])) | ||||
|         loaded_platforms = set(storage.get("loaded_platforms", [])) | ||||
|         no_mdns = storage.get("no_mdns", False) | ||||
|         framework = storage.get("framework") | ||||
|         core_platform = storage.get("core_platform") | ||||
| @@ -203,6 +210,7 @@ class StorageJSON: | ||||
|             build_path, | ||||
|             firmware_bin_path, | ||||
|             loaded_integrations, | ||||
|             loaded_platforms, | ||||
|             no_mdns, | ||||
|             framework, | ||||
|             core_platform, | ||||
| @@ -252,7 +260,7 @@ class EsphomeStorageJSON: | ||||
|     def last_update_check(self, new: datetime) -> None: | ||||
|         self.last_update_check_str = new.strftime("%Y-%m-%dT%H:%M:%S") | ||||
|  | ||||
|     def to_json(self) -> dict: | ||||
|     def to_json(self) -> str: | ||||
|         return f"{json.dumps(self.as_dict(), indent=2)}\n" | ||||
|  | ||||
|     def save(self, path: str) -> None: | ||||
|   | ||||
| @@ -107,7 +107,10 @@ def storage_should_clean(old: StorageJSON, new: StorageJSON) -> bool: | ||||
|         return True | ||||
|     if old.build_path != new.build_path: | ||||
|         return True | ||||
|     if old.loaded_integrations != new.loaded_integrations: | ||||
|     if ( | ||||
|         old.loaded_integrations != new.loaded_integrations | ||||
|         or old.loaded_platforms != new.loaded_platforms | ||||
|     ): | ||||
|         if new.core_platform == PLATFORM_ESP32: | ||||
|             from esphome.components.esp32 import FRAMEWORK_ESP_IDF | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user