Skip to content

Commit 22097e6

Browse files
author
Jorge Aparicio
committed
use helper function in the rebuild logic of the rustc_*san crates
1 parent 775a936 commit 22097e6

File tree

9 files changed

+24
-60
lines changed

9 files changed

+24
-60
lines changed

src/Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_asan/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name = "rustc_asan"
99
path = "lib.rs"
1010

1111
[build-dependencies]
12+
build_helper = { path = "../build_helper" }
1213
cmake = "0.1.18"
1314

1415
[dependencies]

src/librustc_asan/build.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
extern crate build_helper;
1112
extern crate cmake;
1213

1314
use std::path::PathBuf;
@@ -29,21 +30,9 @@ fn main() {
2930
dst.join("build/lib/linux").display());
3031
println!("cargo:rustc-link-lib=static=clang_rt.asan-x86_64");
3132

32-
let src_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
33-
let mut stack = src_dir.join("../compiler-rt")
34-
.read_dir()
35-
.unwrap()
36-
.map(|e| e.unwrap())
37-
.filter(|e| &*e.file_name() != ".git")
38-
.collect::<Vec<_>>();
39-
while let Some(entry) = stack.pop() {
40-
let path = entry.path();
41-
if entry.file_type().unwrap().is_dir() {
42-
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
43-
} else {
44-
println!("cargo:rerun-if-changed={}", path.display());
45-
}
46-
}
33+
build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR")
34+
.unwrap())
35+
.join("../compiler-rt"));
4736
}
4837

4938
println!("cargo:rerun-if-changed=build.rs");

src/librustc_lsan/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name = "rustc_lsan"
99
path = "lib.rs"
1010

1111
[build-dependencies]
12+
build_helper = { path = "../build_helper" }
1213
cmake = "0.1.18"
1314

1415
[dependencies]

src/librustc_lsan/build.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
extern crate build_helper;
1112
extern crate cmake;
1213

1314
use std::path::PathBuf;
@@ -29,21 +30,9 @@ fn main() {
2930
dst.join("build/lib/linux").display());
3031
println!("cargo:rustc-link-lib=static=clang_rt.lsan-x86_64");
3132

32-
let src_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
33-
let mut stack = src_dir.join("../compiler-rt")
34-
.read_dir()
35-
.unwrap()
36-
.map(|e| e.unwrap())
37-
.filter(|e| &*e.file_name() != ".git")
38-
.collect::<Vec<_>>();
39-
while let Some(entry) = stack.pop() {
40-
let path = entry.path();
41-
if entry.file_type().unwrap().is_dir() {
42-
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
43-
} else {
44-
println!("cargo:rerun-if-changed={}", path.display());
45-
}
46-
}
33+
build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR")
34+
.unwrap())
35+
.join("../compiler-rt"));
4736
}
4837

4938
println!("cargo:rerun-if-changed=build.rs");

src/librustc_msan/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name = "rustc_msan"
99
path = "lib.rs"
1010

1111
[build-dependencies]
12+
build_helper = { path = "../build_helper" }
1213
cmake = "0.1.18"
1314

1415
[dependencies]

src/librustc_msan/build.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
extern crate build_helper;
1112
extern crate cmake;
1213

1314
use std::path::PathBuf;
@@ -29,21 +30,9 @@ fn main() {
2930
dst.join("build/lib/linux").display());
3031
println!("cargo:rustc-link-lib=static=clang_rt.msan-x86_64");
3132

32-
let src_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
33-
let mut stack = src_dir.join("../compiler-rt")
34-
.read_dir()
35-
.unwrap()
36-
.map(|e| e.unwrap())
37-
.filter(|e| &*e.file_name() != ".git")
38-
.collect::<Vec<_>>();
39-
while let Some(entry) = stack.pop() {
40-
let path = entry.path();
41-
if entry.file_type().unwrap().is_dir() {
42-
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
43-
} else {
44-
println!("cargo:rerun-if-changed={}", path.display());
45-
}
46-
}
33+
build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR")
34+
.unwrap())
35+
.join("../compiler-rt"));
4736
}
4837

4938
println!("cargo:rerun-if-changed=build.rs");

src/librustc_tsan/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name = "rustc_tsan"
99
path = "lib.rs"
1010

1111
[build-dependencies]
12+
build_helper = { path = "../build_helper" }
1213
cmake = "0.1.18"
1314

1415
[dependencies]

src/librustc_tsan/build.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
extern crate build_helper;
1112
extern crate cmake;
1213

1314
use std::path::PathBuf;
@@ -29,21 +30,9 @@ fn main() {
2930
dst.join("build/lib/linux").display());
3031
println!("cargo:rustc-link-lib=static=clang_rt.tsan-x86_64");
3132

32-
let src_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
33-
let mut stack = src_dir.join("../compiler-rt")
34-
.read_dir()
35-
.unwrap()
36-
.map(|e| e.unwrap())
37-
.filter(|e| &*e.file_name() != ".git")
38-
.collect::<Vec<_>>();
39-
while let Some(entry) = stack.pop() {
40-
let path = entry.path();
41-
if entry.file_type().unwrap().is_dir() {
42-
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
43-
} else {
44-
println!("cargo:rerun-if-changed={}", path.display());
45-
}
46-
}
33+
build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR")
34+
.unwrap())
35+
.join("../compiler-rt"));
4736
}
4837

4938
println!("cargo:rerun-if-changed=build.rs");

0 commit comments

Comments
 (0)