From a1f241a3c63b4f5340ee214c3f97ff57001b317f Mon Sep 17 00:00:00 2001 From: eV Date: Sat, 3 Nov 2018 07:42:32 +0000 Subject: [PATCH] Tweak Layout to allow for non json file targets with internal "." --- src/cargo/core/compiler/layout.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/compiler/layout.rs b/src/cargo/core/compiler/layout.rs index d7a3e441304..233c23d5e68 100644 --- a/src/cargo/core/compiler/layout.rs +++ b/src/cargo/core/compiler/layout.rs @@ -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 { 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)