From e7aae437469e08bc9e91f9549ce8015f5392cc1e Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sat, 21 Sep 2019 11:58:26 -0400 Subject: [PATCH] Add all link search paths Probably want to rewrite via `cc` at some point. --- aeron_driver-sys/build.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/aeron_driver-sys/build.rs b/aeron_driver-sys/build.rs index e6b656b..dcfb192 100644 --- a/aeron_driver-sys/build.rs +++ b/aeron_driver-sys/build.rs @@ -53,8 +53,18 @@ pub fn main() { // Trying to figure out the final path is a bit weird; // For Linux/OSX, it's just build/lib // For Windows, it's build/lib/{profile} - let lib_dir = lib_output_dir(&cmake_output); - println!("cargo:rustc-link-search=native={}", lib_dir.display()); + let base_lib_dir = cmake_output.join("build").join("lib"); + println!("cargo:rustc-link-search=native={}", base_lib_dir.display()); + // Because the `cmake_output` path is different for debug/release, we're not worried + // about accidentally linking in the wrong library + println!( + "cargo:rustc-link-search=native={}", + base_lib_dir.join("Debug").display() + ); + println!( + "cargo:rustc-link-search=native={}", + base_lib_dir.join("Release").display() + ); println!("cargo:include={}", header_path.display()); let bindings = bindgen::Builder::default() @@ -67,15 +77,3 @@ pub fn main() { .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); } - -fn lib_output_dir(cmake_dir: &PathBuf) -> PathBuf { - if cfg!(target_os = "windows") { - if cmake_dir.join("build/lib/Debug").exists() { - cmake_dir.join("build/lib/Debug") - } else { - cmake_dir.join("build/lib/Release") - } - } else { - cmake_dir.join("build/lib") - } -}