Skip to content

Commit

Permalink
Add virtual deps to package, not virtual workspace root (#2775)
Browse files Browse the repository at this point in the history
Otherwise on repinning, we get errors because virtual workspaces can't
have deps.

Repinning the multi_package example hit this problem.
  • Loading branch information
illicitonion authored Aug 2, 2024
1 parent 00d1176 commit 4a8f678
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crate_universe/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,28 @@ impl TreeResolver {
pristine_manifest_path
)
})?;

// To add dependencies to a virtual workspace, we need to add them to a package inside the workspace,
// we can't just add them to the workspace directly.
if !proc_macros.is_empty() && manifest.package.is_none() {
if let Some(ref mut workspace) = &mut manifest.workspace {
if !workspace.members.contains(&".".to_owned()) {
workspace.members.push(".".to_owned());
}
manifest.package = Some(cargo_toml::Package::new(
"rules_rust_fake_proc_macro_root",
"0.0.0",
));
}
if manifest.lib.is_none() && manifest.bin.is_empty() {
manifest.bin.push(cargo_toml::Product {
name: Some("rules_rust_fake_proc_macro_root_bin".to_owned()),
path: Some("/dev/null".to_owned()),
..cargo_toml::Product::default()
})
}
}

for (dep_name, dep_version) in proc_macros {
let detail = cargo_toml::DependencyDetail {
package: Some(dep_name.clone()),
Expand Down

0 comments on commit 4a8f678

Please sign in to comment.