Avoid hard-coded rustc when building wrappers
This commit is contained in:
parent
22c5249f68
commit
629eab79c1
@ -3,7 +3,9 @@ use std::path::Path;
|
|||||||
use std::process::{self, Command};
|
use std::process::{self, Command};
|
||||||
|
|
||||||
use super::path::{Dirs, RelPath};
|
use super::path::{Dirs, RelPath};
|
||||||
use super::rustc_info::{get_file_name, get_rustc_version, get_wrapper_file_name};
|
use super::rustc_info::{
|
||||||
|
get_file_name, get_rustc_version, get_toolchain_name, get_wrapper_file_name,
|
||||||
|
};
|
||||||
use super::utils::{spawn_and_wait, try_hard_link, CargoProject, Compiler};
|
use super::utils::{spawn_and_wait, try_hard_link, CargoProject, Compiler};
|
||||||
use super::SysrootKind;
|
use super::SysrootKind;
|
||||||
|
|
||||||
@ -44,8 +46,9 @@ pub(crate) fn build_sysroot(
|
|||||||
for wrapper in ["rustc-clif", "rustdoc-clif", "cargo-clif"] {
|
for wrapper in ["rustc-clif", "rustdoc-clif", "cargo-clif"] {
|
||||||
let wrapper_name = get_wrapper_file_name(wrapper, "bin");
|
let wrapper_name = get_wrapper_file_name(wrapper, "bin");
|
||||||
|
|
||||||
let mut build_cargo_wrapper_cmd = Command::new("rustc");
|
let mut build_cargo_wrapper_cmd = Command::new(&bootstrap_host_compiler.rustc);
|
||||||
build_cargo_wrapper_cmd
|
build_cargo_wrapper_cmd
|
||||||
|
.env("TOOLCHAIN_NAME", get_toolchain_name())
|
||||||
.arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs")))
|
.arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs")))
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg(DIST_DIR.to_path(dirs).join(wrapper_name))
|
.arg(DIST_DIR.to_path(dirs).join(wrapper_name))
|
||||||
|
@ -23,6 +23,16 @@ pub(crate) fn get_host_triple() -> String {
|
|||||||
.to_owned()
|
.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_toolchain_name() -> String {
|
||||||
|
let active_toolchain = Command::new("rustup")
|
||||||
|
.stderr(Stdio::inherit())
|
||||||
|
.args(&["show", "active-toolchain"])
|
||||||
|
.output()
|
||||||
|
.unwrap()
|
||||||
|
.stdout;
|
||||||
|
String::from_utf8(active_toolchain).unwrap().trim().split_once(' ').unwrap().0.to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn get_cargo_path() -> PathBuf {
|
pub(crate) fn get_cargo_path() -> PathBuf {
|
||||||
let cargo_path = Command::new("rustup")
|
let cargo_path = Command::new("rustup")
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
|
@ -26,7 +26,7 @@ fn main() {
|
|||||||
env::set_var("RUSTDOCFLAGS", env::var("RUSTDOCFLAGS").unwrap_or(String::new()) + &rustflags);
|
env::set_var("RUSTDOCFLAGS", env::var("RUSTDOCFLAGS").unwrap_or(String::new()) + &rustflags);
|
||||||
|
|
||||||
// Ensure that the right toolchain is used
|
// Ensure that the right toolchain is used
|
||||||
env::set_var("RUSTUP_TOOLCHAIN", env!("RUSTUP_TOOLCHAIN"));
|
env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
|
||||||
|
|
||||||
let args: Vec<_> = match env::args().nth(1).as_deref() {
|
let args: Vec<_> = match env::args().nth(1).as_deref() {
|
||||||
Some("jit") => {
|
Some("jit") => {
|
||||||
|
@ -24,7 +24,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the right toolchain is used
|
// Ensure that the right toolchain is used
|
||||||
env::set_var("RUSTUP_TOOLCHAIN", env!("RUSTUP_TOOLCHAIN"));
|
env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
Command::new("rustc").args(args).exec();
|
Command::new("rustc").args(args).exec();
|
||||||
|
@ -24,7 +24,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the right toolchain is used
|
// Ensure that the right toolchain is used
|
||||||
env::set_var("RUSTUP_TOOLCHAIN", env!("RUSTUP_TOOLCHAIN"));
|
env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
Command::new("rustdoc").args(args).exec();
|
Command::new("rustdoc").args(args).exec();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user