Avoid unncessary cargo rebuilds in non-perf configuration

This commit is contained in:
Michael Vines 2018-08-20 11:51:36 -07:00
parent 8de317113c
commit c9e6fb36c3
1 changed files with 11 additions and 0 deletions

View File

@ -1,7 +1,18 @@
use std::env;
use std::fs;
fn main() {
println!("cargo:rerun-if-changed=target/perf-libs");
println!("cargo:rerun-if-changed=build.rs");
// Ensure target/perf-libs/ exists. It's been observed that
// a cargo:rerun-if-changed= directive with a non-existent
// directory triggers a rebuild on every |cargo build| invocation
fs::create_dir("target/perf-libs").unwrap_or_else(|err| {
if err.kind() != std::io::ErrorKind::AlreadyExists {
panic!("Unable to create target/perf-libs: {:?}", err);
}
});
let cuda = !env::var("CARGO_FEATURE_CUDA").is_err();
let erasure = !env::var("CARGO_FEATURE_ERASURE").is_err();