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 Jan 20, 2025
1 parent 92bfc2f commit f8ee328
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ edition = "2021"
opt-level = 2

[build-dependencies]
cc = "1.1"
glob = "0.3.1"
cc = "1"
glob = "0.3"
pkg-config = "0.3.27"

[features]
default = ["std", "parallel"]
Expand All @@ -32,3 +33,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 = []
13 changes: 10 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
extern crate cc;
extern crate glob;

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().probe(lib_name).is_ok();

if find_system_lib {
println!("cargo:rustc-link-lib={}", 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 f8ee328

Please sign in to comment.