Skip to content

Add 'static' feature to build a statically linked crate #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ vcpkg = "0.2"
# noted in `contrib/README.contrib`, these routines are experimental and not
# vetted, use at your own risk!
asm = []
# Enable this feature if you want to have a staticly linked libz
static = []
3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ fn main() {
// also don't run pkg-config on macOS/FreeBSD/DragonFly. That'll end up printing
// `-L /usr/lib` which wreaks havoc with linking to an OpenSSL in /usr/local/lib
// (Homebrew, Ports, etc.)
let want_static = env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1";
let want_static =
cfg!(feature = "static") || env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1";
if !wants_asm &&
!want_static &&
!target.contains("msvc") && // pkg-config just never works here
Expand Down
3 changes: 3 additions & 0 deletions systest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ libc = "0.2"

[build-dependencies]
ctest = "0.1"

[features]
libz-static = ["libz-sys/static"]