]> git.proxmox.com Git - rustc.git/blob - src/bootstrap/lib.rs
Imported Upstream version 1.10.0+dfsg1
[rustc.git] / src / bootstrap / lib.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! A small helper library shared between the build system's executables
12 //!
13 //! Currently this just has some simple utilities for modifying the dynamic
14 //! library lookup path.
15
16 use std::env;
17 use std::ffi::OsString;
18 use std::path::PathBuf;
19
20 /// Returns the environment variable which the dynamic library lookup path
21 /// resides in for this platform.
22 pub fn dylib_path_var() -> &'static str {
23 if cfg!(target_os = "windows") {
24 "PATH"
25 } else if cfg!(target_os = "macos") {
26 "DYLD_LIBRARY_PATH"
27 } else {
28 "LD_LIBRARY_PATH"
29 }
30 }
31
32 /// Parses the `dylib_path_var()` environment variable, returning a list of
33 /// paths that are members of this lookup path.
34 pub fn dylib_path() -> Vec<PathBuf> {
35 env::split_paths(&env::var_os(dylib_path_var()).unwrap_or(OsString::new()))
36 .collect()
37 }