Skip to content

Commit fba31ec

Browse files
committed
Auto merge of #6300 - ehuss:out-dir-custom-build, r=alexcrichton
Don't include build scripts in --out-dir. As I understand the `--out-dir` use cases, these shouldn't be needed. Closes #6282
2 parents ab59c81 + 27e6b18 commit fba31ec

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,13 @@ fn link_targets<'a, 'cfg>(
437437
destinations.push(dst.display().to_string());
438438
hardlink_or_copy(src, dst)?;
439439
if let Some(ref path) = export_dir {
440-
if !path.exists() {
441-
fs::create_dir_all(path)?;
442-
}
440+
if !target.is_custom_build() {
441+
if !path.exists() {
442+
fs::create_dir_all(path)?;
443+
}
443444

444-
hardlink_or_copy(src, &path.join(dst.file_name().unwrap()))?;
445+
hardlink_or_copy(src, &path.join(dst.file_name().unwrap()))?;
446+
}
445447
}
446448
}
447449

tests/testsuite/out_dir.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,37 @@ fn replaces_artifacts() {
203203
.run();
204204
}
205205

206+
#[test]
207+
fn avoid_build_scripts() {
208+
let p = project()
209+
.file(
210+
"Cargo.toml",
211+
r#"
212+
[workspace]
213+
members = ["a", "b"]
214+
"#,
215+
)
216+
.file("a/Cargo.toml", &basic_manifest("a", "0.0.1"))
217+
.file("a/src/main.rs", "fn main() {}")
218+
.file("a/build.rs", r#"fn main() { println!("hello-build-a"); }"#)
219+
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1"))
220+
.file("b/src/main.rs", "fn main() {}")
221+
.file("b/build.rs", r#"fn main() { println!("hello-build-b"); }"#)
222+
.build();
223+
224+
p.cargo("build -Z unstable-options --out-dir out -vv")
225+
.masquerade_as_nightly_cargo()
226+
.with_stdout_contains("[a 0.0.1] hello-build-a")
227+
.with_stdout_contains("[b 0.0.1] hello-build-b")
228+
.run();
229+
check_dir_contents(
230+
&p.root().join("out"),
231+
&["a", "b"],
232+
&["a", "a.dSYM", "b", "b.dSYM"],
233+
&["a.exe", "a.pdb", "b.exe", "b.pdb"],
234+
);
235+
}
236+
206237
fn check_dir_contents(
207238
out_dir: &Path,
208239
expected_linux: &[&str],

0 commit comments

Comments
 (0)