track deps in project model

This commit is contained in:
Aleksey Kladov 2018-12-08 21:54:00 +03:00
parent 34956b7823
commit 32c067f8c9

View File

@ -28,6 +28,7 @@ struct PackageData {
manifest: PathBuf,
targets: Vec<Target>,
is_member: bool,
dependencies: Vec<Package>,
}
#[derive(Debug, Clone)]
@ -106,6 +107,7 @@ impl CargoWorkspace {
manifest: PathBuf::from(meta_pkg.manifest_path),
targets: Vec::new(),
is_member,
dependencies: Vec::new(),
};
for meta_tgt in meta_pkg.targets {
let tgt = Target(targets.len());
@ -119,6 +121,14 @@ impl CargoWorkspace {
}
packages.push(pkg_data)
}
let resolve = meta.resolve.expect("metadata executed with deps");
for node in resolve.nodes {
let source = pkg_by_id[&node.id];
for id in node.dependencies {
let target = pkg_by_id[&id];
packages[source.0].dependencies.push(target);
}
}
Ok(CargoWorkspace { packages, targets })
}