Skip to content

Commit

Permalink
Yarps
Browse files Browse the repository at this point in the history
  • Loading branch information
davisp committed Nov 8, 2024
1 parent f15765e commit b408abc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
13 changes: 13 additions & 0 deletions tiledb/sys-cfg/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main() {
let linkage =
std::env::var("DEP_TILEDB_LINKAGE").expect("Missing DEP_TILEDB_LIKAGE");
if linkage == "dynamic" {
let libdir = std::env::var("DEP_TILEDB_LIBDIR")
.expect("Missing DEP_TILEDB_LIBDIR");
println!("cargo::rustc-env=TILEDB_RPATH={}", libdir);
} else if linkage == "static" {
println!("cargo::rustc-env=TILEDB_RPATH=");
} else {
panic!("Unknown linkage of tiledb-sys: {linkage}")
}
}
18 changes: 12 additions & 6 deletions tiledb/sys-cfg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
/// building static binaries, this is a no-op when tiledb-sys was built
/// statically.
pub fn rpath() {
let libdir = option_env!("DEP_TILEDB_LIBDIR");
if libdir.is_none() {
let libdir = env!("TILEDB_RPATH");
if libdir.is_empty() {
return;
}

println!(
"cargo:rustc-link-arg=-Wl,-rpath,@loader_path,-rpath,$ORIGIN,-rpath,{}",
libdir.unwrap()
);
let parts = [
"cargo::rustc-link-arg=",
"-Wl,",
"-rpath,@loader_path,",
"-rpath,$ORIGIN,",
"-rpath,",
libdir,
];

println!("{}", parts.join(""));
}
1 change: 1 addition & 0 deletions tiledb/sys/build/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fn configure_rustc(out: &std::path::Path) {
// Configure linking
println!("cargo::rustc-link-search=native={}", out.display());
println!("cargo::rustc-link-lib=static=tiledb_bundled");
println!("cargo::metadata=LINKAGE=static");

// Add any extra OS specific config
current_os::configure_rustc(out).expect("Error configuring rustc");
Expand Down
10 changes: 3 additions & 7 deletions tiledb/sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ fn configure_dynamic() -> error::Result<()> {
.atleast_version("2.20.0")
.probe("tiledb")
.expect("Build-time TileDB library missing, version >= 2.4 not found.");
println!("cargo:rustc-link-lib=tiledb");
println!("cargo::rustc-link-lib=tiledb");

let libdir = pkg_config::get_variable("tiledb", "libdir")
.expect("Missing tiledb dependency.");

println!(
"cargo:rustc-link-arg=-Wl,-rpath,@loader_path,-rpath,$ORIGIN,-rpath,{}",
libdir
);

println!("cargo:rustc-env=DYLD_LIBRARY_PATH=/opt/tiledb/lib");
println!("cargo::metadata=LINKAGE=dynamic");
println!("cargo::metadata=LIBDIR={libdir}");

Ok(())
}
Expand Down

0 comments on commit b408abc

Please sign in to comment.