diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-09 11:21:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-09 11:21:59 +0100 |
| commit | a8df4b15302ebb452369797439470b135d6736d2 (patch) | |
| tree | b140b4f3fc5ab7953ca5a822fa2f24950df3daeb /src/bootstrap | |
| parent | a3e152ca812bb7e9f67ccaf9ff71383e4b8e53ba (diff) | |
| parent | 41c6c5d4996728b5a635319ef9b077a3d0ccc480 (diff) | |
| download | rust-a8df4b15302ebb452369797439470b135d6736d2.tar.gz rust-a8df4b15302ebb452369797439470b135d6736d2.zip | |
Rollup merge of #107834 - zephaniahong:issue-107547-fix, r=albertlarsan68
create symlink for legacy rustfmt path Fixes #107547 . Main change is in the `download.rs` file. Created a symlink for the legacy rustfmt path to the new rustfmt path. Other file changes are simply as a result of porting over the symlink_file function from the Build struct to the config Struct
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/download.rs | 16 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 11 | ||||
| -rw-r--r-- | src/bootstrap/native.rs | 2 |
3 files changed, 17 insertions, 12 deletions
diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index bd67978a766..5c863015adb 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -2,7 +2,7 @@ use std::{ env, ffi::{OsStr, OsString}, fs::{self, File}, - io::{BufRead, BufReader, ErrorKind}, + io::{self, BufRead, BufReader, ErrorKind}, path::{Path, PathBuf}, process::{Command, Stdio}, }; @@ -26,6 +26,14 @@ impl Config { self.verbose > 0 } + pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> { + #[cfg(unix)] + use std::os::unix::fs::symlink as symlink_file; + #[cfg(windows)] + use std::os::windows::fs::symlink_file; + if !self.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) } + } + pub(crate) fn create(&self, path: &Path, s: &str) { if self.dry_run() { return; @@ -331,6 +339,12 @@ impl Config { let bin_root = self.out.join(host.triple).join("rustfmt"); let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host)); let rustfmt_stamp = bin_root.join(".rustfmt-stamp"); + + let legacy_rustfmt = self.initial_rustc.with_file_name(exe("rustfmt", host)); + if !legacy_rustfmt.exists() { + t!(self.symlink_file(&rustfmt_path, &legacy_rustfmt)); + } + if rustfmt_path.exists() && !program_out_of_date(&rustfmt_stamp, &channel) { return Some(rustfmt_path); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f4abdf1cc57..f753720b353 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -20,7 +20,6 @@ use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; use std::env; use std::fs::{self, File}; -use std::io; use std::io::ErrorKind; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; @@ -1407,7 +1406,7 @@ impl Build { src = t!(fs::canonicalize(src)); } else { let link = t!(fs::read_link(src)); - t!(self.symlink_file(link, dst)); + t!(self.config.symlink_file(link, dst)); return; } } @@ -1525,14 +1524,6 @@ impl Build { iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter() } - fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> { - #[cfg(unix)] - use std::os::unix::fs::symlink as symlink_file; - #[cfg(windows)] - use std::os::windows::fs::symlink_file; - if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) } - } - /// Returns if config.ninja is enabled, and checks for ninja existence, /// exiting with a nicer error message if not. fn ninja(&self) -> bool { diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 3acc2d4b5c4..07d339c067c 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -516,7 +516,7 @@ impl Step for Llvm { let lib_llvm = out_dir.join("build").join("lib").join(lib_name); if !lib_llvm.exists() { - t!(builder.symlink_file("libLLVM.dylib", &lib_llvm)); + t!(builder.build.config.symlink_file("libLLVM.dylib", &lib_llvm)); } } |
