rust/compiler/rustc_codegen_cranelift/build_system/path.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
939 B
Rust
Raw Permalink Normal View History

2022-12-01 13:30:03 +00:00
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub(crate) struct Dirs {
pub(crate) source_dir: PathBuf,
pub(crate) download_dir: PathBuf,
pub(crate) build_dir: PathBuf,
pub(crate) dist_dir: PathBuf,
pub(crate) frozen: bool,
}
2022-12-01 13:30:03 +00:00
#[doc(hidden)]
#[derive(Debug, Copy, Clone)]
2024-12-18 18:11:47 +00:00
enum PathBase {
2022-12-01 13:30:03 +00:00
Source,
Build,
}
#[derive(Debug, Copy, Clone)]
2024-09-12 18:07:02 +00:00
pub(crate) struct RelPath {
base: PathBase,
suffix: &'static str,
2022-12-01 13:30:03 +00:00
}
impl RelPath {
2024-09-12 18:07:02 +00:00
pub(crate) const fn source(suffix: &'static str) -> RelPath {
RelPath { base: PathBase::Source, suffix }
2022-12-01 13:30:03 +00:00
}
2024-09-12 18:07:02 +00:00
pub(crate) const fn build(suffix: &'static str) -> RelPath {
RelPath { base: PathBase::Build, suffix }
2022-12-01 13:30:03 +00:00
}
2024-09-12 18:07:02 +00:00
pub(crate) fn to_path(&self, dirs: &Dirs) -> PathBuf {
2024-12-18 18:11:47 +00:00
match self.base {
PathBase::Source => dirs.source_dir.join(self.suffix),
PathBase::Build => dirs.build_dir.join(self.suffix),
}
2022-12-01 13:30:03 +00:00
}
}