Skip to content

build: Don't always expect a tests/headers directory. #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2017
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
14 changes: 10 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down