about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/build_system/utils.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-10-23 16:22:55 +0200
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-10-23 16:22:55 +0200
commite54a13f18bf2873f12d556fb05bb60f2a7f75bfa (patch)
treeaa307e1924204c6108c4a5fdf139ec643bf9ab47 /compiler/rustc_codegen_cranelift/build_system/utils.rs
parent9be2f35a4c1ed1b04aa4a6945b64763f599259ff (diff)
parent266e96785ab71834b917bf474f130a6d8fdecd4b (diff)
downloadrust-e54a13f18bf2873f12d556fb05bb60f2a7f75bfa.tar.gz
rust-e54a13f18bf2873f12d556fb05bb60f2a7f75bfa.zip
Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23
Diffstat (limited to 'compiler/rustc_codegen_cranelift/build_system/utils.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/utils.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_cranelift/build_system/utils.rs b/compiler/rustc_codegen_cranelift/build_system/utils.rs
index bdf8f8ecd99..48da64906e2 100644
--- a/compiler/rustc_codegen_cranelift/build_system/utils.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/utils.rs
@@ -4,6 +4,52 @@ use std::io::Write;
 use std::path::Path;
 use std::process::{self, Command, Stdio};
 
+pub(crate) fn cargo_command(
+    cargo: impl AsRef<Path>,
+    subcommand: &str,
+    triple: Option<&str>,
+    source_dir: &Path,
+) -> Command {
+    let mut cmd = Command::new(cargo.as_ref());
+    cmd.arg(subcommand)
+        .arg("--manifest-path")
+        .arg(source_dir.join("Cargo.toml"))
+        .arg("--target-dir")
+        .arg(source_dir.join("target"));
+
+    if let Some(triple) = triple {
+        cmd.arg("--target").arg(triple);
+    }
+
+    cmd
+}
+
+pub(crate) fn hyperfine_command(
+    warmup: u64,
+    runs: u64,
+    prepare: Option<Command>,
+    a: Command,
+    b: Command,
+) -> Command {
+    let mut bench = Command::new("hyperfine");
+
+    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(format!("{:?}", prepare));
+    }
+
+    bench.arg(format!("{:?}", a)).arg(format!("{:?}", b));
+
+    bench
+}
+
 #[track_caller]
 pub(crate) fn try_hard_link(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
     let src = src.as_ref();