about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--build_system/build_sysroot.rs7
-rw-r--r--build_system/rustc_info.rs9
-rw-r--r--build_system/tests.rs11
3 files changed, 14 insertions, 13 deletions
diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs
index 14e82a77f86..cd3216cd624 100644
--- a/build_system/build_sysroot.rs
+++ b/build_system/build_sysroot.rs
@@ -2,7 +2,7 @@ use std::fs;
 use std::path::{Path, PathBuf};
 use std::process::{self, Command};
 
-use super::rustc_info::{get_file_name, get_rustc_version};
+use super::rustc_info::{get_file_name, get_wrapper_file_name, get_rustc_version};
 use super::utils::{spawn_and_wait, try_hard_link};
 use super::SysrootKind;
 
@@ -37,10 +37,7 @@ pub(crate) fn build_sysroot(
 
     // Build and copy rustc and cargo wrappers
     for wrapper in ["rustc-clif", "cargo-clif"] {
-        let crate_name = wrapper.replace('-', "_");
-        let wrapper_name = get_file_name(&crate_name, "bin", target_triple);
-        let wrapper_name = wrapper_name.replace('_', "-");
-
+        let wrapper_name = get_wrapper_file_name(wrapper, "bin", target_triple);
 
         let mut build_cargo_wrapper_cmd = Command::new("rustc");
         build_cargo_wrapper_cmd
diff --git a/build_system/rustc_info.rs b/build_system/rustc_info.rs
index f9689eb2a8c..63e1d16ead6 100644
--- a/build_system/rustc_info.rs
+++ b/build_system/rustc_info.rs
@@ -65,3 +65,12 @@ pub(crate) fn get_file_name(crate_name: &str, crate_type: &str, target: &str) ->
     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, target: &str) -> String {
+    let crate_name = crate_name.replace('-', "_");
+    let wrapper_name = get_file_name(&crate_name, crate_type, target);
+    wrapper_name.replace('_', "-")
+}
diff --git a/build_system/tests.rs b/build_system/tests.rs
index f2166b20fcb..20d600effd3 100644
--- a/build_system/tests.rs
+++ b/build_system/tests.rs
@@ -1,5 +1,6 @@
 use super::build_sysroot;
 use super::config;
+use super::rustc_info::get_wrapper_file_name;
 use super::utils::{spawn_and_wait, spawn_and_wait_with_input};
 use build_system::SysrootKind;
 use std::env;
@@ -407,10 +408,7 @@ impl TestRunner {
     {
         let mut rustc_clif = self.root_dir.clone();
         rustc_clif.push("build");
-        rustc_clif.push("rustc-clif");
-        if cfg!(windows) {
-            rustc_clif.set_extension("exe");
-        }
+        rustc_clif.push(get_wrapper_file_name("rustc-clif", "bin", &self.target_triple));
 
         let mut cmd = Command::new(rustc_clif);
         if !self.rust_flags.is_empty() {
@@ -471,10 +469,7 @@ impl TestRunner {
     {
         let mut cargo_clif = self.root_dir.clone();
         cargo_clif.push("build");
-        cargo_clif.push("cargo-clif");
-        if cfg!(windows) {
-            cargo_clif.set_extension("exe");
-        }
+        cargo_clif.push(get_wrapper_file_name("cargo-clif", "bin", &self.target_triple));
 
         let mut cmd = Command::new(cargo_clif);
         cmd.args(args);