From cddd00a1e60924fd41e2b51cfd22b9756f6145e8 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 22 Sep 2018 22:24:32 +0200 Subject: Move `filename_for_metadata` to codegen_utils This function isn't strictly tied to LLVM (it's more of a utility) and it's now near an analogous, almost identical `filename_for_input` (for rlibs and so forth). Also this means not depending on the backend when one wants to know the accurate .rmeta output filename. --- src/librustc_codegen_utils/link.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/librustc_codegen_utils') diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs index 75f1d614ae7..3d47f91a623 100644 --- a/src/librustc_codegen_utils/link.rs +++ b/src/librustc_codegen_utils/link.rs @@ -97,6 +97,19 @@ pub fn find_crate_name(sess: Option<&Session>, "rust_out".to_string() } +pub fn filename_for_metadata(sess: &Session, + crate_name: &str, + outputs: &OutputFilenames) -> PathBuf { + let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename); + + let out_filename = outputs.single_output_file.clone() + .unwrap_or(outputs.out_directory.join(&format!("lib{}.rmeta", libname))); + + check_file_is_writeable(&out_filename, sess); + + out_filename +} + pub fn filename_for_input(sess: &Session, crate_type: config::CrateType, crate_name: &str, -- cgit 1.4.1-3-g733a5