about summary refs log tree commit diff
path: root/compiler/rustc_driver/src
diff options
context:
space:
mode:
authorTor Hovland <tor.hovland@bekk.no>2021-11-02 22:41:34 +0100
committerTor Hovland <tor.hovland@bekk.no>2021-11-02 22:41:34 +0100
commit5d1e09f44ab0bd3ca29acf44d92e884ec140d00a (patch)
tree57ecc54c99e43c3668a72ad77b3d7cb8937cd15c /compiler/rustc_driver/src
parent18bc4bee9710b181b440a472635150f0d6257713 (diff)
downloadrust-5d1e09f44ab0bd3ca29acf44d92e884ec140d00a.tar.gz
rust-5d1e09f44ab0bd3ca29acf44d92e884ec140d00a.zip
Added the --temps-dir option.
Diffstat (limited to 'compiler/rustc_driver/src')
-rw-r--r--compiler/rustc_driver/src/lib.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs
index 9a57ec99144..6b3c65dd527 100644
--- a/compiler/rustc_driver/src/lib.rs
+++ b/compiler/rustc_driver/src/lib.rs
@@ -215,6 +215,7 @@ fn run_compiler(
 
     let cfg = interface::parse_cfgspecs(matches.opt_strs("cfg"));
     let (odir, ofile) = make_output(&matches);
+    let temps_dir = make_temps_dir(&matches);
     let mut config = interface::Config {
         opts: sopts,
         crate_cfg: cfg,
@@ -222,6 +223,7 @@ fn run_compiler(
         input_path: None,
         output_file: ofile,
         output_dir: odir,
+        temps_dir,
         file_loader,
         diagnostic_output,
         stderr: None,
@@ -267,6 +269,7 @@ fn run_compiler(
                         None,
                         compiler.output_dir(),
                         compiler.output_file(),
+                        compiler.temps_dir(),
                     );
 
                     if should_stop == Compilation::Stop {
@@ -295,6 +298,7 @@ fn run_compiler(
             Some(compiler.input()),
             compiler.output_dir(),
             compiler.output_file(),
+            compiler.temps_dir(),
         )
         .and_then(|| {
             RustcDefaultCalls::list_metadata(
@@ -454,6 +458,11 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>)
     (odir, ofile)
 }
 
+// Extract temporary directory from matches.
+fn make_temps_dir(matches: &getopts::Matches) -> Option<PathBuf> {
+    matches.opt_str("temps-dir").map(|o| PathBuf::from(&o))
+}
+
 // Extract input (string or file and optional path) from matches.
 fn make_input(
     error_format: ErrorOutputType,
@@ -647,6 +656,7 @@ impl RustcDefaultCalls {
         input: Option<&Input>,
         odir: &Option<PathBuf>,
         ofile: &Option<PathBuf>,
+        temps_dir: &Option<PathBuf>,
     ) -> Compilation {
         use rustc_session::config::PrintRequest::*;
         // PrintRequest::NativeStaticLibs is special - printed during linking
@@ -685,7 +695,7 @@ impl RustcDefaultCalls {
                     });
                     let attrs = attrs.as_ref().unwrap();
                     let t_outputs = rustc_interface::util::build_output_filenames(
-                        input, odir, ofile, attrs, sess,
+                        input, odir, ofile, temps_dir, attrs, sess,
                     );
                     let id = rustc_session::output::find_crate_name(sess, attrs, input);
                     if *req == PrintRequest::CrateName {