]> git.lizzy.rs Git - rust.git/commitdiff
save-analysis: make the dump file's name closer to the crate file's name
authorNick Cameron <ncameron@mozilla.com>
Fri, 20 Nov 2015 02:00:10 +0000 (15:00 +1300)
committerNick Cameron <ncameron@mozilla.com>
Fri, 20 Nov 2015 02:44:53 +0000 (15:44 +1300)
src/librustc_trans/save/mod.rs

index af9f3e4896d2c8b3cbacf9323bbb73d6a5259972..53f2d93c3f1a8fca594e59b8d4fc27a8cbfc5a1f 100644 (file)
@@ -17,8 +17,9 @@
 use std::path::{Path, PathBuf};
 
 use rustc_front;
-use rustc::front::map::NodeItem;
 use rustc_front::{hir, lowering};
+use rustc::front::map::NodeItem;
+use rustc::session::config::CrateType::CrateTypeExecutable;
 
 use syntax::ast::{self, NodeId};
 use syntax::ast_util;
@@ -744,7 +745,14 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>,
     }
 
     // Create output file.
-    let mut out_name = cratename.to_owned();
+    let executable = tcx.sess.crate_types.borrow().iter().any(|ct| *ct == CrateTypeExecutable);
+    let mut out_name = if executable {
+        "".to_owned()
+    } else {
+        "lib".to_owned()
+    };
+    out_name.push_str(&cratename);
+    out_name.push_str(&tcx.sess.opts.cg.extra_filename);
     out_name.push_str(".csv");
     root_path.push(&out_name);
     let output_file = match File::create(&root_path) {