mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Allow platform dependencies (#6623)
This commit is contained in:
parent
a700ae481d
commit
8334934e08
2 changed files with 31 additions and 5 deletions
|
@ -374,7 +374,10 @@ class LoadValidationStep(ConfigValidationStep):
|
||||||
path + [CONF_ID],
|
path + [CONF_ID],
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
result.add_str_error("No platform specified! See 'platform' key.", path)
|
result.add_str_error(
|
||||||
|
f"'{self.domain}' requires a 'platform' key but it was not specified.",
|
||||||
|
path,
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
# Remove temp output path and construct new one
|
# Remove temp output path and construct new one
|
||||||
result.remove_output_path(path, p_domain)
|
result.remove_output_path(path, p_domain)
|
||||||
|
@ -449,9 +452,28 @@ class MetadataValidationStep(ConfigValidationStep):
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
for dependency in self.comp.dependencies:
|
for dependency in self.comp.dependencies:
|
||||||
if dependency not in result:
|
dependency_parts = dependency.split(".")
|
||||||
|
if len(dependency_parts) > 2:
|
||||||
result.add_str_error(
|
result.add_str_error(
|
||||||
f"Component {self.domain} requires component {dependency}",
|
"Dependencies must be specified as a single component or in component.platform format only",
|
||||||
|
self.path,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
component_dep = dependency_parts[0]
|
||||||
|
platform_dep = dependency_parts[-1]
|
||||||
|
if component_dep not in result:
|
||||||
|
result.add_str_error(
|
||||||
|
f"Component {self.domain} requires component {component_dep}",
|
||||||
|
self.path,
|
||||||
|
)
|
||||||
|
success = False
|
||||||
|
elif component_dep != platform_dep and (
|
||||||
|
not isinstance(platform_list := result.get(component_dep), list)
|
||||||
|
or not any(CONF_PLATFORM in p for p in platform_list)
|
||||||
|
or not any(p[CONF_PLATFORM] == platform_dep for p in platform_list)
|
||||||
|
):
|
||||||
|
result.add_str_error(
|
||||||
|
f"Component {self.domain} requires 'platform: {platform_dep}' in component '{component_dep}'",
|
||||||
self.path,
|
self.path,
|
||||||
)
|
)
|
||||||
success = False
|
success = False
|
||||||
|
|
|
@ -69,7 +69,9 @@ def create_components_graph():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for dependency in comp.dependencies:
|
for dependency in comp.dependencies:
|
||||||
add_item_to_components_graph(components_graph, dependency, name)
|
add_item_to_components_graph(
|
||||||
|
components_graph, dependency.split(".")[0], name
|
||||||
|
)
|
||||||
|
|
||||||
for target_config in TARGET_CONFIGURATIONS:
|
for target_config in TARGET_CONFIGURATIONS:
|
||||||
CORE.data[KEY_CORE] = target_config
|
CORE.data[KEY_CORE] = target_config
|
||||||
|
@ -87,7 +89,9 @@ def create_components_graph():
|
||||||
add_item_to_components_graph(components_graph, platform_name, name)
|
add_item_to_components_graph(components_graph, platform_name, name)
|
||||||
|
|
||||||
for dependency in platform.dependencies:
|
for dependency in platform.dependencies:
|
||||||
add_item_to_components_graph(components_graph, dependency, name)
|
add_item_to_components_graph(
|
||||||
|
components_graph, dependency.split(".")[0], name
|
||||||
|
)
|
||||||
|
|
||||||
for target_config in TARGET_CONFIGURATIONS:
|
for target_config in TARGET_CONFIGURATIONS:
|
||||||
CORE.data[KEY_CORE] = target_config
|
CORE.data[KEY_CORE] = target_config
|
||||||
|
|
Loading…
Reference in a new issue