Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ fn main() {
let install_dir = extracted_install_dir(&version);
let final_path = install_dir.join(platform.binary_name);

// Invalidate build.rs whenever the cached binary disappears (cache GC,
// manual rm, OS reset, switching extract dir). Without this, cargo
// replays the saved `has_extracted_cli` cfg from its build-script
// output cache even when the file is gone, and runtime resolution
// fails with BinaryNotFound.
println!("cargo:rerun-if-changed={}", final_path.display());

if !final_path.is_file() {
let archive = cached_download(
&format!("{base_url}/{}", platform.asset_name),
Expand All @@ -117,7 +124,11 @@ fn main() {
extract_to_cache(&archive, &install_dir, platform);
}

println!("cargo:rustc-cfg=has_extracted_cli");
// Re-check after potential download+extract above; not an `else`
// because we need to verify the extraction actually produced the file.
if final_path.is_file() {
println!("cargo:rustc-cfg=has_extracted_cli");
}
}
}

Expand Down
Loading