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: 10 additions & 3 deletions crates/build/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,26 @@ pub(crate) fn cargo_rerun_if_changed(metadata: &Metadata, program_dir: &Path) {
];
for dir in dirs {
if dir.exists() {
println!("cargo::rerun-if-changed={}", dir.canonicalize().unwrap().display());
if let Ok(canonical_path) = dir.canonicalize() {
println!("cargo::rerun-if-changed={}", canonical_path.display());
} else {
println!(
"cargo::warning=Could not canonicalize path: {dir:?}, using original path"
);
println!("cargo::rerun-if-changed={}", dir.display());
}
}
}

// Re-run the build script if the workspace root's Cargo.lock changes. If the program is its own
// workspace, this will be the program's Cargo.lock.
println!("cargo:rerun-if-changed={}", metadata.workspace_root.join("Cargo.lock").as_str());
println!("cargo::rerun-if-changed={}", metadata.workspace_root.join("Cargo.lock").as_str());

// Re-run if any local dependency changes.
for package in &metadata.packages {
for dependency in &package.dependencies {
if let Some(path) = &dependency.path {
println!("cargo:rerun-if-changed={}", path.as_str());
println!("cargo::rerun-if-changed={}", path.as_str());
}
}
}
Expand Down