diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-04-17 15:30:55 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-04-17 15:30:55 +0200 |
commit | aaa42bcccb54f4025c0e129728432056b78e95d6 (patch) | |
tree | 6c461c02f2644617855e8dc63bd902b6d11d36a2 | |
parent | 719d03c7724da0c93b05b891465b2df4299ef169 (diff) |
build: Don't always expect a tests/headers directory.
It may not exist after packaging. This should unblock publishing bindgen.
-rw-r--r-- | build.rs | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -28,13 +28,19 @@ mod testgen { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let mut dst = File::create(Path::new(&out_dir).join("tests.rs")).unwrap(); - println!("cargo:rerun-if-changed=tests/headers"); let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let headers_dir = manifest_dir.join("tests").join("headers"); - let entries = fs::read_dir(headers_dir) - .expect("Couldn't read headers dir") - .map(|result| result.expect("Couldn't read header file")); + let headers = match fs::read_dir(headers_dir) { + Ok(dir) => dir, + // We may not have headers directory after packaging. + Err(..) => return, + }; + + let entries = + headers.map(|result| result.expect("Couldn't read header file")); + + println!("cargo:rerun-if-changed=tests/headers"); for entry in entries { match entry.path().extension().and_then(OsStr::to_str) { |