2012-03-12 22:04:27 -05:00
|
|
|
import std::map;
|
2012-03-07 18:48:57 -06:00
|
|
|
import std::map::hashmap;
|
2011-10-04 17:23:32 -05:00
|
|
|
import metadata::cstore;
|
|
|
|
import driver::session;
|
2012-05-29 22:38:46 -05:00
|
|
|
import metadata::filesearch;
|
2011-10-04 17:23:32 -05:00
|
|
|
|
2012-01-05 20:23:28 -06:00
|
|
|
export get_rpath_flags;
|
2011-10-04 17:23:32 -05:00
|
|
|
|
2012-01-30 23:00:57 -06:00
|
|
|
pure fn not_win32(os: session::os) -> bool {
|
|
|
|
alt os {
|
|
|
|
session::os_win32 { false }
|
|
|
|
_ { true }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn get_rpath_flags(sess: session::session, out_filename: ~str) -> ~[~str] {
|
2012-01-12 10:59:49 -06:00
|
|
|
let os = sess.targ_cfg.os;
|
2011-10-06 16:28:52 -05:00
|
|
|
|
2011-10-06 15:11:56 -05:00
|
|
|
// No rpath on windows
|
2011-10-06 16:28:52 -05:00
|
|
|
if os == session::os_win32 {
|
2012-06-29 18:26:56 -05:00
|
|
|
ret ~[];
|
2011-10-06 15:11:56 -05:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{"preparing the RPATH!"};
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
let cwd = os::getcwd();
|
2012-01-12 10:59:49 -06:00
|
|
|
let sysroot = sess.filesearch.sysroot();
|
2011-10-04 17:23:32 -05:00
|
|
|
let output = out_filename;
|
2012-01-12 10:59:49 -06:00
|
|
|
let libs = cstore::get_used_crate_files(sess.cstore);
|
2012-07-03 18:11:00 -05:00
|
|
|
// We don't currently rpath extern libraries, but we know
|
2011-10-05 01:12:46 -05:00
|
|
|
// where rustrt is and we know every rust program needs it
|
2012-06-28 17:00:03 -05:00
|
|
|
let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));
|
2011-10-05 01:12:46 -05:00
|
|
|
|
2012-01-12 10:59:49 -06:00
|
|
|
let target_triple = sess.opts.target_triple;
|
2011-10-06 16:28:52 -05:00
|
|
|
let rpaths = get_rpaths(os, cwd, sysroot, output, libs, target_triple);
|
2011-10-05 01:36:06 -05:00
|
|
|
rpaths_to_flags(rpaths)
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:04:27 -05:00
|
|
|
fn get_sysroot_absolute_rt_lib(sess: session::session) -> path::path {
|
2012-06-29 18:26:56 -05:00
|
|
|
let mut path = vec::append(~[sess.filesearch.sysroot()],
|
2012-06-28 17:00:03 -05:00
|
|
|
filesearch::relative_target_lib_path(
|
|
|
|
sess.opts.target_triple));
|
2012-07-14 00:57:48 -05:00
|
|
|
vec::push(path, os::dll_filename(~"rustrt"));
|
2012-03-12 22:04:27 -05:00
|
|
|
path::connect_many(path)
|
2011-10-05 01:12:46 -05:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn rpaths_to_flags(rpaths: ~[~str]) -> ~[~str] {
|
2012-07-30 18:01:07 -05:00
|
|
|
vec::map(rpaths, |rpath| fmt!{"-Wl,-rpath,%s",rpath} )
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:04:27 -05:00
|
|
|
fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path,
|
2012-06-29 18:26:56 -05:00
|
|
|
output: path::path, libs: ~[path::path],
|
2012-07-14 00:57:48 -05:00
|
|
|
target_triple: ~str) -> ~[~str] {
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{"cwd: %s", cwd};
|
|
|
|
debug!{"sysroot: %s", sysroot};
|
|
|
|
debug!{"output: %s", output};
|
|
|
|
debug!{"libs:"};
|
2012-06-30 18:19:07 -05:00
|
|
|
for libs.each |libpath| {
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{" %s", libpath};
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{"target_triple: %s", target_triple};
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
// Use relative paths to the libraries. Binaries can be moved
|
|
|
|
// as long as they maintain the relative relationship to the
|
|
|
|
// crates they depend on.
|
2011-10-06 16:28:52 -05:00
|
|
|
let rel_rpaths = get_rpaths_relative_to_output(os, cwd, output, libs);
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
// Make backup absolute paths to the libraries. Binaries can
|
|
|
|
// be moved as long as the crates they link against don't move.
|
2011-10-05 00:40:38 -05:00
|
|
|
let abs_rpaths = get_absolute_rpaths(cwd, libs);
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
// And a final backup rpath to the global library location.
|
2012-06-29 18:26:56 -05:00
|
|
|
let fallback_rpaths = ~[get_install_prefix_rpath(cwd, target_triple)];
|
2011-10-05 00:40:38 -05:00
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn log_rpaths(desc: ~str, rpaths: ~[~str]) {
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{"%s rpaths:", desc};
|
2012-06-30 18:19:07 -05:00
|
|
|
for rpaths.each |rpath| {
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{" %s", rpath};
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
log_rpaths(~"relative", rel_rpaths);
|
|
|
|
log_rpaths(~"absolute", abs_rpaths);
|
|
|
|
log_rpaths(~"fallback", fallback_rpaths);
|
2011-10-05 00:40:38 -05:00
|
|
|
|
2012-06-28 17:00:03 -05:00
|
|
|
let mut rpaths = rel_rpaths;
|
|
|
|
vec::push_all(rpaths, abs_rpaths);
|
|
|
|
vec::push_all(rpaths, fallback_rpaths);
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
// Remove duplicates
|
|
|
|
let rpaths = minimize_rpaths(rpaths);
|
|
|
|
ret rpaths;
|
|
|
|
}
|
|
|
|
|
2011-10-06 16:28:52 -05:00
|
|
|
fn get_rpaths_relative_to_output(os: session::os,
|
2012-03-12 22:04:27 -05:00
|
|
|
cwd: path::path,
|
|
|
|
output: path::path,
|
2012-07-14 00:57:48 -05:00
|
|
|
libs: ~[path::path]) -> ~[~str] {
|
2012-06-30 18:19:07 -05:00
|
|
|
vec::map(libs, |a| {
|
2012-06-19 21:34:01 -05:00
|
|
|
get_rpath_relative_to_output(os, cwd, output, a)
|
|
|
|
})
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2011-10-06 16:28:52 -05:00
|
|
|
fn get_rpath_relative_to_output(os: session::os,
|
2012-03-12 22:04:27 -05:00
|
|
|
cwd: path::path,
|
|
|
|
output: path::path,
|
2012-07-13 20:43:52 -05:00
|
|
|
&&lib: path::path) -> ~str {
|
|
|
|
assert not_win32(os);
|
|
|
|
|
2011-10-06 16:28:52 -05:00
|
|
|
// Mac doesn't appear to support $ORIGIN
|
|
|
|
let prefix = alt os {
|
2012-07-14 00:57:48 -05:00
|
|
|
session::os_linux { ~"$ORIGIN" + path::path_sep() }
|
|
|
|
session::os_freebsd { ~"$ORIGIN" + path::path_sep() }
|
|
|
|
session::os_macos { ~"@executable_path" + path::path_sep() }
|
2012-03-08 16:29:17 -06:00
|
|
|
session::os_win32 { core::unreachable(); }
|
2011-10-06 16:28:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
prefix + get_relative_to(
|
2011-10-04 17:23:32 -05:00
|
|
|
get_absolute(cwd, output),
|
2011-10-04 22:07:18 -05:00
|
|
|
get_absolute(cwd, lib))
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Find the relative path from one file to another
|
2012-03-12 22:04:27 -05:00
|
|
|
fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
|
|
|
|
assert path::path_is_absolute(abs1);
|
|
|
|
assert path::path_is_absolute(abs2);
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{"finding relative path from %s to %s",
|
|
|
|
abs1, abs2};
|
2012-03-12 22:04:27 -05:00
|
|
|
let normal1 = path::normalize(abs1);
|
|
|
|
let normal2 = path::normalize(abs2);
|
|
|
|
let split1 = path::split(normal1);
|
|
|
|
let split2 = path::split(normal2);
|
2011-10-04 22:07:18 -05:00
|
|
|
let len1 = vec::len(split1);
|
|
|
|
let len2 = vec::len(split2);
|
|
|
|
assert len1 > 0u;
|
|
|
|
assert len2 > 0u;
|
|
|
|
|
2012-03-10 19:42:53 -06:00
|
|
|
let max_common_path = uint::min(len1, len2) - 1u;
|
2012-03-15 08:47:03 -05:00
|
|
|
let mut start_idx = 0u;
|
2011-10-04 22:07:18 -05:00
|
|
|
while start_idx < max_common_path
|
|
|
|
&& split1[start_idx] == split2[start_idx] {
|
|
|
|
start_idx += 1u;
|
|
|
|
}
|
|
|
|
|
2012-06-29 18:26:56 -05:00
|
|
|
let mut path = ~[];
|
2012-07-14 00:57:48 -05:00
|
|
|
for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ~".."); };
|
2011-10-04 22:07:18 -05:00
|
|
|
|
2012-07-26 16:00:31 -05:00
|
|
|
vec::push_all(path, vec::view(split2, start_idx, len2 - 1u));
|
2011-10-04 22:07:18 -05:00
|
|
|
|
2012-07-13 20:43:52 -05:00
|
|
|
if vec::is_not_empty(path) {
|
2012-03-12 22:04:27 -05:00
|
|
|
ret path::connect_many(path);
|
2011-10-05 00:40:38 -05:00
|
|
|
} else {
|
2012-07-14 00:57:48 -05:00
|
|
|
ret ~".";
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn get_absolute_rpaths(cwd: path::path, libs: ~[path::path]) -> ~[~str] {
|
2012-06-30 18:19:07 -05:00
|
|
|
vec::map(libs, |a| get_absolute_rpath(cwd, a) )
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn get_absolute_rpath(cwd: path::path, &&lib: path::path) -> ~str {
|
2012-03-12 22:04:27 -05:00
|
|
|
path::dirname(get_absolute(cwd, lib))
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:04:27 -05:00
|
|
|
fn get_absolute(cwd: path::path, lib: path::path) -> path::path {
|
|
|
|
if path::path_is_absolute(lib) {
|
2011-10-04 17:23:32 -05:00
|
|
|
lib
|
|
|
|
} else {
|
2012-03-12 22:04:27 -05:00
|
|
|
path::connect(cwd, lib)
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn get_install_prefix_rpath(cwd: path::path, target_triple: ~str) -> ~str {
|
2012-07-30 18:01:07 -05:00
|
|
|
let install_prefix = env!{"CFG_PREFIX"};
|
2011-10-04 17:23:32 -05:00
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
if install_prefix == ~"" {
|
|
|
|
fail ~"rustc compiled without CFG_PREFIX environment variable";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2012-06-28 17:00:03 -05:00
|
|
|
let path = vec::append(
|
2012-06-29 18:26:56 -05:00
|
|
|
~[install_prefix],
|
2012-06-28 17:00:03 -05:00
|
|
|
filesearch::relative_target_lib_path(target_triple));
|
2012-03-12 22:04:27 -05:00
|
|
|
get_absolute(cwd, path::connect_many(path))
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn minimize_rpaths(rpaths: ~[~str]) -> ~[~str] {
|
2012-03-14 14:07:23 -05:00
|
|
|
let set = map::str_hash::<()>();
|
2012-06-29 18:26:56 -05:00
|
|
|
let mut minimized = ~[];
|
2012-06-30 18:19:07 -05:00
|
|
|
for rpaths.each |rpath| {
|
2011-10-05 00:40:38 -05:00
|
|
|
if !set.contains_key(rpath) {
|
2012-06-28 17:00:03 -05:00
|
|
|
vec::push(minimized, rpath);
|
2011-10-05 00:40:38 -05:00
|
|
|
set.insert(rpath, ());
|
|
|
|
}
|
|
|
|
}
|
2011-10-04 17:23:32 -05:00
|
|
|
ret minimized;
|
|
|
|
}
|
|
|
|
|
2012-06-07 23:38:25 -05:00
|
|
|
#[cfg(unix)]
|
2011-10-04 17:23:32 -05:00
|
|
|
mod test {
|
|
|
|
#[test]
|
|
|
|
fn test_rpaths_to_flags() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let flags = rpaths_to_flags(~[~"path1", ~"path2"]);
|
|
|
|
assert flags == ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"];
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_get_absolute1() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let cwd = ~"/dir";
|
|
|
|
let lib = ~"some/path/lib";
|
2011-10-04 17:23:32 -05:00
|
|
|
let res = get_absolute(cwd, lib);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"/dir/some/path/lib";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_get_absolute2() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let cwd = ~"/dir";
|
|
|
|
let lib = ~"/some/path/lib";
|
2011-10-04 17:23:32 -05:00
|
|
|
let res = get_absolute(cwd, lib);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"/some/path/lib";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_prefix_rpath() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let res = get_install_prefix_rpath(~"/usr/lib", ~"triple");
|
2012-07-30 18:01:07 -05:00
|
|
|
let d = path::connect(env!{"CFG_PREFIX"}, ~"/lib/rustc/triple/lib");
|
2012-01-09 18:11:25 -06:00
|
|
|
assert str::ends_with(res, d);
|
2011-10-06 18:12:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_prefix_rpath_abs() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let res = get_install_prefix_rpath(~"/usr/lib", ~"triple");
|
2012-03-12 22:04:27 -05:00
|
|
|
assert path::path_is_absolute(res);
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2011-10-05 00:40:38 -05:00
|
|
|
fn test_minimize1() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let res = minimize_rpaths(~[~"rpath1", ~"rpath2", ~"rpath1"]);
|
|
|
|
assert res == ~[~"rpath1", ~"rpath2"];
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2011-10-05 00:40:38 -05:00
|
|
|
#[test]
|
|
|
|
fn test_minimize2() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let res = minimize_rpaths(~[~"1a", ~"2", ~"2", ~"1a", ~"4a",
|
|
|
|
~"1a", ~"2", ~"3", ~"4a", ~"3"]);
|
|
|
|
assert res == ~[~"1a", ~"2", ~"4a", ~"3"];
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
|
|
|
|
2011-10-04 17:23:32 -05:00
|
|
|
#[test]
|
|
|
|
fn test_relative_to1() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/usr/bin/rustc";
|
|
|
|
let p2 = ~"/usr/lib/mylib";
|
2011-10-04 17:23:32 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"../lib";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_relative_to2() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/usr/bin/rustc";
|
|
|
|
let p2 = ~"/usr/bin/../lib/mylib";
|
2011-10-04 17:23:32 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"../lib";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_relative_to3() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/usr/bin/whatever/rustc";
|
|
|
|
let p2 = ~"/usr/lib/whatever/mylib";
|
2011-10-04 17:23:32 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"../../lib/whatever";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_relative_to4() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/usr/bin/whatever/../rustc";
|
|
|
|
let p2 = ~"/usr/lib/whatever/mylib";
|
2011-10-04 17:23:32 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"../lib/whatever";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_relative_to5() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/usr/bin/whatever/../rustc";
|
|
|
|
let p2 = ~"/usr/lib/whatever/../mylib";
|
2011-10-04 17:23:32 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"../lib";
|
2011-10-04 22:07:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_relative_to6() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/1";
|
|
|
|
let p2 = ~"/2/3";
|
2011-10-04 22:07:18 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"2";
|
2011-10-04 22:07:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_relative_to7() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/1/2";
|
|
|
|
let p2 = ~"/3";
|
2011-10-04 22:07:18 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~"..";
|
2011-10-04 22:07:18 -05:00
|
|
|
}
|
|
|
|
|
2011-10-05 00:40:38 -05:00
|
|
|
#[test]
|
|
|
|
fn test_relative_to8() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p1 = ~"/home/brian/Dev/rust/build/"
|
|
|
|
+ ~"stage2/lib/rustc/i686-unknown-linux-gnu/lib/librustc.so";
|
|
|
|
let p2 = ~"/home/brian/Dev/rust/build/stage2/bin/.."
|
|
|
|
+ ~"/lib/rustc/i686-unknown-linux-gnu/lib/libstd.so";
|
2011-10-05 00:40:38 -05:00
|
|
|
let res = get_relative_to(p1, p2);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert res == ~".";
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
|
|
|
|
2011-10-04 22:07:18 -05:00
|
|
|
#[test]
|
2011-10-06 16:28:52 -05:00
|
|
|
#[cfg(target_os = "linux")]
|
2011-10-04 22:07:18 -05:00
|
|
|
fn test_rpath_relative() {
|
2012-07-13 20:43:52 -05:00
|
|
|
let o = session::os_linux;
|
|
|
|
let res = get_rpath_relative_to_output(o,
|
2012-07-14 00:57:48 -05:00
|
|
|
~"/usr", ~"bin/rustc", ~"lib/libstd.so");
|
2012-07-13 20:43:52 -05:00
|
|
|
assert res == ~"$ORIGIN/../lib";
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
2011-10-05 00:40:38 -05:00
|
|
|
|
2011-12-30 02:18:55 -06:00
|
|
|
#[test]
|
|
|
|
#[cfg(target_os = "freebsd")]
|
|
|
|
fn test_rpath_relative() {
|
2012-07-14 12:27:09 -05:00
|
|
|
let o = session::os_freebsd;
|
|
|
|
let res = get_rpath_relative_to_output(o,
|
|
|
|
~"/usr", ~"bin/rustc", ~"lib/libstd.so");
|
|
|
|
assert res == ~"$ORIGIN/../lib";
|
2011-12-30 02:18:55 -06:00
|
|
|
}
|
|
|
|
|
2011-10-06 16:28:52 -05:00
|
|
|
#[test]
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
fn test_rpath_relative() {
|
2012-07-14 12:27:09 -05:00
|
|
|
// this is why refinements would be nice
|
|
|
|
let o = session::os_macos;
|
|
|
|
let res = get_rpath_relative_to_output(o, ~"/usr", ~"bin/rustc",
|
|
|
|
~"lib/libstd.so");
|
|
|
|
assert res == ~"@executable_path/../lib";
|
2011-10-06 16:28:52 -05:00
|
|
|
}
|
|
|
|
|
2011-10-05 00:40:38 -05:00
|
|
|
#[test]
|
|
|
|
fn test_get_absolute_rpath() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let res = get_absolute_rpath(~"/usr", ~"lib/libstd.so");
|
|
|
|
assert res == ~"/usr/lib";
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|