Skip to content

Commit

Permalink
Support PKG_CONFIG_PATH_FOR_BUILD env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 authored Oct 29, 2022
1 parent 947aea5 commit 75ff726
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,14 @@ impl Config {
fn targetted_env_var(&self, var_base: &str) -> Option<OsString> {
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)) => {
Expand Down

0 comments on commit 75ff726

Please sign in to comment.