Skip to content

Commit 1f87055

Browse files
committed
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!
1 parent 3bab084 commit 1f87055

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/cargo/ops/cargo_rustc/output_depinfo.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,32 @@ fn render_filename<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResul
1919
relpath.to_str().ok_or_else(|| internal("path not utf-8")).map(|f| f.replace(" ", "\\ "))
2020
}
2121

22-
fn add_deps_for_unit<'a, 'b>(deps: &mut HashSet<PathBuf>, context: &mut Context<'a, 'b>,
23-
unit: &Unit<'a>, visited: &mut HashSet<Unit<'a>>) -> CargoResult<()>
22+
fn add_deps_for_unit<'a, 'b>(
23+
deps: &mut HashSet<PathBuf>,
24+
context: &mut Context<'a, 'b>,
25+
unit: &Unit<'a>,
26+
visited: &mut HashSet<Unit<'a>>,
27+
)
28+
-> CargoResult<()>
2429
{
2530
if !visited.insert(*unit) {
2631
return Ok(());
2732
}
2833

29-
// Add dependencies from rustc dep-info output (stored in fingerprint directory)
30-
let dep_info_loc = fingerprint::dep_info_loc(context, unit);
31-
if let Some(paths) = fingerprint::parse_dep_info(&dep_info_loc)? {
32-
for path in paths {
33-
deps.insert(path);
34+
// units representing the execution of a build script don't actually
35+
// generate a dep info file, so we just keep on going below
36+
if !unit.profile.run_custom_build {
37+
// Add dependencies from rustc dep-info output (stored in fingerprint directory)
38+
let dep_info_loc = fingerprint::dep_info_loc(context, unit);
39+
if let Some(paths) = fingerprint::parse_dep_info(&dep_info_loc)? {
40+
for path in paths {
41+
deps.insert(path);
42+
}
43+
} else {
44+
debug!("can't find dep_info for {:?} {:?}",
45+
unit.pkg.package_id(), unit.profile);
46+
return Err(internal("dep_info missing"));
3447
}
35-
} else {
36-
debug!("can't find dep_info for {:?} {:?}",
37-
unit.pkg.package_id(), unit.profile);
38-
return Err(internal("dep_info missing"));
3948
}
4049

4150
// Add rerun-if-changed dependencies

tests/dep-info.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fn build_dep_info_lib() {
3131
name = "ex"
3232
crate-type = ["lib"]
3333
"#)
34+
.file("build.rs", "fn main() {}")
3435
.file("src/lib.rs", "")
3536
.file("examples/ex.rs", "")
3637
.build();

0 commit comments

Comments
 (0)