1
0
mirror of https://github.com/bspeice/aeron-rs synced 2024-12-22 05:48:10 -05:00

Add all link search paths

Probably want to rewrite via `cc` at some point.
This commit is contained in:
Bradlee Speice 2019-09-21 11:58:26 -04:00
parent 4c9f575e2b
commit e7aae43746

View File

@ -53,8 +53,18 @@ pub fn main() {
// Trying to figure out the final path is a bit weird; // Trying to figure out the final path is a bit weird;
// For Linux/OSX, it's just build/lib // For Linux/OSX, it's just build/lib
// For Windows, it's build/lib/{profile} // For Windows, it's build/lib/{profile}
let lib_dir = lib_output_dir(&cmake_output); let base_lib_dir = cmake_output.join("build").join("lib");
println!("cargo:rustc-link-search=native={}", lib_dir.display()); 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()); println!("cargo:include={}", header_path.display());
let bindings = bindgen::Builder::default() let bindings = bindgen::Builder::default()
@ -67,15 +77,3 @@ pub fn main() {
.write_to_file(out_path.join("bindings.rs")) .write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!"); .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")
}
}