Skip to content

Commit

Permalink
feat: static system link
Browse files Browse the repository at this point in the history
  • Loading branch information
NoXF committed Nov 10, 2023
1 parent 493c070 commit b368782
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repository = "https://github.com/NoXF/libwebp-sys"
[build-dependencies]
cc = "1"
glob = "0.3"
pkg-config = "0.3.27"

[features]
default = ["std", "parallel", "neon"]
Expand All @@ -25,3 +26,4 @@ parallel = ["cc/parallel"]
neon = [] # ARM NEON SIMD (will crash on ARM CPUs without it)
sse41 = [] # x64 SSE 4.1 (will crash on x86 CPUs without it)
avx2 = [] # x64 AVX2 (will crash on x86 CPUs without it)
system-link = []
14 changes: 14 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
extern crate cc;
extern crate glob;
extern crate pkg_config;

use std::env;
use std::path::PathBuf;

fn main() {
if cfg!(feature = "system-link") {
let lib_name = "libwebp";
let find_system_lib = pkg_config::Config::new()
.statik(true)
.probe(lib_name)
.is_ok();

if find_system_lib {
println!("cargo:rustc-link-lib=static={}", lib_name);
return;
}
}

let manifest_dir =
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
let vendor = manifest_dir.join("vendor");
Expand Down

0 comments on commit b368782

Please sign in to comment.