Skip to content

Commit

Permalink
feat: add feature "static" to allow static linkage for unix/macos as …
Browse files Browse the repository at this point in the history
…well.
  • Loading branch information
mbehr1 authored and otavio committed Jun 24, 2024
1 parent 4152415 commit 8406b2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ libc = "0.2.86"
async_support = ["async-trait", "futures-channel", "futures-core", "futures-io", "futures-util", "futures-executor"]
futures_support = ["async_support", "blocking"]
tokio_support = ["async_support", "tokio", "tokio-util"]
static = []

[dev-dependencies]
tempfile = "3.1"
Expand Down
25 changes: 25 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,35 @@ fn find_libarchive() {
std::env::set_var("PKG_CONFIG_PATH", MACOS_HOMEBREW_LIBARCHIVE_PATH);
}

if cfg!(feature = "static") {
pkg_config::Config::new()
.atleast_version("0.98.1")
.statik(cfg!(feature = "static"))
.probe("libb2")
.expect("Unable to find libb2");

pkg_config::Config::new()
.atleast_version("1.9.4")
.statik(cfg!(feature = "static"))
.probe("liblz4")
.expect("Unable to find liblz4");

pkg_config::Config::new()
.atleast_version("1.5.6")
.statik(cfg!(feature = "static"))
.probe("libzstd")
.expect("Unable to find libzstd");
}

pkg_config::Config::new()
.atleast_version("3.2.0")
.statik(cfg!(feature = "static"))
.probe("libarchive")
.expect("Unable to find libarchive");

if cfg!(feature = "static") {
println!("cargo:rustc-link-lib=static=archive");
}
}

#[cfg(target_env = "msvc")]
Expand Down

0 comments on commit 8406b2c

Please sign in to comment.