From 9117260f362e935d2d8e9820e1277d7599d6d170 Mon Sep 17 00:00:00 2001 From: nikoPLP Date: Wed, 9 Aug 2023 23:23:13 +0300 Subject: [PATCH] customize build based on target platform (linux/macos) --- librocksdb-sys/build.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 6469031..2096831 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -165,6 +165,13 @@ fn build_rocksdb() { config.define("HAVE_UINT128_EXTENSION", None); config.flag_if_supported("-faligned-new"); config.define("AVE_ALIGNED_NEW", None); + let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + println!( + "cargo:rustc-link-search=native={}", + Path::new(&dir) + .join("rocksdb/plugin/ippcp/library/macos/lib") + .display() + ); } else if target.contains("android") { config.define("OS_ANDROID", None); config.define("ROCKSDB_PLATFORM_POSIX", None); @@ -178,6 +185,15 @@ fn build_rocksdb() { println!("cargo:rustc-link-arg=-lpthread"); println!("cargo:rustc-link-arg=-lrt"); println!("cargo:rustc-link-arg=-ldl"); + + let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + println!( + "cargo:rustc-link-search=native={}", + Path::new(&dir) + .join("rocksdb/plugin/ippcp/library/linux/lib") + .display() + ); + println!("cargo:rustc-link-lib=static=ippcp"); } else if target.contains("freebsd") { config.define("OS_FREEBSD", None); config.define("ROCKSDB_PLATFORM_POSIX", None); @@ -294,15 +310,6 @@ fn build_rocksdb() { config.cpp(true); config.flag_if_supported("-std=c++17"); - let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - println!( - "cargo:rustc-link-search=native={}", - Path::new(&dir) - .join("rocksdb/plugin/ippcp/library/lib") - .display() - ); - println!("cargo:rustc-link-lib=static=ippcp"); - config.compile("librocksdb.a"); }