Skip to content

Commit

Permalink
Merge pull request #93 from kaniini/master
Browse files Browse the repository at this point in the history
add support for PKG_CONFIG_ALLOW_SYSTEM_CFLAGS
  • Loading branch information
sdroege committed Sep 9, 2019
2 parents 81378e5 + 078af54 commit de90d5d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub struct Config {
cargo_metadata: bool,
env_metadata: bool,
print_system_libs: bool,
print_system_cflags: bool,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -213,6 +214,7 @@ impl Config {
min_version: Bound::Unbounded,
max_version: Bound::Unbounded,
extra_args: vec![],
print_system_cflags: true,
print_system_libs: true,
cargo_metadata: true,
env_metadata: false,
Expand Down Expand Up @@ -292,6 +294,15 @@ impl Config {
self
}

/// Enable or disable the `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS` environment
/// variable.
///
/// This env var is enabled by default.
pub fn print_system_cflags(&mut self, print: bool) -> &mut Config {
self.print_system_cflags = print;
self
}

/// Deprecated in favor fo the `probe` function
#[doc(hidden)]
pub fn find(&self, name: &str) -> Result<Library, String> {
Expand Down Expand Up @@ -407,6 +418,9 @@ impl Config {
if self.print_system_libs {
cmd.env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1");
}
if self.print_system_cflags {
cmd.env("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS", "1");
}
cmd.arg(name);
match self.min_version {
Bound::Included(ref version) => {
Expand Down Expand Up @@ -459,6 +473,7 @@ impl Default for Config {
min_version: Bound::Unbounded,
max_version: Bound::Unbounded,
extra_args: vec![],
print_system_cflags: false,
print_system_libs: false,
cargo_metadata: false,
env_metadata: false,
Expand Down

0 comments on commit de90d5d

Please sign in to comment.