diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-01-05 16:03:28 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-01-05 16:03:31 -0800 |
| commit | e746ed68809c68ae32e5864b5aded37564a38f27 (patch) | |
| tree | 20f17429d54ef3875415405bcc258ca894b1084a /src/comp | |
| parent | 54cf0e9c0d1151f82e86cab5488162bd7e0706a2 (diff) | |
| download | rust-e746ed68809c68ae32e5864b5aded37564a38f27.tar.gz rust-e746ed68809c68ae32e5864b5aded37564a38f27.zip | |
rustc: Add cargo's lib directory to search paths
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/util/filesearch.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/comp/util/filesearch.rs b/src/comp/util/filesearch.rs index ce8a1d7fde0..e4ac615d973 100644 --- a/src/comp/util/filesearch.rs +++ b/src/comp/util/filesearch.rs @@ -6,6 +6,8 @@ import core::option; import std::fs; import vec; import std::os; +import result; +import std::generic_os; export filesearch; export mk_filesearch; @@ -13,6 +15,7 @@ export pick; export pick_file; export search; export relative_target_lib_path; +export get_cargo_root; type pick<T> = block(path: fs::path) -> option::t<T>; @@ -38,6 +41,10 @@ fn mk_filesearch(maybe_sysroot: option::t<fs::path>, fn lib_search_paths() -> [fs::path] { addl_lib_search_paths + [make_target_lib_path(sysroot, target_triple)] + + alt get_cargo_lib_path() { + result::ok(p) { [p] } + result::err(p) { [] } + } } fn get_target_lib_path() -> fs::path { @@ -99,3 +106,21 @@ fn get_sysroot(maybe_sysroot: option::t<fs::path>) -> fs::path { option::none. { get_default_sysroot() } } } + +fn get_cargo_root() -> result::t<fs::path, str> { + alt generic_os::getenv("CARGO_ROOT") { + some(_p) { result::ok(_p) } + none. { + alt generic_os::getenv("HOME") { + some(_q) { result::ok(fs::connect(_q, ".cargo")) } + none. { result::err("no CARGO_ROOT or HOME") } + } + } + } +} + +fn get_cargo_lib_path() -> result::t<fs::path, str> { + result::chain(get_cargo_root()) { |p| + result::ok(fs::connect(p, "lib")) + } +} \ No newline at end of file |
