Skip to content

Commit

Permalink
Merge pull request #11 from yu-re-ka/pkg-config
Browse files Browse the repository at this point in the history
add pkg-config support
  • Loading branch information
rwestphal authored Nov 3, 2023
2 parents 64e7f80 + de81022 commit f5013b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions libyang2-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ categories = ["external-ffi-bindings"]
bindgen = { version = "0.68.0", optional = true }
cc = { version = "1.0", features = ["parallel"], optional = true }
cmake = { version = "0.1", optional = true }
pkg-config = "0.3.27"

[features]
# Use pre-generated FFI bindings
Expand Down
14 changes: 12 additions & 2 deletions libyang2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,18 @@ fn main() {

build.compile("yang2");
println!("cargo:root={}", env::var("OUT_DIR").unwrap());
println!("cargo:rustc-link-lib=pcre2-8");
if let Err(e) = pkg_config::Config::new().probe("libpcre2-8") {
println!("cargo:warning=failed to find pcre2 library with pkg-config: {}", e);
println!("cargo:warning=attempting to link without pkg-config");
println!("cargo:rustc-link-lib=pcre2-8");
}
}
#[cfg(not(feature = "bundled"))]
println!("cargo:rustc-link-lib=yang");
{
if let Err(e) = pkg_config::Config::new().probe("libyang") {
println!("cargo:warning=failed to find yang library with pkg-config: {}", e);
println!("cargo:warning=attempting to link without pkg-config");
println!("cargo:rustc-link-lib=yang");
}
}
}

0 comments on commit f5013b0

Please sign in to comment.