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 1e52ba1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

* Raise MSRV to 1.65.0
* Fix use slice::from_raw_parts only if size > 0 [#126]
* Add feature "static" to allow static linkage for unix/macos [#127]

[#126]: https://github.com/OSSystems/compress-tools-rs/pull/126
[#127]: https://github.com/OSSystems/compress-tools-rs/pull/127

## [0.14.3] - 2023-05-26

Expand Down
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
22 changes: 22 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,32 @@ fn find_libarchive() {
std::env::set_var("PKG_CONFIG_PATH", MACOS_HOMEBREW_LIBARCHIVE_PATH);
}

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

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

pkg_config::Config::new()
.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 1e52ba1

Please sign in to comment.