Skip to content

Commit 0982968

Browse files
authored
Increase resilience towards partial cache clears (#119)
1 parent 0cbd863 commit 0982968

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

crates/cargo-gpu/src/install.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,24 +223,26 @@ package = "rustc_codegen_spirv"
223223
std::env::consts::DLL_SUFFIX
224224
);
225225

226-
let dest_dylib_path;
227-
if source.is_path() {
228-
dest_dylib_path = install_dir
229-
.join("target")
230-
.join("release")
231-
.join(&dylib_filename);
226+
let (dest_dylib_path, skip_rebuild) = if source.is_path() {
227+
(
228+
install_dir
229+
.join("target")
230+
.join("release")
231+
.join(&dylib_filename),
232+
// if `source` is a path, always rebuild
233+
false,
234+
)
232235
} else {
233-
dest_dylib_path = install_dir.join(&dylib_filename);
234-
if dest_dylib_path.is_file() {
235-
log::info!(
236-
"cargo-gpu artifacts are already installed in '{}'",
237-
install_dir.display()
238-
);
236+
let dest_dylib_path = install_dir.join(&dylib_filename);
237+
let artifacts_found = dest_dylib_path.is_file()
238+
&& install_dir.join("Cargo.toml").is_file()
239+
&& install_dir.join("src").join("lib.rs").is_file();
240+
if artifacts_found {
241+
log::info!("cargo-gpu artifacts found in '{}'", install_dir.display());
239242
}
240-
}
243+
(dest_dylib_path, artifacts_found && !self.rebuild_codegen)
244+
};
241245

242-
// if `source` is a path, always rebuild
243-
let skip_rebuild = !source.is_path() && dest_dylib_path.is_file() && !self.rebuild_codegen;
244246
if skip_rebuild {
245247
log::info!("...and so we are aborting the install step.");
246248
} else {

0 commit comments

Comments
 (0)