Validate dynamic builder outputs

This commit is contained in:
RunasSudo 2025-05-24 00:43:40 +10:00
parent fa7381fce5
commit a0c4aedb2d
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -226,14 +226,31 @@ pub fn steps_for_targets(
&dependencies,
&context,
) {
new_steps.push((builder.build)(
let new_step = (builder.build)(
dependency.product.name,
dependency.product.kind,
dependency.product.args.clone(),
&steps,
&dependencies,
&context,
));
);
// Check new step meets the dependency
if new_step.id().name != dependency.product.name {
panic!("Unexpected step returned from dynamic builder (expected name {}, got {})", dependency.product.name, new_step.id().name);
}
if new_step.id().args != dependency.product.args {
panic!("Unexpected step returned from dynamic builder {} (expected args {:?}, got {:?})", dependency.product.name, dependency.product.args, new_step.id().args);
}
if !new_step
.id()
.product_kinds
.contains(&dependency.product.kind)
{
panic!("Unexpected step returned from dynamic builder {} (expected kind {:?}, got {:?})", dependency.product.name, dependency.product.kind, new_step.id().product_kinds);
}
new_steps.push(new_step);
break;
}
}