Skip to content

Commit 76cc088

Browse files
author
bors-servo
authored
Auto merge of rust-lang#637 - emilio:headers-dir, r=SimonSapin
build: Don't always expect a tests/headers directory. It may not exist after packaging. This should unblock publishing bindgen.
2 parents 719d03c + aaa42bc commit 76cc088

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

build.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ mod testgen {
2828
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
2929
let mut dst = File::create(Path::new(&out_dir).join("tests.rs")).unwrap();
3030

31-
println!("cargo:rerun-if-changed=tests/headers");
3231
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
3332
let headers_dir = manifest_dir.join("tests").join("headers");
3433

35-
let entries = fs::read_dir(headers_dir)
36-
.expect("Couldn't read headers dir")
37-
.map(|result| result.expect("Couldn't read header file"));
34+
let headers = match fs::read_dir(headers_dir) {
35+
Ok(dir) => dir,
36+
// We may not have headers directory after packaging.
37+
Err(..) => return,
38+
};
39+
40+
let entries =
41+
headers.map(|result| result.expect("Couldn't read header file"));
42+
43+
println!("cargo:rerun-if-changed=tests/headers");
3844

3945
for entry in entries {
4046
match entry.path().extension().and_then(OsStr::to_str) {

0 commit comments

Comments
 (0)