From: Alex Crichton Date: Fri, 30 Dec 2016 18:50:39 +0000 (-0800) Subject: Lift up workspace rlibs while building X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~11^2~40^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3cbf141b5095b95a752f51574151b91fd7fddd1e;p=cargo.git 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 --- diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index a5a16b479..471f8ff37 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -224,7 +224,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 { @@ -448,7 +448,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(( diff --git a/tests/path.rs b/tests/path.rs index ab9d91bc8..082003b3b 100644 --- a/tests/path.rs +++ b/tests/path.rs @@ -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()); + +}