Added the --temps-dir option.
This commit is contained in:
parent
18bc4bee97
commit
5d1e09f44a
7 changed files with 49 additions and 4 deletions
|
@ -36,6 +36,7 @@ pub struct Compiler {
|
|||
pub(crate) input_path: Option<PathBuf>,
|
||||
pub(crate) output_dir: Option<PathBuf>,
|
||||
pub(crate) output_file: Option<PathBuf>,
|
||||
pub(crate) temps_dir: Option<PathBuf>,
|
||||
pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
|
||||
pub(crate) override_queries:
|
||||
Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::ExternProviders)>,
|
||||
|
@ -57,6 +58,9 @@ impl Compiler {
|
|||
pub fn output_file(&self) -> &Option<PathBuf> {
|
||||
&self.output_file
|
||||
}
|
||||
pub fn temps_dir(&self) -> &Option<PathBuf> {
|
||||
&self.temps_dir
|
||||
}
|
||||
pub fn register_lints(&self) -> &Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>> {
|
||||
&self.register_lints
|
||||
}
|
||||
|
@ -65,7 +69,14 @@ impl Compiler {
|
|||
sess: &Session,
|
||||
attrs: &[ast::Attribute],
|
||||
) -> OutputFilenames {
|
||||
util::build_output_filenames(&self.input, &self.output_dir, &self.output_file, attrs, sess)
|
||||
util::build_output_filenames(
|
||||
&self.input,
|
||||
&self.output_dir,
|
||||
&self.output_file,
|
||||
&self.temps_dir,
|
||||
attrs,
|
||||
sess,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +143,7 @@ pub struct Config {
|
|||
pub input_path: Option<PathBuf>,
|
||||
pub output_dir: Option<PathBuf>,
|
||||
pub output_file: Option<PathBuf>,
|
||||
pub temps_dir: Option<PathBuf>,
|
||||
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
||||
pub diagnostic_output: DiagnosticOutput,
|
||||
|
||||
|
@ -193,6 +205,7 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
|
|||
input_path: config.input_path,
|
||||
output_dir: config.output_dir,
|
||||
output_file: config.output_file,
|
||||
temps_dir: config.temps_dir,
|
||||
register_lints: config.register_lints,
|
||||
override_queries: config.override_queries,
|
||||
};
|
||||
|
|
|
@ -692,6 +692,7 @@ pub fn prepare_outputs(
|
|||
&compiler.input,
|
||||
&compiler.output_dir,
|
||||
&compiler.output_file,
|
||||
&compiler.temps_dir,
|
||||
&krate.attrs,
|
||||
sess,
|
||||
);
|
||||
|
@ -734,6 +735,12 @@ pub fn prepare_outputs(
|
|||
return Err(ErrorReported);
|
||||
}
|
||||
}
|
||||
if let Some(ref dir) = compiler.temps_dir {
|
||||
if fs::create_dir_all(dir).is_err() {
|
||||
sess.err("failed to find or create the directory specified by `--temps-dir`");
|
||||
return Err(ErrorReported);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(outputs)
|
||||
|
|
|
@ -604,6 +604,7 @@ pub fn build_output_filenames(
|
|||
input: &Input,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
temps_dir: &Option<PathBuf>,
|
||||
attrs: &[ast::Attribute],
|
||||
sess: &Session,
|
||||
) -> OutputFilenames {
|
||||
|
@ -626,6 +627,7 @@ pub fn build_output_filenames(
|
|||
dirpath,
|
||||
stem,
|
||||
None,
|
||||
temps_dir.clone(),
|
||||
sess.opts.cg.extra_filename.clone(),
|
||||
sess.opts.output_types.clone(),
|
||||
)
|
||||
|
@ -654,6 +656,7 @@ pub fn build_output_filenames(
|
|||
out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
|
||||
out_file.file_stem().unwrap_or_default().to_str().unwrap().to_string(),
|
||||
ofile,
|
||||
temps_dir.clone(),
|
||||
sess.opts.cg.extra_filename.clone(),
|
||||
sess.opts.output_types.clone(),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue