Skip to content

Commit

Permalink
Inline all RelPath::ensure_fresh
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 21, 2024
1 parent 81fa34f commit 18e7621
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
5 changes: 3 additions & 2 deletions build_system/build_sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,14 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
return None;
}

RTSTARTUP_SYSROOT.ensure_fresh(dirs);
let rtstartup_sysroot = RTSTARTUP_SYSROOT.to_path(dirs);
ensure_empty_dir(&rtstartup_sysroot);

let rtstartup_src = STDLIB_SRC.to_path(dirs).join("library").join("rtstartup");
let mut target_libs = SysrootTarget { triple: compiler.triple.clone(), libs: vec![] };

for file in ["rsbegin", "rsend"] {
let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o"));
let obj = rtstartup_sysroot.join(format!("{file}.o"));
let mut build_rtstartup_cmd = Command::new(&compiler.rustc);
build_rtstartup_cmd
.arg("--target")
Expand Down
7 changes: 0 additions & 7 deletions build_system/path.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::path::PathBuf;

use crate::utils::ensure_empty_dir;

#[derive(Debug, Clone)]
pub(crate) struct Dirs {
pub(crate) source_dir: PathBuf,
Expand Down Expand Up @@ -45,9 +43,4 @@ impl RelPath {
pub(crate) fn to_path(&self, dirs: &Dirs) -> PathBuf {
self.base.to_path(dirs).join(self.suffix)
}

pub(crate) fn ensure_fresh(&self, dirs: &Dirs) {
let path = self.to_path(dirs);
ensure_empty_dir(&path);
}
}
6 changes: 4 additions & 2 deletions build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::path::{Dirs, RelPath};
use crate::prepare::{GitRepo, apply_patches};
use crate::rustc_info::get_default_sysroot;
use crate::shared_utils::rustflags_from_env;
use crate::utils::{CargoProject, Compiler, LogGroup, spawn_and_wait};
use crate::utils::{CargoProject, Compiler, LogGroup, ensure_empty_dir, spawn_and_wait};
use crate::{CodegenBackend, SysrootKind, build_sysroot, config};

static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::build("example");
Expand Down Expand Up @@ -267,7 +267,9 @@ pub(crate) fn run_tests(
stdlib_source.clone(),
);

BUILD_EXAMPLE_OUT_DIR.ensure_fresh(dirs);
let path = BUILD_EXAMPLE_OUT_DIR.to_path(dirs);
ensure_empty_dir(&path);

runner.run_testsuite(NO_SYSROOT_SUITE);
} else {
eprintln!("[SKIP] no_sysroot tests");
Expand Down

0 comments on commit 18e7621

Please sign in to comment.