Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PKG_CONFIG_PATH_FOR_BUILD env var #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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