Skip to content

Commit 142128b

Browse files
committed
Generate lockfile and fetch dependencies outside sandbox on retry
1 parent 2993463 commit 142128b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/docbuilder/rustwide_builder.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,16 @@ impl RustwideBuilder {
337337
// If the build fails with the lockfile given, try using only the dependencies listed in Cargo.toml.
338338
let cargo_lock = build.host_source_dir().join("Cargo.lock");
339339
if !res.result.successful && cargo_lock.exists() {
340+
info!("removing lockfile and reattempting build");
340341
std::fs::remove_file(cargo_lock)?;
342+
Command::new(&self.workspace, self.toolchain.cargo())
343+
.cd(build.host_source_dir())
344+
.args(&["generate-lockfile", "-Zno-index-update"])
345+
.run()?;
346+
Command::new(&self.workspace, self.toolchain.cargo())
347+
.cd(build.host_source_dir())
348+
.args(&["fetch", "--locked"])
349+
.run()?;
341350
res = self.execute_build(
342351
default_target,
343352
true,
@@ -1019,4 +1028,19 @@ mod tests {
10191028
Ok(())
10201029
});
10211030
}
1031+
1032+
#[test]
1033+
#[ignore]
1034+
fn test_locked_fails_unlocked_needs_new_deps() {
1035+
wrapper(|env| {
1036+
env.override_config(|cfg| cfg.include_default_targets = false);
1037+
1038+
let crate_ = "stm32f7xx-hal";
1039+
let version = "0.6.0";
1040+
let mut builder = RustwideBuilder::init(env).unwrap();
1041+
assert!(builder.build_package(crate_, version, PackageKind::CratesIo)?);
1042+
1043+
Ok(())
1044+
});
1045+
}
10221046
}

0 commit comments

Comments
 (0)