2022-12-01 13:30:03 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2022-12-01 14:54:37 +00:00
|
|
|
#[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,
|
2023-02-12 14:16:48 +00:00
|
|
|
pub(crate) frozen: bool,
|
2022-12-01 14:54:37 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|