about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-12-16 17:55:53 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2023-12-16 17:56:03 +0100
commit9882d7c511fcfed404c547a64cbc42b6cf3fc17c (patch)
tree5d645355f16fc0b83eb067ba9ab8299179c8984b
parent95dfe5ec9040bcba53a8dd61d3593d182defab71 (diff)
downloadrust-9882d7c511fcfed404c547a64cbc42b6cf3fc17c.tar.gz
rust-9882d7c511fcfed404c547a64cbc42b6cf3fc17c.zip
Apply suggestions
-rw-r--r--build_system/src/build.rs4
-rw-r--r--build_system/src/config.rs12
-rw-r--r--build_system/src/test.rs2
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<String, String>, 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<String, String>, 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<String>,
@@ -42,6 +43,13 @@ impl ConfigInfo {
         args: &mut impl Iterator<Item = String>,
     ) -> Result<bool, String> {
         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(())
 }