Skip to content

Commit

Permalink
Fix --build-plan with dev-dependencies
Browse files Browse the repository at this point in the history
Regressed in rust-lang#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 rust-lang#6082
  • Loading branch information
alexcrichton committed Sep 24, 2018
1 parent 650b5d8 commit d8e43e8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
queue.execute(&mut self, &mut plan)?;

if build_plan {
plan.set_inputs(self.inputs()?);
plan.set_inputs(self.build_plan_inputs()?);
plan.output_plan();
}

Expand Down Expand Up @@ -512,10 +512,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> {

/// Return the list of filenames read by cargo to generate the BuildContext
/// (all Cargo.toml, etc).
pub fn inputs(&self) -> CargoResult<Vec<PathBuf>> {
pub fn build_plan_inputs(&self) -> CargoResult<Vec<PathBuf>> {
let mut inputs = Vec::new();
for id in self.bcx.packages.package_ids() {
let pkg = self.get_package(id)?;
// Note that we're using the `package_cache`, which should have been
// populated by `build_unit_dependencies`, and only those packages are
// considered as all the inputs.
//
// (notably we skip dev-deps here if they aren't present)
for pkg in self.package_cache.values() {
inputs.push(pkg.manifest_path().to_path_buf());
}
inputs.sort();
Expand Down
26 changes: 26 additions & 0 deletions tests/testsuite/build_plan.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use support::registry::Package;
use support::{basic_bin_manifest, basic_manifest, main_file, project};

#[test]
Expand Down Expand Up @@ -180,3 +181,28 @@ fn cargo_build_plan_build_script() {
"#,
).run();
}

#[test]
fn build_plan_with_dev_dep() {
Package::new("bar", "0.1.0").publish();

let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.5.0"
authors = []
[dev-dependencies]
bar = "*"
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("build --build-plan -Zunstable-options")
.masquerade_as_nightly_cargo()
.run();
}

0 comments on commit d8e43e8

Please sign in to comment.