From 75ff72661eef5a4943dafc4962bc4f439db1ec10 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 29 Oct 2022 23:57:06 +0100 Subject: [PATCH] Support `PKG_CONFIG_PATH_FOR_BUILD` env var Fix #139 --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e9395be..60f6dd3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -443,12 +443,14 @@ impl Config { fn targetted_env_var(&self, var_base: &str) -> Option { match (env::var("TARGET"), env::var("HOST")) { (Ok(target), Ok(host)) => { - let kind = if host == target { "HOST" } else { "TARGET" }; + let kind_suffix = if host == target { "_FOR_BUILD" } else { "" }; + let kind_prefix = if host == target { "HOST" } else { "TARGET" }; let target_u = target.replace("-", "_"); self.env_var_os(&format!("{}_{}", var_base, target)) .or_else(|| self.env_var_os(&format!("{}_{}", var_base, target_u))) - .or_else(|| self.env_var_os(&format!("{}_{}", kind, var_base))) + .or_else(|| self.env_var_os(&format!("{}_{}", var_base, kind_suffix))) + .or_else(|| self.env_var_os(&format!("{}_{}", kind_prefix, var_base))) .or_else(|| self.env_var_os(var_base)) } (Err(env::VarError::NotPresent), _) | (_, Err(env::VarError::NotPresent)) => {