Skip to content

Commit

Permalink
Merge pull request #145 from lu-zero/pkgconf-fallback
Browse files Browse the repository at this point in the history
Pkgconf fallback
  • Loading branch information
sdroege committed May 3, 2023
2 parents d039d32 + 385a911 commit a305d77
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/lib.rs
Expand Up @@ -477,12 +477,23 @@ impl Config {
}

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

let mut cmd = self.command(exe, name, args);
match cmd.output() {

match cmd.output().or_else(|e| {
if let Some(exe) = fallback_exe {
self.command(exe, name, args).output()
} else {
Err(e)
}
}) {
Ok(output) => {
if output.status.success() {
Ok(output.stdout)
Expand Down

0 comments on commit a305d77

Please sign in to comment.