Skip to content

Commit

Permalink
Auto merge of #4711 - alexcrichton:fix-dep-info, r=matklad
Browse files Browse the repository at this point in the history
Fix dep info showing up with a build script

Cargo would erroneously bail out early and accidentally forget to emit a
dep info file if any dependency used a build script, so this fixes that!
  • Loading branch information
bors committed Nov 12, 2017
2 parents 6463fc7 + 9e4f4d1 commit de48f75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/cargo/ops/cargo_rustc/output_depinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,32 @@ fn render_filename<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResul
relpath.to_str().ok_or_else(|| internal("path not utf-8")).map(|f| f.replace(" ", "\\ "))
}

fn add_deps_for_unit<'a, 'b>(deps: &mut HashSet<PathBuf>, context: &mut Context<'a, 'b>,
unit: &Unit<'a>, visited: &mut HashSet<Unit<'a>>) -> CargoResult<()>
fn add_deps_for_unit<'a, 'b>(
deps: &mut HashSet<PathBuf>,
context: &mut Context<'a, 'b>,
unit: &Unit<'a>,
visited: &mut HashSet<Unit<'a>>,
)
-> CargoResult<()>
{
if !visited.insert(*unit) {
return Ok(());
}

// Add dependencies from rustc dep-info output (stored in fingerprint directory)
let dep_info_loc = fingerprint::dep_info_loc(context, unit);
if let Some(paths) = fingerprint::parse_dep_info(&dep_info_loc)? {
for path in paths {
deps.insert(path);
// units representing the execution of a build script don't actually
// generate a dep info file, so we just keep on going below
if !unit.profile.run_custom_build {
// Add dependencies from rustc dep-info output (stored in fingerprint directory)
let dep_info_loc = fingerprint::dep_info_loc(context, unit);
if let Some(paths) = fingerprint::parse_dep_info(&dep_info_loc)? {
for path in paths {
deps.insert(path);
}
} else {
debug!("can't find dep_info for {:?} {:?}",
unit.pkg.package_id(), unit.profile);
return Err(internal("dep_info missing"));
}
} else {
debug!("can't find dep_info for {:?} {:?}",
unit.pkg.package_id(), unit.profile);
return Err(internal("dep_info missing"));
}

// Add rerun-if-changed dependencies
Expand Down
1 change: 1 addition & 0 deletions tests/dep-info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn build_dep_info_lib() {
name = "ex"
crate-type = ["lib"]
"#)
.file("build.rs", "fn main() {}")
.file("src/lib.rs", "")
.file("examples/ex.rs", "")
.build();
Expand Down

0 comments on commit de48f75

Please sign in to comment.