Skip to content

Commit d184e48

Browse files
committed
Add an option to disable PKG_CONFIG_ALLOW_SYSTEM_LIBS
1 parent e9297b2 commit d184e48

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/lib.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub struct Config {
9393
atleast_version: Option<String>,
9494
extra_args: Vec<OsString>,
9595
cargo_metadata: bool,
96+
print_system_libs: bool,
9697
}
9798

9899
#[derive(Debug)]
@@ -274,6 +275,7 @@ impl Config {
274275
statik: None,
275276
atleast_version: None,
276277
extra_args: vec![],
278+
print_system_libs: true,
277279
cargo_metadata: true,
278280
}
279281
}
@@ -308,6 +310,15 @@ impl Config {
308310
self
309311
}
310312

313+
/// Enable or disable the `PKG_CONFIG_ALLOW_SYSTEM_LIBS` environment
314+
/// variable.
315+
///
316+
/// This env var is enabled by default.
317+
pub fn print_system_libs(&mut self, print: bool) -> &mut Config {
318+
self.print_system_libs = print;
319+
self
320+
}
321+
311322
/// Deprecated in favor fo the `probe` function
312323
#[doc(hidden)]
313324
pub fn find(&self, name: &str) -> Result<Library, String> {
@@ -359,8 +370,11 @@ impl Config {
359370
cmd.arg("--static");
360371
}
361372
cmd.args(args)
362-
.args(&self.extra_args)
363-
.env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1");
373+
.args(&self.extra_args);
374+
375+
if self.print_system_libs {
376+
cmd.env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1");
377+
}
364378
if let Some(ref version) = self.atleast_version {
365379
cmd.arg(&format!("{} >= {}", name, version));
366380
} else {

0 commit comments

Comments
 (0)