Skip to content

Commit

Permalink
Auto merge of #6300 - ehuss:out-dir-custom-build, r=alexcrichton
Browse files Browse the repository at this point in the history
Don't include build scripts in --out-dir.

As I understand the `--out-dir` use cases, these shouldn't be needed.

Closes #6282
  • Loading branch information
bors committed Nov 12, 2018
2 parents ab59c81 + 27e6b18 commit fba31ec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,13 @@ fn link_targets<'a, 'cfg>(
destinations.push(dst.display().to_string());
hardlink_or_copy(src, dst)?;
if let Some(ref path) = export_dir {
if !path.exists() {
fs::create_dir_all(path)?;
}
if !target.is_custom_build() {
if !path.exists() {
fs::create_dir_all(path)?;
}

hardlink_or_copy(src, &path.join(dst.file_name().unwrap()))?;
hardlink_or_copy(src, &path.join(dst.file_name().unwrap()))?;
}
}
}

Expand Down
31 changes: 31 additions & 0 deletions tests/testsuite/out_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,37 @@ fn replaces_artifacts() {
.run();
}

#[test]
fn avoid_build_scripts() {
let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["a", "b"]
"#,
)
.file("a/Cargo.toml", &basic_manifest("a", "0.0.1"))
.file("a/src/main.rs", "fn main() {}")
.file("a/build.rs", r#"fn main() { println!("hello-build-a"); }"#)
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1"))
.file("b/src/main.rs", "fn main() {}")
.file("b/build.rs", r#"fn main() { println!("hello-build-b"); }"#)
.build();

p.cargo("build -Z unstable-options --out-dir out -vv")
.masquerade_as_nightly_cargo()
.with_stdout_contains("[a 0.0.1] hello-build-a")
.with_stdout_contains("[b 0.0.1] hello-build-b")
.run();
check_dir_contents(
&p.root().join("out"),
&["a", "b"],
&["a", "a.dSYM", "b", "b.dSYM"],
&["a.exe", "a.pdb", "b.exe", "b.pdb"],
);
}

fn check_dir_contents(
out_dir: &Path,
expected_linux: &[&str],
Expand Down

0 comments on commit fba31ec

Please sign in to comment.