]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_codegen_cranelift/build_system/rustc_info.rs
Merge commit 'e9d1a0a7b0b28dd422f1a790ccde532acafbf193' into sync_cg_clif-2022-08-24
[rust.git] / compiler / rustc_codegen_cranelift / build_system / rustc_info.rs
index 9206bb02bd3da56da6959cdbbf34cf2e55a93f1c..913b589afcc87f658510195969fd03aef5d683e2 100644 (file)
@@ -63,3 +63,12 @@ pub(crate) fn get_file_name(crate_name: &str, crate_type: &str) -> String {
     assert!(file_name.contains(crate_name));
     file_name
 }
+
+/// Similar to `get_file_name`, but converts any dashes (`-`) in the `crate_name` to
+/// underscores (`_`). This is specially made for the the rustc and cargo wrappers
+/// which have a dash in the name, and that is not allowed in a crate name.
+pub(crate) fn get_wrapper_file_name(crate_name: &str, crate_type: &str) -> String {
+    let crate_name = crate_name.replace('-', "_");
+    let wrapper_name = get_file_name(&crate_name, crate_type);
+    wrapper_name.replace('_', "-")
+}