Skip to content

Commit 4b351ea

Browse files
committed
Auto merge of #3478 - alexcrichton:lift, r=brson
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
2 parents d12cc03 + 3cbf141 commit 4b351ea

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
231231

232232
map.insert(crate_type.to_string(), Some((prefix.to_string(), suffix.to_string())));
233233
}
234-
234+
235235
let cfg = if has_cfg {
236236
Some(try!(lines.map(Cfg::from_str).collect()))
237237
} else {
@@ -455,7 +455,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
455455
// we don't want to link it up.
456456
if src_dir.ends_with("deps") {
457457
// Don't lift up library dependencies
458-
if self.ws.members().find(|&p| p != unit.pkg).is_some() && !unit.target.is_bin() {
458+
if self.ws.members().find(|&p| p == unit.pkg).is_none() &&
459+
!unit.target.is_bin() {
459460
None
460461
} else {
461462
Some((

tests/path.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,34 @@ location searched: [..]
979979
version required: *
980980
"));
981981
}
982+
983+
#[test]
984+
fn workspace_produces_rlib() {
985+
let p = project("foo")
986+
.file("Cargo.toml", r#"
987+
[project]
988+
name = "top"
989+
version = "0.5.0"
990+
authors = []
991+
992+
[workspace]
993+
994+
[dependencies]
995+
foo = { path = "foo" }
996+
"#)
997+
.file("src/lib.rs", "")
998+
.file("foo/Cargo.toml", r#"
999+
[project]
1000+
name = "foo"
1001+
version = "0.5.0"
1002+
authors = []
1003+
"#)
1004+
.file("foo/src/lib.rs", "");
1005+
p.build();
1006+
1007+
assert_that(p.cargo("build"), execs().with_status(0));
1008+
1009+
assert_that(&p.root().join("target/debug/libtop.rlib"), existing_file());
1010+
assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());
1011+
1012+
}

0 commit comments

Comments
 (0)