Skip to content

Commit 99bea3b

Browse files
committed
Auto merge of #6255 - evq:tweak-build-dir, r=alexcrichton
Tweak Layout to allow for non json file targets with internal "." Per @alexcrichton 's comment in rust-lang/rust#55041 (comment), currently cargo assumes that a target with an internal `.` is a custom json target spec, using the file stem for the build directory name. This PR changes cargo to only use the file stem for files with a `json` extension.
2 parents ad23924 + a1f241a commit 99bea3b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Diff for: src/cargo/core/compiler/layout.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,20 @@ impl Layout {
8686
/// adding the target triple and the profile (debug, release, ...).
8787
pub fn new(ws: &Workspace, triple: Option<&str>, dest: &str) -> CargoResult<Layout> {
8888
let mut path = ws.target_dir();
89-
// Flexible target specifications often point at filenames, so interpret
89+
// Flexible target specifications often point at json files, so interpret
9090
// the target triple as a Path and then just use the file stem as the
91-
// component for the directory name.
91+
// component for the directory name in that case.
9292
if let Some(triple) = triple {
93-
path.push(Path::new(triple)
94-
.file_stem()
95-
.ok_or_else(|| format_err!("invalid target"))?);
93+
let triple = Path::new(triple);
94+
if triple.extension().and_then(|s| s.to_str()) == Some("json") {
95+
path.push(
96+
triple
97+
.file_stem()
98+
.ok_or_else(|| format_err!("invalid target"))?,
99+
);
100+
} else {
101+
path.push(triple);
102+
}
96103
}
97104
path.push(dest);
98105
Layout::at(ws.config(), path)

0 commit comments

Comments
 (0)