]> git.proxmox.com Git - cargo.git/commitdiff
Improve experience with the flexible target specification
authorAlex Crichton <alex@alexcrichton.com>
Mon, 9 Mar 2015 16:49:33 +0000 (09:49 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 10 Mar 2015 02:43:06 +0000 (19:43 -0700)
When calculating the output directory filename, only use the "file name"
component of the target triple specified as otherwise the output could be placed
into an odd location.

Closes #1390

src/cargo/ops/cargo_rustc/layout.rs

index 1f6b2e50ec0ff2d1469f8e22d838311799229950..33ea8af692a9ee5b9e382bc89bf04f468defa6d9 100644 (file)
@@ -69,9 +69,11 @@ pub struct LayoutProxy<'a> {
 impl Layout {
     pub fn new(pkg: &Package, triple: Option<&str>, dest: &str) -> Layout {
         let mut path = pkg.absolute_target_dir();
-        match triple {
-            Some(s) => path.push(s),
-            None => {}
+        // Flexible target specifications often point at filenames, so interpret
+        // the target triple as a Path and then just use the file stem as the
+        // component for the directory name.
+        if let Some(triple) = triple {
+            path.push(Path::new(triple).file_stem().unwrap());
         }
         path.push(dest);
         Layout::at(path)