Skip to content

Commit 4375cf3

Browse files
proc-macro-test build script: wipe before, be more verbose
1 parent a88e088 commit 4375cf3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

crates/proc-macro-test/build.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,28 @@ use std::{
1212
use cargo_metadata::Message;
1313

1414
fn main() {
15+
println!("cargo:rerun-if-changed=imp");
16+
1517
let out_dir = env::var_os("OUT_DIR").unwrap();
1618
let out_dir = Path::new(&out_dir);
1719

1820
let name = "proc-macro-test-impl";
1921
let version = "0.0.0";
2022

2123
let imp_dir = std::env::current_dir().unwrap().join("imp");
22-
let staging_dir = out_dir.join("staging");
24+
25+
let staging_dir = out_dir.join("proc-macro-test-imp-staging");
26+
// this'll error out if the staging dir didn't previously. using
27+
// `std::fs::exists` would suffer from TOCTOU so just do our best to
28+
// wip it and ignore errors.
29+
let _ = std::fs::remove_dir_all(&staging_dir);
30+
31+
println!("Creating {}", staging_dir.display());
2332
std::fs::create_dir_all(&staging_dir).unwrap();
24-
std::fs::create_dir_all(staging_dir.join("src")).unwrap();
33+
34+
let src_dir = staging_dir.join("src");
35+
println!("Creating {}", src_dir.display());
36+
std::fs::create_dir_all(src_dir).unwrap();
2537

2638
for item_els in [&["Cargo.toml"][..], &["Cargo.lock"], &["src", "lib.rs"]] {
2739
let mut src = imp_dir.clone();
@@ -30,6 +42,7 @@ fn main() {
3042
src.push(el);
3143
dst.push(el);
3244
}
45+
println!("Copying {} to {}", src.display(), dst.display());
3346
std::fs::copy(src, dst).unwrap();
3447
}
3548

0 commit comments

Comments
 (0)