Skip to content

Commit

Permalink
Merge pull request #12 from jelmansouri/cargo-change-detection
Browse files Browse the repository at this point in the history
Fix Cargo change detection in the runtime
  • Loading branch information
Twinklebear authored Feb 17, 2022
2 parents 0b195d6 + 08b8531 commit b16ef27
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ impl PackagedModule {
}
/// Link with a previously built ISPC library packaged with the crate
pub fn link(&self) {
let libfile = self.lib.clone() + &env::var("HOST").unwrap();
let path = self.get_lib_path();
let libfile = self.lib.clone() + &env::var("TARGET").unwrap();
let bindgen_file = self.lib.clone() + ".rs";
println!("cargo:rerun-if-changed={}", libfile);
println!("cargo:rerun-if-changed={}", bindgen_file);

println!("cargo:rustc-link-lib=static={}", libfile);

let path = self.get_lib_path();
println!("cargo:rerun-if-changed={}", path.join(get_lib_filename(&libfile)).display());
println!("cargo:rerun-if-changed={}", path.join(bindgen_file).display());
println!("cargo:rustc-link-search=native={}", path.display());
println!("cargo:rustc-env=ISPC_OUT_DIR={}", path.display());
}
Expand All @@ -97,6 +97,14 @@ impl PackagedModule {
}
}

fn get_lib_filename(libfile: &str) -> String {
if libfile.contains("windows") {
format!("{}.lib", libfile)
} else {
format!("lib{}.a", libfile)
}
}

static mut TASK_SYSTEM: Option<&'static dyn TaskSystem> = None;
static TASK_INIT: Once = Once::new();

Expand Down

0 comments on commit b16ef27

Please sign in to comment.