Skip to content

Commit

Permalink
download transitive deps of artifact deps on target platform
Browse files Browse the repository at this point in the history
  • Loading branch information
epage authored and elchukc committed Oct 30, 2024
1 parent 24738d8 commit 77a7041
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
20 changes: 19 additions & 1 deletion src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ impl<'gctx> PackageSet<'gctx> {
target_data,
force_all_targets,
);
for (pkg_id, _dep) in filtered_deps {
for (pkg_id, deps) in filtered_deps {
collect_used_deps(
used,
resolve,
Expand All @@ -529,6 +529,24 @@ impl<'gctx> PackageSet<'gctx> {
target_data,
force_all_targets,
)?;
let artifact_kinds = deps.iter().filter_map(|dep| {
Some(
dep.artifact()?
.target()?
.to_resolved_compile_kind(*requested_kinds.iter().next().unwrap()),
)
});
for artifact_kind in artifact_kinds {
collect_used_deps(
used,
resolve,
pkg_id,
has_dev_units,
artifact_kind,
target_data,
force_all_targets,
)?;
}
}
Ok(())
}
Expand Down
23 changes: 12 additions & 11 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,16 +1646,17 @@ fn dep_of_artifact_dep_same_target_specified() {
.with_status(0)
.run();

// TODO This command currently fails due to a bug in cargo but it should be fixed so that it succeeds in the future.
p.cargo("tree -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.with_stderr_data(
.with_stdout_data(
r#"...
no entry found for key
foo v0.1.0 ([ROOT]/foo)
└── bar v0.1.0 ([ROOT]/foo/bar)
└── baz v0.1.0 ([ROOT]/foo/baz)
...
"#,
)
.with_status(101)
.with_status(0)
.run();
}

Expand Down Expand Up @@ -1827,17 +1828,17 @@ fn proc_macro_in_artifact_dep() {

p.cargo("check -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.with_stderr_data(str![[r#"
.with_stderr_data(
r#"...
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] bin-uses-pm v1.0.0 (registry `dummy-registry`)
[DOWNLOADING] crates ...
thread 'main' panicked at src/cargo/core/compiler/unit_dependencies.rs:1035:33:
expected pm v1.0.0 to be downloaded
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[ERROR] failed to download from `[ROOTURL]/dl/pm/1.0.0/download`
"#]])
Caused by:
[37] Could not read a file:// file (Couldn't open file [ROOT]/dl/pm/1.0.0/download)
"#,
)
.with_status(101)
.run();
}
Expand Down

0 comments on commit 77a7041

Please sign in to comment.