Assume host target in get_file_name
This commit is contained in:
parent
5d7936650d
commit
f588bfa095
5 changed files with 38 additions and 42 deletions
|
@ -23,7 +23,7 @@ pub(crate) fn build_sysroot(
|
||||||
fs::create_dir_all(target_dir.join("lib")).unwrap();
|
fs::create_dir_all(target_dir.join("lib")).unwrap();
|
||||||
|
|
||||||
// Copy the backend
|
// Copy the backend
|
||||||
let cg_clif_dylib = get_file_name("rustc_codegen_cranelift", "dylib", host_triple);
|
let cg_clif_dylib = get_file_name("rustc_codegen_cranelift", "dylib");
|
||||||
let cg_clif_dylib_path = target_dir
|
let cg_clif_dylib_path = target_dir
|
||||||
.join(if cfg!(windows) {
|
.join(if cfg!(windows) {
|
||||||
// Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
|
// Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
|
||||||
|
@ -37,7 +37,7 @@ pub(crate) fn build_sysroot(
|
||||||
|
|
||||||
// Build and copy rustc and cargo wrappers
|
// Build and copy rustc and cargo wrappers
|
||||||
for wrapper in ["rustc-clif", "cargo-clif"] {
|
for wrapper in ["rustc-clif", "cargo-clif"] {
|
||||||
let wrapper_name = get_wrapper_file_name(wrapper, "bin", host_triple);
|
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("rustc");
|
||||||
build_cargo_wrapper_cmd
|
build_cargo_wrapper_cmd
|
||||||
|
|
|
@ -48,42 +48,13 @@ pub fn main() {
|
||||||
// The target dir is expected in the default location. Guard against the user changing it.
|
// The target dir is expected in the default location. Guard against the user changing it.
|
||||||
env::set_var("CARGO_TARGET_DIR", "target");
|
env::set_var("CARGO_TARGET_DIR", "target");
|
||||||
|
|
||||||
|
|
||||||
let host_triple = if let Ok(host_triple) = std::env::var("HOST_TRIPLE") {
|
|
||||||
host_triple
|
|
||||||
} else if let Some(host_triple) = config::get_value("host") {
|
|
||||||
host_triple
|
|
||||||
} else {
|
|
||||||
rustc_info::get_host_triple()
|
|
||||||
};
|
|
||||||
let target_triple = if let Ok(target_triple) = std::env::var("TARGET_TRIPLE") {
|
|
||||||
if target_triple != "" {
|
|
||||||
target_triple
|
|
||||||
} else {
|
|
||||||
host_triple.clone() // Empty target triple can happen on GHA
|
|
||||||
}
|
|
||||||
} else if let Some(target_triple) = config::get_value("target") {
|
|
||||||
target_triple
|
|
||||||
} else {
|
|
||||||
host_triple.clone()
|
|
||||||
};
|
|
||||||
|
|
||||||
if target_triple.ends_with("-msvc") {
|
|
||||||
eprintln!("The MSVC toolchain is not yet supported by rustc_codegen_cranelift.");
|
|
||||||
eprintln!("Switch to the MinGW toolchain for Windows support.");
|
|
||||||
eprintln!("Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to");
|
|
||||||
eprintln!("set the global default target to MinGW");
|
|
||||||
process::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let mut args = env::args().skip(1);
|
let mut args = env::args().skip(1);
|
||||||
let command = match args.next().as_deref() {
|
let command = match args.next().as_deref() {
|
||||||
Some("prepare") => {
|
Some("prepare") => {
|
||||||
if args.next().is_some() {
|
if args.next().is_some() {
|
||||||
arg_error!("./y.rs prepare doesn't expect arguments");
|
arg_error!("./y.rs prepare doesn't expect arguments");
|
||||||
}
|
}
|
||||||
prepare::prepare(&host_triple);
|
prepare::prepare();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
Some("build") => Command::Build,
|
Some("build") => Command::Build,
|
||||||
|
@ -124,6 +95,33 @@ pub fn main() {
|
||||||
}
|
}
|
||||||
target_dir = std::env::current_dir().unwrap().join(target_dir);
|
target_dir = std::env::current_dir().unwrap().join(target_dir);
|
||||||
|
|
||||||
|
let host_triple = if let Ok(host_triple) = std::env::var("HOST_TRIPLE") {
|
||||||
|
host_triple
|
||||||
|
} else if let Some(host_triple) = config::get_value("host") {
|
||||||
|
host_triple
|
||||||
|
} else {
|
||||||
|
rustc_info::get_host_triple()
|
||||||
|
};
|
||||||
|
let target_triple = if let Ok(target_triple) = std::env::var("TARGET_TRIPLE") {
|
||||||
|
if target_triple != "" {
|
||||||
|
target_triple
|
||||||
|
} else {
|
||||||
|
host_triple.clone() // Empty target triple can happen on GHA
|
||||||
|
}
|
||||||
|
} else if let Some(target_triple) = config::get_value("target") {
|
||||||
|
target_triple
|
||||||
|
} else {
|
||||||
|
host_triple.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
if target_triple.ends_with("-msvc") {
|
||||||
|
eprintln!("The MSVC toolchain is not yet supported by rustc_codegen_cranelift.");
|
||||||
|
eprintln!("Switch to the MinGW toolchain for Windows support.");
|
||||||
|
eprintln!("Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to");
|
||||||
|
eprintln!("set the global default target to MinGW");
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
let cg_clif_build_dir = build_backend::build_backend(channel, &host_triple, use_unstable_features);
|
let cg_clif_build_dir = build_backend::build_backend(channel, &host_triple, use_unstable_features);
|
||||||
match command {
|
match command {
|
||||||
Command::Test => {
|
Command::Test => {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::process::Command;
|
||||||
use super::rustc_info::{get_file_name, get_rustc_path, get_rustc_version};
|
use super::rustc_info::{get_file_name, get_rustc_path, get_rustc_version};
|
||||||
use super::utils::{copy_dir_recursively, spawn_and_wait};
|
use super::utils::{copy_dir_recursively, spawn_and_wait};
|
||||||
|
|
||||||
pub(crate) fn prepare(host_triple: &str) {
|
pub(crate) fn prepare() {
|
||||||
prepare_sysroot();
|
prepare_sysroot();
|
||||||
|
|
||||||
eprintln!("[INSTALL] hyperfine");
|
eprintln!("[INSTALL] hyperfine");
|
||||||
|
@ -49,8 +49,8 @@ pub(crate) fn prepare(host_triple: &str) {
|
||||||
build_cmd.arg("build").env_remove("CARGO_TARGET_DIR").current_dir("simple-raytracer");
|
build_cmd.arg("build").env_remove("CARGO_TARGET_DIR").current_dir("simple-raytracer");
|
||||||
spawn_and_wait(build_cmd);
|
spawn_and_wait(build_cmd);
|
||||||
fs::copy(
|
fs::copy(
|
||||||
Path::new("simple-raytracer/target/debug").join(get_file_name("main", "bin", host_triple)),
|
Path::new("simple-raytracer/target/debug").join(get_file_name("main", "bin")),
|
||||||
Path::new("simple-raytracer").join(get_file_name("raytracer_cg_llvm", "bin", host_triple)),
|
Path::new("simple-raytracer").join(get_file_name("raytracer_cg_llvm", "bin")),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub(crate) fn get_default_sysroot() -> PathBuf {
|
||||||
Path::new(String::from_utf8(default_sysroot).unwrap().trim()).to_owned()
|
Path::new(String::from_utf8(default_sysroot).unwrap().trim()).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_file_name(crate_name: &str, crate_type: &str, target: &str) -> String {
|
pub(crate) fn get_file_name(crate_name: &str, crate_type: &str) -> String {
|
||||||
let file_name = Command::new("rustc")
|
let file_name = Command::new("rustc")
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.args(&[
|
.args(&[
|
||||||
|
@ -51,8 +51,6 @@ pub(crate) fn get_file_name(crate_name: &str, crate_type: &str, target: &str) ->
|
||||||
crate_name,
|
crate_name,
|
||||||
"--crate-type",
|
"--crate-type",
|
||||||
crate_type,
|
crate_type,
|
||||||
"--target",
|
|
||||||
target,
|
|
||||||
"--print",
|
"--print",
|
||||||
"file-names",
|
"file-names",
|
||||||
"-",
|
"-",
|
||||||
|
@ -69,8 +67,8 @@ pub(crate) fn get_file_name(crate_name: &str, crate_type: &str, target: &str) ->
|
||||||
/// Similar to `get_file_name`, but converts any dashes (`-`) in the `crate_name` to
|
/// Similar to `get_file_name`, but converts any dashes (`-`) in the `crate_name` to
|
||||||
/// underscores (`_`). This is specially made for the the rustc and cargo wrappers
|
/// underscores (`_`). This is specially made for the the rustc and cargo wrappers
|
||||||
/// which have a dash in the name, and that is not allowed in a crate name.
|
/// which have a dash in the name, and that is not allowed in a crate name.
|
||||||
pub(crate) fn get_wrapper_file_name(crate_name: &str, crate_type: &str, target: &str) -> String {
|
pub(crate) fn get_wrapper_file_name(crate_name: &str, crate_type: &str) -> String {
|
||||||
let crate_name = crate_name.replace('-', "_");
|
let crate_name = crate_name.replace('-', "_");
|
||||||
let wrapper_name = get_file_name(&crate_name, crate_type, target);
|
let wrapper_name = get_file_name(&crate_name, crate_type);
|
||||||
wrapper_name.replace('_', "-")
|
wrapper_name.replace('_', "-")
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,7 +415,7 @@ impl TestRunner {
|
||||||
{
|
{
|
||||||
let mut rustc_clif = self.root_dir.clone();
|
let mut rustc_clif = self.root_dir.clone();
|
||||||
rustc_clif.push("build");
|
rustc_clif.push("build");
|
||||||
rustc_clif.push(get_wrapper_file_name("rustc-clif", "bin", &self.host_triple));
|
rustc_clif.push(get_wrapper_file_name("rustc-clif", "bin"));
|
||||||
|
|
||||||
let mut cmd = Command::new(rustc_clif);
|
let mut cmd = Command::new(rustc_clif);
|
||||||
cmd.args(self.rust_flags.split_whitespace());
|
cmd.args(self.rust_flags.split_whitespace());
|
||||||
|
@ -474,7 +474,7 @@ impl TestRunner {
|
||||||
{
|
{
|
||||||
let mut cargo_clif = self.root_dir.clone();
|
let mut cargo_clif = self.root_dir.clone();
|
||||||
cargo_clif.push("build");
|
cargo_clif.push("build");
|
||||||
cargo_clif.push(get_wrapper_file_name("cargo-clif", "bin", &self.host_triple));
|
cargo_clif.push(get_wrapper_file_name("cargo-clif", "bin"));
|
||||||
|
|
||||||
let mut cmd = Command::new(cargo_clif);
|
let mut cmd = Command::new(cargo_clif);
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue