Skip to content

Commit 3d6e75c

Browse files
committed
fix(layout): Put examples in their unit dir in new layout
Before, pre-uplifted examples were being written to `{build-dir}/{profile}/examples/{name}-{hash}`. Now they are being written to `{build-dir}/{profile}/build/{pkgname}/{hash}/{name}-{hash}`. This does not affect uplifted examples (they lack the `-{hash}`). Pre-build-dir, these were placed in a "public" location but I don't see a reason for that to be the case (otherwise, we'd need to switch them to `{target-dir}/{profile}/examples/{name}-{hash}`). In that case, I don't see a reason to treat examples as any different than any other artifact and going in their unique build init directory. Fixes #16302
1 parent bbb5c5b commit 3d6e75c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cargo/core/compiler/build_runner/compilation_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
220220
panic!("doc tests do not have an out dir");
221221
} else if unit.target.is_custom_build() {
222222
self.build_script_dir(unit)
223-
} else if unit.target.is_example() {
223+
} else if unit.target.is_example() && !self.ws.gctx().cli_unstable().build_dir_new_layout {
224224
self.layout(unit.kind).build_dir().examples().to_path_buf()
225225
} else if unit.artifact.is_true() {
226226
self.artifact_dir(unit)

tests/testsuite/build_dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ fn examples_should_output_to_build_dir_and_uplift_to_target_dir() {
396396
[ROOT]/foo/build-dir/debug/build/foo/[HASH]/fingerprint/example-foo
397397
[ROOT]/foo/build-dir/debug/build/foo/[HASH]/fingerprint/example-foo.json
398398
[ROOT]/foo/build-dir/debug/build/foo/[HASH]/fingerprint/invoked.timestamp
399-
[ROOT]/foo/build-dir/debug/examples/foo[..][EXE]
400-
[ROOT]/foo/build-dir/debug/examples/foo[..].d
399+
[ROOT]/foo/build-dir/debug/build/foo/[HASH]/deps/foo[..][EXE]
400+
[ROOT]/foo/build-dir/debug/build/foo/[HASH]/deps/foo[..].d
401401
402402
"#]]);
403403

0 commit comments

Comments
 (0)