Skip to content

Commit

Permalink
Auto merge of #3478 - alexcrichton:lift, r=brson
Browse files Browse the repository at this point in the history
Lift up workspace rlibs while building

I think the condition here was slightly off from before, so invert it subtly to
get what we want, lifting up anything in a workspace or binaries otherwise.

Closes #3432
  • Loading branch information
bors committed Jan 12, 2017
2 parents d12cc03 + 3cbf141 commit 4b351ea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cargo/ops/cargo_rustc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {

map.insert(crate_type.to_string(), Some((prefix.to_string(), suffix.to_string())));
}

let cfg = if has_cfg {
Some(try!(lines.map(Cfg::from_str).collect()))
} else {
Expand Down Expand Up @@ -455,7 +455,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
// we don't want to link it up.
if src_dir.ends_with("deps") {
// Don't lift up library dependencies
if self.ws.members().find(|&p| p != unit.pkg).is_some() && !unit.target.is_bin() {
if self.ws.members().find(|&p| p == unit.pkg).is_none() &&
!unit.target.is_bin() {
None
} else {
Some((
Expand Down
31 changes: 31 additions & 0 deletions tests/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,3 +979,34 @@ location searched: [..]
version required: *
"));
}

#[test]
fn workspace_produces_rlib() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "top"
version = "0.5.0"
authors = []
[workspace]
[dependencies]
foo = { path = "foo" }
"#)
.file("src/lib.rs", "")
.file("foo/Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = []
"#)
.file("foo/src/lib.rs", "");
p.build();

assert_that(p.cargo("build"), execs().with_status(0));

assert_that(&p.root().join("target/debug/libtop.rlib"), existing_file());
assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());

}

0 comments on commit 4b351ea

Please sign in to comment.