Skip to content

Commit 2e74d3f

Browse files
committed
Auto merge of #6086 - alexcrichton:build-plan-dev-deps, r=ehuss
Fix `--build-plan` with dev-dependencies Regressed in #6005 it looks like the build plan requires all packages to be downloaded rather than just those coming out of `unit_dependenices`, so let's make sure to download everything! Closes #6082
2 parents a0e3077 + d8e43e8 commit 2e74d3f

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/cargo/core/compiler/context/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
167167
queue.execute(&mut self, &mut plan)?;
168168

169169
if build_plan {
170-
plan.set_inputs(self.inputs()?);
170+
plan.set_inputs(self.build_plan_inputs()?);
171171
plan.output_plan();
172172
}
173173

@@ -512,10 +512,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
512512

513513
/// Return the list of filenames read by cargo to generate the BuildContext
514514
/// (all Cargo.toml, etc).
515-
pub fn inputs(&self) -> CargoResult<Vec<PathBuf>> {
515+
pub fn build_plan_inputs(&self) -> CargoResult<Vec<PathBuf>> {
516516
let mut inputs = Vec::new();
517-
for id in self.bcx.packages.package_ids() {
518-
let pkg = self.get_package(id)?;
517+
// Note that we're using the `package_cache`, which should have been
518+
// populated by `build_unit_dependencies`, and only those packages are
519+
// considered as all the inputs.
520+
//
521+
// (notably we skip dev-deps here if they aren't present)
522+
for pkg in self.package_cache.values() {
519523
inputs.push(pkg.manifest_path().to_path_buf());
520524
}
521525
inputs.sort();

tests/testsuite/build_plan.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use support::registry::Package;
12
use support::{basic_bin_manifest, basic_manifest, main_file, project};
23

34
#[test]
@@ -180,3 +181,28 @@ fn cargo_build_plan_build_script() {
180181
"#,
181182
).run();
182183
}
184+
185+
#[test]
186+
fn build_plan_with_dev_dep() {
187+
Package::new("bar", "0.1.0").publish();
188+
189+
let p = project()
190+
.file(
191+
"Cargo.toml",
192+
r#"
193+
[project]
194+
name = "foo"
195+
version = "0.5.0"
196+
authors = []
197+
198+
[dev-dependencies]
199+
bar = "*"
200+
"#,
201+
)
202+
.file("src/lib.rs", "")
203+
.build();
204+
205+
p.cargo("build --build-plan -Zunstable-options")
206+
.masquerade_as_nightly_cargo()
207+
.run();
208+
}

0 commit comments

Comments
 (0)