From 5d1e09f44ab0bd3ca29acf44d92e884ec140d00a Mon Sep 17 00:00:00 2001 From: Tor Hovland Date: Tue, 2 Nov 2021 22:41:34 +0100 Subject: Added the --temps-dir option. --- compiler/rustc_driver/src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_driver/src') 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, Option) (odir, ofile) } +// Extract temporary directory from matches. +fn make_temps_dir(matches: &getopts::Matches) -> Option { + 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, ofile: &Option, + temps_dir: &Option, ) -> 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 { -- cgit 1.4.1-3-g733a5