1
0
mirror of https://github.com/bspeice/aeron-rs synced 2024-12-21 21:38:09 -05:00

Add support for Windows lib lookup directory

This commit is contained in:
Bradlee Speice 2019-09-20 00:14:40 -04:00
parent 67a24a35d8
commit ffe015e9db

View File

@ -46,12 +46,17 @@ pub fn main() {
link_type.link_lib(), link_type.link_lib(),
link_type.target_name() link_type.target_name()
); );
let lib_dir = Config::new(&aeron_path) let cmake_output = Config::new(&aeron_path)
.build_target(link_type.target_name()) .build_target(link_type.target_name())
.build(); .build();
// 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!( println!(
"cargo:rustc-link-search=native={}", "cargo:rustc-link-search=native={}",
lib_dir.join("build/lib").display() lib_dir.display()
); );
println!("cargo:include={}", header_path.display()); println!("cargo:include={}", header_path.display());
@ -65,3 +70,15 @@ 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")
}
}