Skip to content

Commit aa16a12

Browse files
committed
auto merge of #919 : alexcrichton/cargo/issue-915, r=brson
Like the old build command, this commit adds support for executables run by cargo (and tests) to ensure that `-L` paths for a dynamic library are added to LD_LIBRARY_PATH after a compilation is run. Closes #915
2 parents 515f371 + 1de84a8 commit aa16a12

File tree

1 file changed

+11
-1
lines changed
  • src/cargo/ops/cargo_rustc

1 file changed

+11
-1
lines changed

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,18 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
148148
// Now that we've figured out everything that we're going to do, do it!
149149
try!(queue.execute(cx.config));
150150

151-
let out_dir = cx.layout(pkg, Kind::Target).build_out(pkg).display().to_string();
151+
let out_dir = cx.layout(pkg, Kind::Target).build_out(pkg)
152+
.display().to_string();
152153
cx.compilation.extra_env.insert("OUT_DIR".to_string(), Some(out_dir));
154+
for (&(ref pkg, _), output) in cx.build_state.outputs.lock().iter() {
155+
let any_dylib = output.library_links.iter().any(|l| {
156+
!l.ends_with(":static") && !l.ends_with(":framework")
157+
});
158+
if !any_dylib { continue }
159+
for dir in output.library_paths.iter() {
160+
cx.compilation.native_dirs.insert(pkg.clone(), dir.clone());
161+
}
162+
}
153163
Ok(cx.compilation)
154164
}
155165

0 commit comments

Comments
 (0)