Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/cargo/util/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,16 @@ fn normalize(lib: Option<&[TomlLibTarget]>,
}

fn lib_targets(dst: &mut Vec<Target>, libs: &[TomlLibTarget]) {
let l = &libs[0];
let path = l.path.clone().unwrap_or_else(|| format!("src/{}.rs", l.name));
let crate_types = l.crate_type.clone().and_then(|kinds| {
LibKind::from_strs(kinds).ok()
}).unwrap_or_else(|| vec!(Lib));

for profile in target_profiles(l).iter() {
dst.push(Target::lib_target(l.name.as_slice(), crate_types.clone(),
&Path::new(path.as_slice()), profile));
for l in libs.iter() {
let path = l.path.clone().unwrap_or_else(|| format!("src/{}.rs", l.name));
let crate_types = l.crate_type.clone().and_then(|kinds| {
LibKind::from_strs(kinds).ok()
}).unwrap_or_else(|| vec!(Lib));

for profile in target_profiles(l).iter() {
dst.push(Target::lib_target(l.name.as_slice(), crate_types.clone(),
&Path::new(path.as_slice()), profile));
}
}
}

Expand Down
44 changes: 44 additions & 0 deletions tests/test_cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,3 +559,47 @@ test!(many_crate_types {
assert!(file0.ends_with(os::consts::DLL_SUFFIX) ||
file1.ends_with(os::consts::DLL_SUFFIX));
})

test!(multiple_libs {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
[project]

name = "foo"
version = "0.5.0"
authors = ["[email protected]"]

[[lib]]

name = "foofoofoo"

[[lib]]

name = "barbarbar"
"#)
.file("src/foofoofoo.rs", r#"
pub fn foo() {}
"#)
.file("src/barbarbar.rs", r#"
pub fn bar() {}
"#);

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

let files = fs::readdir(&p.root().join("target")).assert();
let mut files: Vec<String> = files.iter().filter_map(|f| {
match f.filename_str().unwrap() {
"deps" => None,
s if s.contains("fingerprint") => None,
s => Some(s.to_str())
}
}).collect();
files.sort();
let file0 = files.get(0).as_slice();
let file1 = files.get(1).as_slice();
println!("{} {}", file0, file1);
assert!(file0.contains("barbarbar"));
assert!(file1.contains("foofoofoo"));
})