@@ -18,7 +18,6 @@ pub(crate) enum PathBase {
18
18
Source ,
19
19
Download ,
20
20
Build ,
21
- Dist ,
22
21
}
23
22
24
23
impl PathBase {
@@ -27,39 +26,31 @@ impl PathBase {
27
26
PathBase :: Source => dirs. source_dir . clone ( ) ,
28
27
PathBase :: Download => dirs. download_dir . clone ( ) ,
29
28
PathBase :: Build => dirs. build_dir . clone ( ) ,
30
- PathBase :: Dist => dirs. dist_dir . clone ( ) ,
31
29
}
32
30
}
33
31
}
34
32
35
33
#[ derive( Debug , Copy , Clone ) ]
36
- pub ( crate ) enum RelPath {
37
- Base ( PathBase ) ,
38
- Join ( & ' static RelPath , & ' static str ) ,
34
+ pub ( crate ) struct RelPath {
35
+ base : PathBase ,
36
+ suffix : & ' static str ,
39
37
}
40
38
41
39
impl RelPath {
42
- pub ( crate ) const SOURCE : RelPath = RelPath :: Base ( PathBase :: Source ) ;
43
- pub ( crate ) const DOWNLOAD : RelPath = RelPath :: Base ( PathBase :: Download ) ;
44
- pub ( crate ) const BUILD : RelPath = RelPath :: Base ( PathBase :: Build ) ;
45
- pub ( crate ) const DIST : RelPath = RelPath :: Base ( PathBase :: Dist ) ;
46
-
47
- pub ( crate ) const SCRIPTS : RelPath = RelPath :: SOURCE . join ( "scripts" ) ;
48
- pub ( crate ) const PATCHES : RelPath = RelPath :: SOURCE . join ( "patches" ) ;
40
+ pub ( crate ) const fn source ( suffix : & ' static str ) -> RelPath {
41
+ RelPath { base : PathBase :: Source , suffix }
42
+ }
49
43
50
- pub ( crate ) const fn join ( & ' static self , suffix : & ' static str ) -> RelPath {
51
- RelPath :: Join ( self , suffix)
44
+ pub ( crate ) const fn download ( suffix : & ' static str ) -> RelPath {
45
+ RelPath { base : PathBase :: Download , suffix }
52
46
}
53
47
54
- pub ( crate ) fn to_path ( & self , dirs : & Dirs ) -> PathBuf {
55
- match self {
56
- RelPath :: Base ( base) => base. to_path ( dirs) ,
57
- RelPath :: Join ( base, suffix) => base. to_path ( dirs) . join ( suffix) ,
58
- }
48
+ pub ( crate ) const fn build ( suffix : & ' static str ) -> RelPath {
49
+ RelPath { base : PathBase :: Build , suffix }
59
50
}
60
51
61
- pub ( crate ) fn ensure_exists ( & self , dirs : & Dirs ) {
62
- fs :: create_dir_all ( self . to_path ( dirs) ) . unwrap ( ) ;
52
+ pub ( crate ) fn to_path ( & self , dirs : & Dirs ) -> PathBuf {
53
+ self . base . to_path ( dirs) . join ( self . suffix )
63
54
}
64
55
65
56
pub ( crate ) fn ensure_fresh ( & self , dirs : & Dirs ) {
0 commit comments