mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	[core] Dont copy platform source files if there are no entities of that type (#10436)
This commit is contained in:
		| @@ -1,6 +1,7 @@ | |||||||
| from __future__ import annotations | from __future__ import annotations | ||||||
|  |  | ||||||
| import abc | import abc | ||||||
|  | from collections import defaultdict | ||||||
| from contextlib import contextmanager | from contextlib import contextmanager | ||||||
| import contextvars | import contextvars | ||||||
| import functools | import functools | ||||||
| @@ -37,11 +38,13 @@ from esphome.yaml_util import ESPForceValue, ESPHomeDataBase, is_secret | |||||||
| _LOGGER = logging.getLogger(__name__) | _LOGGER = logging.getLogger(__name__) | ||||||
|  |  | ||||||
|  |  | ||||||
| def iter_components(config): | def iter_components(config: ConfigType, platform_counts: defaultdict[str, int]): | ||||||
|     for domain, conf in config.items(): |     for domain, conf in config.items(): | ||||||
|         component = get_component(domain) |         component = get_component(domain) | ||||||
|         yield domain, component |         yield domain, component | ||||||
|         if component.is_platform_component: |         if component.is_platform_component: | ||||||
|  |             if not platform_counts[domain]: | ||||||
|  |                 continue | ||||||
|             for p_config in conf: |             for p_config in conf: | ||||||
|                 p_name = f"{domain}.{p_config[CONF_PLATFORM]}" |                 p_name = f"{domain}.{p_config[CONF_PLATFORM]}" | ||||||
|                 platform = get_platform(domain, p_config[CONF_PLATFORM]) |                 platform = get_platform(domain, p_config[CONF_PLATFORM]) | ||||||
|   | |||||||
| @@ -181,7 +181,7 @@ the custom_components folder or the external_components feature. | |||||||
|  |  | ||||||
| def copy_src_tree(): | def copy_src_tree(): | ||||||
|     source_files: list[loader.FileResource] = [] |     source_files: list[loader.FileResource] = [] | ||||||
|     for _, component in iter_components(CORE.config): |     for _, component in iter_components(CORE.config, CORE.platform_counts): | ||||||
|         source_files += component.resources |         source_files += component.resources | ||||||
|     source_files_map = { |     source_files_map = { | ||||||
|         Path(x.package.replace(".", "/") + "/" + x.resource): x for x in source_files |         Path(x.package.replace(".", "/") + "/" + x.resource): x for x in source_files | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user