Skip to content

Commit

Permalink
Auto merge of #6255 - evq:tweak-build-dir, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Nov 25, 2018
2 parents ad23924 + a1f241a commit 99bea3b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/cargo/core/compiler/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,20 @@ impl Layout {
/// adding the target triple and the profile (debug, release, ...).
pub fn new(ws: &Workspace, triple: Option<&str>, dest: &str) -> CargoResult<Layout> {
let mut path = ws.target_dir();
// Flexible target specifications often point at filenames, so interpret
// Flexible target specifications often point at json files, so interpret
// the target triple as a Path and then just use the file stem as the
// component for the directory name.
// component for the directory name in that case.
if let Some(triple) = triple {
path.push(Path::new(triple)
.file_stem()
.ok_or_else(|| format_err!("invalid target"))?);
let triple = Path::new(triple);
if triple.extension().and_then(|s| s.to_str()) == Some("json") {
path.push(
triple
.file_stem()
.ok_or_else(|| format_err!("invalid target"))?,
);
} else {
path.push(triple);
}
}
path.push(dest);
Layout::at(ws.config(), path)
Expand Down

0 comments on commit 99bea3b

Please sign in to comment.