about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-05-28 08:45:54 +0200
committerGitHub <noreply@github.com>2022-05-28 08:45:54 +0200
commit5badc299d90b7bfb82f22a5a0071b20c4b836b16 (patch)
tree18044c516b31458965269b7ef5ec14c063be569f /src
parent529fcb579b6944fa6256ffb8f8362f6749c7bf8d (diff)
parent81e2c112d92f7cf5bc342641b356962b2d1ae2e5 (diff)
downloadrust-5badc299d90b7bfb82f22a5a0071b20c4b836b16.tar.gz
rust-5badc299d90b7bfb82f22a5a0071b20c4b836b16.zip
Rollup merge of #97466 - jyn514:consolidate-install, r=Mark-Simulacrum
[bootstrap] Move `sanitize_sh` from `dist` to `install`

This is the only place it's used, so there's no need for it to be public in another module.
In general, `dist` shouldn't ever touch shell scripts.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/dist.rs23
-rw-r--r--src/bootstrap/install.rs27
2 files changed, 25 insertions, 25 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index cc10d67c551..5cbaf03d029 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -894,29 +894,6 @@ impl Step for PlainSourceTarball {
     }
 }
 
-// We have to run a few shell scripts, which choke quite a bit on both `\`
-// characters and on `C:\` paths, so normalize both of them away.
-pub fn sanitize_sh(path: &Path) -> String {
-    let path = path.to_str().unwrap().replace("\\", "/");
-    return change_drive(unc_to_lfs(&path)).unwrap_or(path);
-
-    fn unc_to_lfs(s: &str) -> &str {
-        s.strip_prefix("//?/").unwrap_or(s)
-    }
-
-    fn change_drive(s: &str) -> Option<String> {
-        let mut ch = s.chars();
-        let drive = ch.next().unwrap_or('C');
-        if ch.next() != Some(':') {
-            return None;
-        }
-        if ch.next() != Some('/') {
-            return None;
-        }
-        Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..]))
-    }
-}
-
 #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
 pub struct Cargo {
     pub compiler: Compiler,
diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
index 08e37a16279..6e49f39ffb6 100644
--- a/src/bootstrap/install.rs
+++ b/src/bootstrap/install.rs
@@ -5,12 +5,12 @@
 
 use std::env;
 use std::fs;
-use std::path::{Component, PathBuf};
+use std::path::{Component, Path, PathBuf};
 use std::process::Command;
 
 use crate::util::t;
 
-use crate::dist::{self, sanitize_sh};
+use crate::dist;
 use crate::tarball::GeneratedTarball;
 use crate::Compiler;
 
@@ -22,6 +22,29 @@ const SHELL: &str = "bash";
 #[cfg(not(target_os = "illumos"))]
 const SHELL: &str = "sh";
 
+// We have to run a few shell scripts, which choke quite a bit on both `\`
+// characters and on `C:\` paths, so normalize both of them away.
+fn sanitize_sh(path: &Path) -> String {
+    let path = path.to_str().unwrap().replace("\\", "/");
+    return change_drive(unc_to_lfs(&path)).unwrap_or(path);
+
+    fn unc_to_lfs(s: &str) -> &str {
+        s.strip_prefix("//?/").unwrap_or(s)
+    }
+
+    fn change_drive(s: &str) -> Option<String> {
+        let mut ch = s.chars();
+        let drive = ch.next().unwrap_or('C');
+        if ch.next() != Some(':') {
+            return None;
+        }
+        if ch.next() != Some('/') {
+            return None;
+        }
+        Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..]))
+    }
+}
+
 fn install_sh(
     builder: &Builder<'_>,
     package: &str,