Skip to content

Commit

Permalink
Merge pull request #72 from nbigaouette-eai/fix_library_loading_on_ni…
Browse files Browse the repository at this point in the history
…ghtly

Fix running under nightly: copy prebuilt `libtensorflow.so` to `OUT_DIR`
  • Loading branch information
adamcrume committed Mar 19, 2017
2 parents 92d60f9 + 05d4d2b commit b39cc0c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tensorflow-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ fn install_prebuilt() {
// Extract the tarball.
let unpacked_dir = download_dir.join(base_name);
let lib_dir = unpacked_dir.join("lib");
if !lib_dir.join(format!("lib{}.so", LIBRARY)).exists() {
let library_file = format!("lib{}.so", LIBRARY);
let library_full_path = lib_dir.join(&library_file);
if !library_full_path.exists() {
extract(file_name, &unpacked_dir);
}

Expand All @@ -122,7 +124,16 @@ fn install_prebuilt() {
}); // TODO: remove

println!("cargo:rustc-link-lib=dylib={}", LIBRARY);
println!("cargo:rustc-link-search={}", lib_dir.display());
let output = PathBuf::from(&get!("OUT_DIR"));
let new_library_full_path = output.join(&library_file);
if new_library_full_path.exists() {
log!("File {} already exists, deleting.", new_library_full_path.display());
std::fs::remove_file(&new_library_full_path).unwrap();
}

log!("Copying {} to {}...", library_full_path.display(), new_library_full_path.display());
std::fs::copy(&library_full_path, &new_library_full_path).unwrap();
println!("cargo:rustc-link-search={}", output.display());
}

fn build_from_src() {
Expand Down

0 comments on commit b39cc0c

Please sign in to comment.