about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-08-10 15:18:04 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-08-10 15:18:04 +0000
commita33f731df7727e8536d073d5b8d4f4c7b6470eb5 (patch)
tree42f0e78c8436a80712b132612b69c549260c1e46
parent1b9645853a2d1c597ac2b02fd734dcad53c3e3b9 (diff)
downloadrust-a33f731df7727e8536d073d5b8d4f4c7b6470eb5.tar.gz
rust-a33f731df7727e8536d073d5b8d4f4c7b6470eb5.zip
Couple of minor build system changes
-rw-r--r--build_system/bench.rs37
-rw-r--r--build_system/build_sysroot.rs4
-rw-r--r--build_system/prepare.rs21
-rw-r--r--build_system/utils.rs53
4 files changed, 57 insertions, 58 deletions
diff --git a/build_system/bench.rs b/build_system/bench.rs
index 6c64faaa256..a1c3a05058a 100644
--- a/build_system/bench.rs
+++ b/build_system/bench.rs
@@ -1,11 +1,12 @@
 use std::env;
 use std::io::Write;
 use std::path::Path;
+use std::process::Command;
 
 use crate::path::{Dirs, RelPath};
 use crate::prepare::GitRepo;
 use crate::rustc_info::get_file_name;
-use crate::utils::{hyperfine_command, spawn_and_wait, Compiler};
+use crate::utils::{spawn_and_wait, Compiler};
 
 static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
     "ebobby",
@@ -128,3 +129,37 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
         gha_step_summary.write_all(b"\n").unwrap();
     }
 }
+
+#[must_use]
+fn hyperfine_command(
+    warmup: u64,
+    runs: u64,
+    prepare: Option<&str>,
+    cmds: &[(&str, &str)],
+    markdown_export: &Path,
+) -> Command {
+    let mut bench = Command::new("hyperfine");
+
+    bench.arg("--export-markdown").arg(markdown_export);
+
+    if warmup != 0 {
+        bench.arg("--warmup").arg(warmup.to_string());
+    }
+
+    if runs != 0 {
+        bench.arg("--runs").arg(runs.to_string());
+    }
+
+    if let Some(prepare) = prepare {
+        bench.arg("--prepare").arg(prepare);
+    }
+
+    for &(name, cmd) in cmds {
+        if name != "" {
+            bench.arg("-n").arg(name);
+        }
+        bench.arg(cmd);
+    }
+
+    bench
+}
diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs
index abe6ae516b1..01fbef179e3 100644
--- a/build_system/build_sysroot.rs
+++ b/build_system/build_sysroot.rs
@@ -136,6 +136,7 @@ pub(crate) fn build_sysroot(
     target_compiler
 }
 
+#[must_use]
 struct SysrootTarget {
     triple: String,
     libs: Vec<PathBuf>,
@@ -161,7 +162,6 @@ pub(crate) static STANDARD_LIBRARY: CargoProject =
     CargoProject::new(&STDLIB_SRC.join("library/sysroot"), "stdlib_target");
 pub(crate) static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup");
 
-#[must_use]
 fn build_sysroot_for_triple(
     dirs: &Dirs,
     compiler: Compiler,
@@ -176,7 +176,6 @@ fn build_sysroot_for_triple(
     }
 }
 
-#[must_use]
 fn build_llvm_sysroot_for_triple(compiler: Compiler) -> SysrootTarget {
     let default_sysroot = crate::rustc_info::get_default_sysroot(&compiler.rustc);
 
@@ -210,7 +209,6 @@ fn build_llvm_sysroot_for_triple(compiler: Compiler) -> SysrootTarget {
     target_libs
 }
 
-#[must_use]
 fn build_clif_sysroot_for_triple(
     dirs: &Dirs,
     mut compiler: Compiler,
diff --git a/build_system/prepare.rs b/build_system/prepare.rs
index be0bed0f4e6..ad606267402 100644
--- a/build_system/prepare.rs
+++ b/build_system/prepare.rs
@@ -8,7 +8,7 @@ use crate::build_sysroot::STDLIB_SRC;
 use crate::path::{Dirs, RelPath};
 use crate::rustc_info::get_default_sysroot;
 use crate::utils::{
-    copy_dir_recursively, git_command, remove_dir_if_exists, retry_spawn_and_wait, spawn_and_wait,
+    copy_dir_recursively, remove_dir_if_exists, retry_spawn_and_wait, spawn_and_wait,
 };
 
 pub(crate) fn prepare(dirs: &Dirs) {
@@ -285,3 +285,22 @@ pub(crate) fn apply_patches(dirs: &Dirs, crate_name: &str, source_dir: &Path, ta
         spawn_and_wait(apply_patch_cmd);
     }
 }
+
+#[must_use]
+fn git_command<'a>(repo_dir: impl Into<Option<&'a Path>>, cmd: &str) -> Command {
+    let mut git_cmd = Command::new("git");
+    git_cmd
+        .arg("-c")
+        .arg("user.name=Dummy")
+        .arg("-c")
+        .arg("user.email=dummy@example.com")
+        .arg("-c")
+        .arg("core.autocrlf=false")
+        .arg("-c")
+        .arg("commit.gpgSign=false")
+        .arg(cmd);
+    if let Some(repo_dir) = repo_dir.into() {
+        git_cmd.current_dir(repo_dir);
+    }
+    git_cmd
+}
diff --git a/build_system/utils.rs b/build_system/utils.rs
index 3c4b45e02cc..554291346cc 100644
--- a/build_system/utils.rs
+++ b/build_system/utils.rs
@@ -141,59 +141,6 @@ impl CargoProject {
     }
 }
 
-#[must_use]
-pub(crate) fn hyperfine_command(
-    warmup: u64,
-    runs: u64,
-    prepare: Option<&str>,
-    cmds: &[(&str, &str)],
-    markdown_export: &Path,
-) -> Command {
-    let mut bench = Command::new("hyperfine");
-
-    bench.arg("--export-markdown").arg(markdown_export);
-
-    if warmup != 0 {
-        bench.arg("--warmup").arg(warmup.to_string());
-    }
-
-    if runs != 0 {
-        bench.arg("--runs").arg(runs.to_string());
-    }
-
-    if let Some(prepare) = prepare {
-        bench.arg("--prepare").arg(prepare);
-    }
-
-    for &(name, cmd) in cmds {
-        if name != "" {
-            bench.arg("-n").arg(name);
-        }
-        bench.arg(cmd);
-    }
-
-    bench
-}
-
-#[must_use]
-pub(crate) fn git_command<'a>(repo_dir: impl Into<Option<&'a Path>>, cmd: &str) -> Command {
-    let mut git_cmd = Command::new("git");
-    git_cmd
-        .arg("-c")
-        .arg("user.name=Dummy")
-        .arg("-c")
-        .arg("user.email=dummy@example.com")
-        .arg("-c")
-        .arg("core.autocrlf=false")
-        .arg("-c")
-        .arg("commit.gpgSign=false")
-        .arg(cmd);
-    if let Some(repo_dir) = repo_dir.into() {
-        git_cmd.current_dir(repo_dir);
-    }
-    git_cmd
-}
-
 #[track_caller]
 pub(crate) fn try_hard_link(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
     let src = src.as_ref();