@@ -14,8 +14,9 @@ use std::sync::OnceLock;
14
14
use std:: time:: { Duration , Instant } ;
15
15
16
16
use crate :: core:: build_steps:: tool:: { self , SourceType } ;
17
- use crate :: core:: build_steps:: { check, clean, compile, dist, doc, install, run, setup, test} ;
18
- use crate :: core:: build_steps:: { clippy, llvm} ;
17
+ use crate :: core:: build_steps:: {
18
+ check, clean, clippy, compile, dist, doc, install, llvm, run, setup, test, vendor,
19
+ } ;
19
20
use crate :: core:: config:: flags:: { Color , Subcommand } ;
20
21
use crate :: core:: config:: { DryRun , SplitDebuginfo , TargetSelection } ;
21
22
use crate :: prepare_behaviour_dump_dir;
@@ -34,13 +35,34 @@ use once_cell::sync::Lazy;
34
35
#[ cfg( test) ]
35
36
mod tests;
36
37
38
+ /// Builds and performs different [`Self::kind`]s of stuff and actions, taking
39
+ /// into account build configuration from e.g. config.toml.
37
40
pub struct Builder < ' a > {
41
+ /// Build configuration from e.g. config.toml.
38
42
pub build : & ' a Build ,
43
+
44
+ /// The stage to use. Either implicitly determined based on subcommand, or
45
+ /// explicitly specified with `--stage N`. Normally this is the stage we
46
+ /// use, but sometimes we want to run steps with a lower stage than this.
39
47
pub top_stage : u32 ,
48
+
49
+ /// What to build or what action to perform.
40
50
pub kind : Kind ,
51
+
52
+ /// A cache of outputs of [`Step`]s so we can avoid running steps we already
53
+ /// ran.
41
54
cache : Cache ,
55
+
56
+ /// A stack of [`Step`]s to run before we can run this builder. The output
57
+ /// of steps is cached in [`Self::cache`].
42
58
stack : RefCell < Vec < Box < dyn Any > > > ,
59
+
60
+ /// The total amount of time we spent running [`Step`]s in [`Self::stack`].
43
61
time_spent_on_dependencies : Cell < Duration > ,
62
+
63
+ /// The paths passed on the command line. Used by steps to figure out what
64
+ /// to do. For example: with `./x check foo bar` we get `paths=["foo",
65
+ /// "bar"]`.
44
66
pub paths : Vec < PathBuf > ,
45
67
}
46
68
@@ -638,6 +660,7 @@ pub enum Kind {
638
660
Run ,
639
661
Setup ,
640
662
Suggest ,
663
+ Vendor ,
641
664
}
642
665
643
666
impl Kind {
@@ -658,6 +681,7 @@ impl Kind {
658
681
Kind :: Run => "run" ,
659
682
Kind :: Setup => "setup" ,
660
683
Kind :: Suggest => "suggest" ,
684
+ Kind :: Vendor => "vendor" ,
661
685
}
662
686
}
663
687
@@ -921,6 +945,7 @@ impl<'a> Builder<'a> {
921
945
) ,
922
946
Kind :: Setup => describe ! ( setup:: Profile , setup:: Hook , setup:: Link , setup:: Vscode ) ,
923
947
Kind :: Clean => describe ! ( clean:: CleanAll , clean:: Rustc , clean:: Std ) ,
948
+ Kind :: Vendor => describe ! ( vendor:: Vendor ) ,
924
949
// special-cased in Build::build()
925
950
Kind :: Format | Kind :: Suggest => vec ! [ ] ,
926
951
}
@@ -993,6 +1018,7 @@ impl<'a> Builder<'a> {
993
1018
Kind :: Setup ,
994
1019
path. as_ref ( ) . map_or ( [ ] . as_slice ( ) , |path| std:: slice:: from_ref ( path) ) ,
995
1020
) ,
1021
+ Subcommand :: Vendor { .. } => ( Kind :: Vendor , & paths[ ..] ) ,
996
1022
} ;
997
1023
998
1024
Self :: new_internal ( build, kind, paths. to_owned ( ) )
0 commit comments