From 9882d7c511fcfed404c547a64cbc42b6cf3fc17c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 16 Dec 2023 17:55:53 +0100 Subject: [PATCH] Apply suggestions --- build_system/src/build.rs | 4 ++-- build_system/src/config.rs | 12 ++++++++++++ build_system/src/test.rs | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build_system/src/build.rs b/build_system/src/build.rs index 9fb47195aee..d264aac7eff 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -128,7 +128,7 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu &"build", &"--release", &"--target", - &config.target_triple, + &config.target, ], Some(start_dir), Some(&env), @@ -138,7 +138,7 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu env.insert("RUSTFLAGS".to_string(), rustflags); run_command_with_output_and_env( - &[&"cargo", &"build", &"--target", &config.target_triple], + &[&"cargo", &"build", &"--target", &config.target], Some(start_dir), Some(&env), )?; diff --git a/build_system/src/config.rs b/build_system/src/config.rs index 09375791aa3..d948572bda5 100644 --- a/build_system/src/config.rs +++ b/build_system/src/config.rs @@ -21,6 +21,7 @@ impl Channel { #[derive(Default, Debug)] pub struct ConfigInfo { + pub target: String, pub target_triple: String, pub host_triple: String, pub rustc_command: Vec, @@ -42,6 +43,13 @@ impl ConfigInfo { args: &mut impl Iterator, ) -> Result { match arg { + "--target" => { + if let Some(arg) = args.next() { + self.target = arg; + } else { + return Err("Expected a value after `--target`, found nothing".to_string()); + } + } "--target-triple" => match args.next() { Some(arg) if !arg.is_empty() => self.target_triple = arg.to_string(), _ => { @@ -113,6 +121,9 @@ impl ConfigInfo { if self.target_triple.is_empty() { self.target_triple = self.host_triple.clone(); } + if self.target.is_empty() && !self.target_triple.is_empty() { + self.target = self.target_triple.clone(); + } let mut linker = None; @@ -243,6 +254,7 @@ impl ConfigInfo { println!( "\ --target-triple [arg] : Set the target triple to [arg] + --target [arg] : Set the target to [arg] --out-dir : Location where the files will be generated --release : Build in release mode --release-sysroot : Build sysroot in release mode diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 1e9652d2822..a926ee4c79e 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -482,7 +482,7 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> { &args.config_info.target_triple, ]); run_command_with_env(&command, None, Some(env))?; - // FIXME: the compiled binary is not run. Is it normal? + // FIXME: the compiled binary is not run. Ok(()) }