mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
Don't hard-code rustc path in get_rustc_version and get_default_sysroot
This commit is contained in:
parent
4dbafefe74
commit
22c5249f68
@ -53,7 +53,7 @@ pub(crate) fn build_sysroot(
|
||||
spawn_and_wait(build_cargo_wrapper_cmd);
|
||||
}
|
||||
|
||||
let default_sysroot = super::rustc_info::get_default_sysroot();
|
||||
let default_sysroot = super::rustc_info::get_default_sysroot(&bootstrap_host_compiler.rustc);
|
||||
|
||||
let host_rustlib_lib =
|
||||
RUSTLIB_DIR.to_path(dirs).join(&bootstrap_host_compiler.triple).join("lib");
|
||||
@ -182,7 +182,7 @@ fn build_clif_sysroot_for_triple(
|
||||
process::exit(1);
|
||||
}
|
||||
Ok(source_version) => {
|
||||
let rustc_version = get_rustc_version();
|
||||
let rustc_version = get_rustc_version(&compiler.rustc);
|
||||
if source_version != rustc_version {
|
||||
eprintln!("The patched sysroot source is outdated");
|
||||
eprintln!("Source version: {}", source_version.trim());
|
||||
|
@ -35,7 +35,7 @@ pub(crate) fn prepare(dirs: &Dirs) {
|
||||
}
|
||||
|
||||
fn prepare_sysroot(dirs: &Dirs) {
|
||||
let sysroot_src_orig = get_default_sysroot().join("lib/rustlib/src/rust");
|
||||
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust");
|
||||
assert!(sysroot_src_orig.exists());
|
||||
|
||||
eprintln!("[COPY] sysroot src");
|
||||
@ -50,7 +50,7 @@ fn prepare_sysroot(dirs: &Dirs) {
|
||||
&SYSROOT_SRC.to_path(dirs).join("library"),
|
||||
);
|
||||
|
||||
let rustc_version = get_rustc_version();
|
||||
let rustc_version = get_rustc_version(Path::new("rustc"));
|
||||
fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap();
|
||||
|
||||
eprintln!("[GIT] init");
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
pub(crate) fn get_rustc_version() -> String {
|
||||
pub(crate) fn get_rustc_version(rustc: &Path) -> String {
|
||||
let version_info =
|
||||
Command::new("rustc").stderr(Stdio::inherit()).args(&["-V"]).output().unwrap().stdout;
|
||||
Command::new(rustc).stderr(Stdio::inherit()).args(&["-V"]).output().unwrap().stdout;
|
||||
String::from_utf8(version_info).unwrap()
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ pub(crate) fn get_rustdoc_path() -> PathBuf {
|
||||
Path::new(String::from_utf8(rustc_path).unwrap().trim()).to_owned()
|
||||
}
|
||||
|
||||
pub(crate) fn get_default_sysroot() -> PathBuf {
|
||||
let default_sysroot = Command::new("rustc")
|
||||
pub(crate) fn get_default_sysroot(rustc: &Path) -> PathBuf {
|
||||
let default_sysroot = Command::new(rustc)
|
||||
.stderr(Stdio::inherit())
|
||||
.args(&["--print", "sysroot"])
|
||||
.output()
|
||||
|
Loading…
Reference in New Issue
Block a user