Skip to content

Commit 385a911

Browse files
committed
Add a fallback to pkgconf
1 parent d039d32 commit 385a911

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/lib.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,23 @@ impl Config {
477477
}
478478

479479
fn run(&self, name: &str, args: &[&str]) -> Result<Vec<u8>, Error> {
480-
let exe = self
481-
.targetted_env_var("PKG_CONFIG")
482-
.unwrap_or_else(|| OsString::from("pkg-config"));
480+
let pkg_config_exe = self.targetted_env_var("PKG_CONFIG");
481+
let fallback_exe = if pkg_config_exe.is_none() {
482+
Some(OsString::from("pkgconf"))
483+
} else {
484+
None
485+
};
486+
let exe = pkg_config_exe.unwrap_or_else(|| OsString::from("pkg-config"));
483487

484488
let mut cmd = self.command(exe, name, args);
485-
match cmd.output() {
489+
490+
match cmd.output().or_else(|e| {
491+
if let Some(exe) = fallback_exe {
492+
self.command(exe, name, args).output()
493+
} else {
494+
Err(e)
495+
}
496+
}) {
486497
Ok(output) => {
487498
if output.status.success() {
488499
Ok(output.stdout)

0 commit comments

Comments
 (0)