Skip to content

Commit 5badc29

Browse files
authored
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.
2 parents 529fcb5 + 81e2c11 commit 5badc29

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/bootstrap/dist.rs

-23
Original file line numberDiff line numberDiff line change
@@ -894,29 +894,6 @@ impl Step for PlainSourceTarball {
894894
}
895895
}
896896

897-
// We have to run a few shell scripts, which choke quite a bit on both `\`
898-
// characters and on `C:\` paths, so normalize both of them away.
899-
pub fn sanitize_sh(path: &Path) -> String {
900-
let path = path.to_str().unwrap().replace("\\", "/");
901-
return change_drive(unc_to_lfs(&path)).unwrap_or(path);
902-
903-
fn unc_to_lfs(s: &str) -> &str {
904-
s.strip_prefix("//?/").unwrap_or(s)
905-
}
906-
907-
fn change_drive(s: &str) -> Option<String> {
908-
let mut ch = s.chars();
909-
let drive = ch.next().unwrap_or('C');
910-
if ch.next() != Some(':') {
911-
return None;
912-
}
913-
if ch.next() != Some('/') {
914-
return None;
915-
}
916-
Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..]))
917-
}
918-
}
919-
920897
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
921898
pub struct Cargo {
922899
pub compiler: Compiler,

src/bootstrap/install.rs

+25-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
66
use std::env;
77
use std::fs;
8-
use std::path::{Component, PathBuf};
8+
use std::path::{Component, Path, PathBuf};
99
use std::process::Command;
1010

1111
use crate::util::t;
1212

13-
use crate::dist::{self, sanitize_sh};
13+
use crate::dist;
1414
use crate::tarball::GeneratedTarball;
1515
use crate::Compiler;
1616

@@ -22,6 +22,29 @@ const SHELL: &str = "bash";
2222
#[cfg(not(target_os = "illumos"))]
2323
const SHELL: &str = "sh";
2424

25+
// We have to run a few shell scripts, which choke quite a bit on both `\`
26+
// characters and on `C:\` paths, so normalize both of them away.
27+
fn sanitize_sh(path: &Path) -> String {
28+
let path = path.to_str().unwrap().replace("\\", "/");
29+
return change_drive(unc_to_lfs(&path)).unwrap_or(path);
30+
31+
fn unc_to_lfs(s: &str) -> &str {
32+
s.strip_prefix("//?/").unwrap_or(s)
33+
}
34+
35+
fn change_drive(s: &str) -> Option<String> {
36+
let mut ch = s.chars();
37+
let drive = ch.next().unwrap_or('C');
38+
if ch.next() != Some(':') {
39+
return None;
40+
}
41+
if ch.next() != Some('/') {
42+
return None;
43+
}
44+
Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..]))
45+
}
46+
}
47+
2548
fn install_sh(
2649
builder: &Builder<'_>,
2750
package: &str,

0 commit comments

Comments
 (0)