@@ -7,7 +7,7 @@ use crate::util::config::Config;
77use crate :: util:: errors:: CargoResult ;
88use crate :: util:: interning:: InternedString ;
99use crate :: util:: Rustc ;
10- use std:: collections:: HashMap ;
10+ use std:: collections:: { HashMap , HashSet } ;
1111use std:: path:: PathBuf ;
1212
1313mod target_info;
@@ -22,22 +22,31 @@ pub use self::target_info::{FileFlavor, FileType, RustcTargetData, TargetInfo};
2222pub struct BuildContext < ' a , ' cfg > {
2323 /// The workspace the build is for.
2424 pub ws : & ' a Workspace < ' cfg > ,
25+
2526 /// The cargo configuration.
2627 pub config : & ' cfg Config ,
2728 pub profiles : Profiles ,
2829 pub build_config : & ' a BuildConfig ,
30+
2931 /// Extra compiler args for either `rustc` or `rustdoc`.
3032 pub extra_compiler_args : HashMap < Unit , Vec < String > > ,
33+
3134 /// Package downloader.
3235 ///
3336 /// This holds ownership of the `Package` objects.
3437 pub packages : PackageSet < ' cfg > ,
38+
3539 /// Information about rustc and the target platform.
3640 pub target_data : RustcTargetData ,
41+
3742 /// The root units of `unit_graph` (units requested on the command-line).
3843 pub roots : Vec < Unit > ,
44+
3945 /// The dependency graph of units to compile.
4046 pub unit_graph : UnitGraph ,
47+
48+ /// The list of all kinds that are involved in this build
49+ pub all_kinds : HashSet < CompileKind > ,
4150}
4251
4352impl < ' a , ' cfg > BuildContext < ' a , ' cfg > {
@@ -51,6 +60,13 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
5160 roots : Vec < Unit > ,
5261 unit_graph : UnitGraph ,
5362 ) -> CargoResult < BuildContext < ' a , ' cfg > > {
63+ let all_kinds = unit_graph
64+ . keys ( )
65+ . map ( |u| u. kind )
66+ . chain ( build_config. requested_kinds . iter ( ) . copied ( ) )
67+ . chain ( std:: iter:: once ( CompileKind :: Host ) )
68+ . collect ( ) ;
69+
5470 Ok ( BuildContext {
5571 ws,
5672 config : ws. config ( ) ,
@@ -61,6 +77,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
6177 target_data,
6278 roots,
6379 unit_graph,
80+ all_kinds,
6481 } )
6582 }
6683
0 commit comments