Skip to content

Commit

Permalink
Use pkg-config in build.rs
Browse files Browse the repository at this point in the history
The previous approach relied on the library being in the
linker's default paths.
  • Loading branch information
sophie-h committed Jun 4, 2023
1 parent 22ea930 commit fcfba4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use-bindgen = ["bindgen"]

[build-dependencies]
bindgen = { version = "0.63.0", optional = true }
pkg-config = "0.3.15"


[package.metadata.release]
Expand Down
9 changes: 8 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
use std::env;
#[cfg(feature = "use-bindgen")]
use std::path::PathBuf;
use std::process;

fn main() {
// Tell cargo to tell rustc to link the system heif
// shared library.
println!("cargo:rustc-link-lib=heif");
if let Err(err) = pkg_config::Config::new()
.atleast_version("1.14")
.probe("libheif")
{
println!("cargo:warning={}", err);
process::exit(1);
}

#[cfg(feature = "use-bindgen")]
{
Expand Down

1 comment on commit fcfba4e

@chadaustin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the use of pkg_config be gated to unix?

#3

Please sign in to comment.