-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to use static builds of libtiledb
This updates the tiledb-sys crate to be able to build a static version of libtiledb. This allows Rust projects to create statically linked binaries for distribution.
- Loading branch information
Showing
24 changed files
with
1,468 additions
and
298 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ tiledb-common = { workspace = true } | |
|
||
[build-dependencies] | ||
libtiledb = { workspace = true } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
fn main() { | ||
libtiledb::rpath() | ||
libtiledb::rpath(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::thread; | ||
use std::time::Duration; | ||
|
||
use subprocess as sp; | ||
|
||
use crate::error::{Error, Result}; | ||
|
||
pub fn run(cmd: &[&str], input: Option<&str>) -> Result<()> { | ||
// Execute our Git command | ||
let stdin = if input.is_some() { | ||
sp::Redirection::Pipe | ||
} else { | ||
sp::Redirection::None | ||
}; | ||
|
||
let mut git = sp::Popen::create( | ||
cmd, | ||
sp::PopenConfig { | ||
stdin, | ||
stdout: sp::Redirection::Pipe, | ||
stderr: sp::Redirection::Pipe, | ||
..Default::default() | ||
}, | ||
) | ||
.map_err(|e| { | ||
Error::Popen(format!("Spawning command: {}", cmd.join(" ")), e) | ||
})?; | ||
|
||
// Obtain the output from the standard streams. | ||
let (out, err) = git.communicate(input).map_err(|e| { | ||
Error::IO(format!("Executing command: {}", cmd.join(" ")), e) | ||
})?; | ||
|
||
// Wait for git to finish executing | ||
loop { | ||
let result = git.poll(); | ||
if result.is_none() { | ||
thread::sleep(Duration::from_secs(1)); | ||
continue; | ||
} | ||
|
||
if !matches!(result, Some(sp::ExitStatus::Exited(0))) { | ||
let msg = format!( | ||
"Error executing command.\ncommand: {}\ninput: {:?}\nstdout:\n{}\n\nstderr:\n{}", | ||
cmd.join(" "), | ||
input, | ||
out.unwrap_or("".to_string()), | ||
err.unwrap_or("".to_string()) | ||
); | ||
return Err(Error::Git(msg)); | ||
} | ||
|
||
break; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::current_os; | ||
use crate::error::Result; | ||
use crate::utils; | ||
|
||
pub fn libtiledb() -> Result<String> { | ||
let build_dir = utils::build_dir(); | ||
if build_dir.is_dir() { | ||
let mut bundled = build_dir.clone(); | ||
bundled.push("libtiledb_bundled.a"); | ||
if bundled.is_file() { | ||
configure_rustc(&build_dir); | ||
return Ok(build_dir.display().to_string()); | ||
} | ||
} | ||
|
||
// N.B., you might think this should be `build_dir()`, but the cmake crate | ||
// appends `build` unconditionally so we have to go one directory up. | ||
let out_dir = utils::out_dir(); | ||
let git_dir = utils::git_dir(); | ||
let mut builder = cmake::Config::new(&git_dir); | ||
builder | ||
.out_dir(out_dir) | ||
.build_target("all") | ||
.define("BUILD_SHARED_LIBS", "OFF") | ||
.define("TILEDB_WERROR", "OFF") | ||
.define("TILEDB_S3", "ON") | ||
.define("TILEDB_SERIALIZATION", "ON"); | ||
|
||
if std::env::var("TILEDB_SYS_CCACHE").is_ok() { | ||
builder.define("TILEDB_CCACHE", "ON"); | ||
} | ||
|
||
if let Ok(num_jobs) = std::env::var("TILEDB_SYS_JOBS") { | ||
builder.build_arg(format!("-j{}", num_jobs)); | ||
} | ||
|
||
let mut dst = builder.build(); | ||
dst.push("build"); | ||
|
||
current_os::merge_libraries(&dst)?; | ||
configure_rustc(&dst); | ||
Ok(dst.display().to_string()) | ||
} | ||
|
||
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"); | ||
|
||
// Add any extra OS specific config | ||
current_os::configure_rustc(out).expect("Error configuring rustc"); | ||
} |
Oops, something went wrong.