]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_codegen_cranelift/build_system/mod.rs
New upstream version 1.65.0+dfsg1
[rustc.git] / compiler / rustc_codegen_cranelift / build_system / mod.rs
index b897b7fbacfcdf54426583790ed5116d2450ddd6..c3706dc6f82039cfee03fe18fdb7ef7c3f8c36d6 100644 (file)
@@ -2,11 +2,15 @@ use std::env;
 use std::path::PathBuf;
 use std::process;
 
+use self::utils::is_ci;
+
+mod abi_checker;
 mod build_backend;
 mod build_sysroot;
 mod config;
 mod prepare;
 mod rustc_info;
+mod tests;
 mod utils;
 
 fn usage() {
@@ -15,6 +19,9 @@ fn usage() {
     eprintln!(
         "  ./y.rs build [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]"
     );
+    eprintln!(
+        "  ./y.rs test [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]"
+    );
 }
 
 macro_rules! arg_error {
@@ -25,11 +32,13 @@ macro_rules! arg_error {
     }};
 }
 
+#[derive(PartialEq, Debug)]
 enum Command {
     Build,
+    Test,
 }
 
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug)]
 pub(crate) enum SysrootKind {
     None,
     Clif,
@@ -42,16 +51,22 @@ pub fn main() {
     // The target dir is expected in the default location. Guard against the user changing it.
     env::set_var("CARGO_TARGET_DIR", "target");
 
+    if is_ci() {
+        // Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
+        env::set_var("CARGO_BUILD_INCREMENTAL", "false");
+    }
+
     let mut args = env::args().skip(1);
     let command = match args.next().as_deref() {
         Some("prepare") => {
             if args.next().is_some() {
-                arg_error!("./x.rs prepare doesn't expect arguments");
+                arg_error!("./y.rs prepare doesn't expect arguments");
             }
             prepare::prepare();
             process::exit(0);
         }
         Some("build") => Command::Build,
+        Some("test") => Command::Test,
         Some(flag) if flag.starts_with('-') => arg_error!("Expected command found flag {}", flag),
         Some(command) => arg_error!("Unknown command {}", command),
         None => {
@@ -117,12 +132,35 @@ pub fn main() {
 
     let cg_clif_build_dir =
         build_backend::build_backend(channel, &host_triple, use_unstable_features);
-    build_sysroot::build_sysroot(
-        channel,
-        sysroot_kind,
-        &target_dir,
-        cg_clif_build_dir,
-        &host_triple,
-        &target_triple,
-    );
+    match command {
+        Command::Test => {
+            tests::run_tests(
+                channel,
+                sysroot_kind,
+                &target_dir,
+                &cg_clif_build_dir,
+                &host_triple,
+                &target_triple,
+            );
+
+            abi_checker::run(
+                channel,
+                sysroot_kind,
+                &target_dir,
+                &cg_clif_build_dir,
+                &host_triple,
+                &target_triple,
+            );
+        }
+        Command::Build => {
+            build_sysroot::build_sysroot(
+                channel,
+                sysroot_kind,
+                &target_dir,
+                &cg_clif_build_dir,
+                &host_triple,
+                &target_triple,
+            );
+        }
+    }
 }