Skip to content

Commit

Permalink
Enable binary crates as dependencies
Browse files Browse the repository at this point in the history
This is useful in a variety of situations such as:
  * Embedding one binary into another (i.e. BIOS, kernel)
  * Testing using a third-party utility (i.e. nc)

Fixes rust-lang#4316.
  • Loading branch information
npmccallum committed Jan 24, 2020
1 parent 6de33f0 commit ab47de9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/unit_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ fn compute_deps<'a, 'cfg>(
Some(pkg) => pkg,
None => continue,
};
let lib = match pkg.targets().iter().find(|t| t.is_lib()) {
let lib = match pkg.targets().iter().find(|t| t.is_lib() || t.is_bin()) {
Some(t) => t,
None => continue,
};
Expand Down
6 changes: 5 additions & 1 deletion tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2194,6 +2194,8 @@ fn rebuild_preserves_out_dir() {

#[cargo_test]
fn dep_no_libs() {
let exe_name = format!("bar{}", env::consts::EXE_SUFFIX);

let foo = project()
.file(
"Cargo.toml",
Expand All @@ -2209,9 +2211,11 @@ fn dep_no_libs() {
)
.file("src/lib.rs", "pub fn bar() -> i32 { 1 }")
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.0"))
.file("bar/src/main.rs", "")
.file("bar/src/main.rs", "fn main() {}")
.build();

foo.cargo("build").run();
assert!(foo.target_debug_dir().join(exe_name).exists());
}

#[cargo_test]
Expand Down

0 comments on commit ab47de9

Please sign in to comment.