Skip to content

Commit 257be69

Browse files
committed
Inline all RelPath::ensure_fresh
1 parent a8712ea commit 257be69

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

build_system/build_sysroot.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,15 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
289289
return None;
290290
}
291291

292-
RTSTARTUP_SYSROOT.ensure_fresh(dirs);
292+
let rtstartup_sysroot = RTSTARTUP_SYSROOT.to_path(dirs);
293+
remove_dir_if_exists(&rtstartup_sysroot);
294+
fs::create_dir_all(&rtstartup_sysroot).unwrap();
293295

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

297299
for file in ["rsbegin", "rsend"] {
298-
let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o"));
300+
let obj = rtstartup_sysroot.join(format!("{file}.o"));
299301
let mut build_rtstartup_cmd = Command::new(&compiler.rustc);
300302
build_rtstartup_cmd
301303
.arg("--target")

build_system/path.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
use std::fs;
21
use std::path::PathBuf;
32

4-
use crate::utils::remove_dir_if_exists;
5-
63
#[derive(Debug, Clone)]
74
pub(crate) struct Dirs {
85
pub(crate) source_dir: PathBuf,
@@ -46,10 +43,4 @@ impl RelPath {
4643
pub(crate) fn to_path(&self, dirs: &Dirs) -> PathBuf {
4744
self.base.to_path(dirs).join(self.suffix)
4845
}
49-
50-
pub(crate) fn ensure_fresh(&self, dirs: &Dirs) {
51-
let path = self.to_path(dirs);
52-
remove_dir_if_exists(&path);
53-
fs::create_dir_all(path).unwrap();
54-
}
5546
}

build_system/tests.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::path::{Dirs, RelPath};
77
use crate::prepare::{apply_patches, GitRepo};
88
use crate::rustc_info::get_default_sysroot;
99
use crate::shared_utils::rustflags_from_env;
10-
use crate::utils::{spawn_and_wait, CargoProject, Compiler, LogGroup};
10+
use crate::utils::{remove_dir_if_exists, spawn_and_wait, CargoProject, Compiler, LogGroup};
1111
use crate::{build_sysroot, config, CodegenBackend, SysrootKind};
1212

1313
static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::build("example");
@@ -267,7 +267,10 @@ pub(crate) fn run_tests(
267267
stdlib_source.clone(),
268268
);
269269

270-
BUILD_EXAMPLE_OUT_DIR.ensure_fresh(dirs);
270+
let path = BUILD_EXAMPLE_OUT_DIR.to_path(dirs);
271+
remove_dir_if_exists(&path);
272+
fs::create_dir_all(path).unwrap();
273+
271274
runner.run_testsuite(NO_SYSROOT_SUITE);
272275
} else {
273276
eprintln!("[SKIP] no_sysroot tests");

0 commit comments

Comments
 (0)