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
This commit is contained in:
bors 2018-09-24 22:43:47 +00:00
commit 2e74d3fde0
2 changed files with 34 additions and 4 deletions

View File

@ -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();
}
@ -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();

View File

@ -1,3 +1,4 @@
use support::registry::Package;
use support::{basic_bin_manifest, basic_manifest, main_file, project};
#[test]
@ -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();
}