Skip to content

Commit

Permalink
Merge pull request #235 from jorendorff/dev
Browse files Browse the repository at this point in the history
Handle missing or empty DYLD_LIBRARY_PATH on Mac. Fixes #233.
  • Loading branch information
Manishearth committed Mar 4, 2021
2 parents 77df2f4 + b1b405b commit bc2ff25
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/common.rs
Expand Up @@ -275,15 +275,18 @@ impl Config {

// Dependencies can be found in the environment variable. Throw everything there into the
// link flags
let lib_paths = env::var(varname).unwrap_or_else(|e| {
panic!("Cannot link to dependencies. Problem with env var '{}': {:?}", varname, e)
let lib_paths = env::var(varname).unwrap_or_else(|err| match err {
env::VarError::NotPresent => String::new(),
err => panic!("can't get {} environment variable: {}", varname, err),
});

// Append to current flags if any are set, otherwise make new String
let mut flags = self.target_rustcflags.take().unwrap_or_else(String::new);
for p in env::split_paths(&lib_paths) {
flags += " -L ";
flags += p.to_str().unwrap(); // Can't fail. We already know this is unicode
if !lib_paths.is_empty() {
for p in env::split_paths(&lib_paths) {
flags += " -L ";
flags += p.to_str().unwrap(); // Can't fail. We already know this is unicode
}
}

self.target_rustcflags = Some(flags);
Expand Down

0 comments on commit bc2ff25

Please sign in to comment.