about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/build_system/path.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-12-06 12:10:30 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-12-06 12:10:30 +0000
commitb3d837afe1190420464ccd6933b90b01be338ca2 (patch)
treed5b111fc2d1b1e4d54b3d2a9c02d1e04146042d1 /compiler/rustc_codegen_cranelift/build_system/path.rs
parentacf48426b64d24f372d534f634072de1f4c7e588 (diff)
parent57845a397ec15e4e6a561ed2c4bfa3dcf49144fb (diff)
downloadrust-b3d837afe1190420464ccd6933b90b01be338ca2.tar.gz
rust-b3d837afe1190420464ccd6933b90b01be338ca2.zip
Merge commit '57845a397ec15e4e6a561ed2c4bfa3dcf49144fb' into sync_cg_clif-2024-12-06
Diffstat (limited to 'compiler/rustc_codegen_cranelift/build_system/path.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/path.rs41
1 files changed, 9 insertions, 32 deletions
diff --git a/compiler/rustc_codegen_cranelift/build_system/path.rs b/compiler/rustc_codegen_cranelift/build_system/path.rs
index 35e7e81c528..20a81156b71 100644
--- a/compiler/rustc_codegen_cranelift/build_system/path.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/path.rs
@@ -1,8 +1,5 @@
-use std::fs;
 use std::path::PathBuf;
 
-use crate::utils::ensure_empty_dir;
-
 #[derive(Debug, Clone)]
 pub(crate) struct Dirs {
     pub(crate) source_dir: PathBuf,
@@ -16,54 +13,34 @@ pub(crate) struct Dirs {
 #[derive(Debug, Copy, Clone)]
 pub(crate) enum PathBase {
     Source,
-    Download,
     Build,
-    Dist,
 }
 
 impl PathBase {
     fn to_path(self, dirs: &Dirs) -> PathBuf {
         match self {
             PathBase::Source => dirs.source_dir.clone(),
-            PathBase::Download => dirs.download_dir.clone(),
             PathBase::Build => dirs.build_dir.clone(),
-            PathBase::Dist => dirs.dist_dir.clone(),
         }
     }
 }
 
 #[derive(Debug, Copy, Clone)]
-pub(crate) enum RelPath {
-    Base(PathBase),
-    Join(&'static RelPath, &'static str),
+pub(crate) struct RelPath {
+    base: PathBase,
+    suffix: &'static str,
 }
 
 impl RelPath {
-    pub(crate) const SOURCE: RelPath = RelPath::Base(PathBase::Source);
-    pub(crate) const DOWNLOAD: RelPath = RelPath::Base(PathBase::Download);
-    pub(crate) const BUILD: RelPath = RelPath::Base(PathBase::Build);
-    pub(crate) const DIST: RelPath = RelPath::Base(PathBase::Dist);
-
-    pub(crate) const SCRIPTS: RelPath = RelPath::SOURCE.join("scripts");
-    pub(crate) const PATCHES: RelPath = RelPath::SOURCE.join("patches");
-
-    pub(crate) const fn join(&'static self, suffix: &'static str) -> RelPath {
-        RelPath::Join(self, suffix)
+    pub(crate) const fn source(suffix: &'static str) -> RelPath {
+        RelPath { base: PathBase::Source, suffix }
     }
 
-    pub(crate) fn to_path(&self, dirs: &Dirs) -> PathBuf {
-        match self {
-            RelPath::Base(base) => base.to_path(dirs),
-            RelPath::Join(base, suffix) => base.to_path(dirs).join(suffix),
-        }
-    }
-
-    pub(crate) fn ensure_exists(&self, dirs: &Dirs) {
-        fs::create_dir_all(self.to_path(dirs)).unwrap();
+    pub(crate) const fn build(suffix: &'static str) -> RelPath {
+        RelPath { base: PathBase::Build, suffix }
     }
 
-    pub(crate) fn ensure_fresh(&self, dirs: &Dirs) {
-        let path = self.to_path(dirs);
-        ensure_empty_dir(&path);
+    pub(crate) fn to_path(&self, dirs: &Dirs) -> PathBuf {
+        self.base.to_path(dirs).join(self.suffix)
     }
 }