Couple of minor build system changes
This commit is contained in:
parent
1b9645853a
commit
a33f731df7
@ -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
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ pub(crate) fn build_sysroot(
|
||||
target_compiler
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
struct SysrootTarget {
|
||||
triple: String,
|
||||
libs: Vec<PathBuf>,
|
||||
@ -161,7 +162,6 @@ fn install_into_sysroot(&self, sysroot: &Path) {
|
||||
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,
|
||||
|
@ -8,7 +8,7 @@
|
||||
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
|
||||
}
|
||||
|
@ -141,59 +141,6 @@ pub(crate) fn run(&self, compiler: &Compiler, dirs: &Dirs) -> Command {
|
||||
}
|
||||
}
|
||||
|
||||
#[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();
|
||||
|
Loading…
Reference in New Issue
Block a user