@@ -7,7 +7,7 @@ use crate::util::config::Config;
7
7
use crate :: util:: errors:: CargoResult ;
8
8
use crate :: util:: interning:: InternedString ;
9
9
use crate :: util:: Rustc ;
10
- use std:: collections:: HashMap ;
10
+ use std:: collections:: { HashMap , HashSet } ;
11
11
use std:: path:: PathBuf ;
12
12
13
13
mod target_info;
@@ -22,22 +22,31 @@ pub use self::target_info::{FileFlavor, FileType, RustcTargetData, TargetInfo};
22
22
pub struct BuildContext < ' a , ' cfg > {
23
23
/// The workspace the build is for.
24
24
pub ws : & ' a Workspace < ' cfg > ,
25
+
25
26
/// The cargo configuration.
26
27
pub config : & ' cfg Config ,
27
28
pub profiles : Profiles ,
28
29
pub build_config : & ' a BuildConfig ,
30
+
29
31
/// Extra compiler args for either `rustc` or `rustdoc`.
30
32
pub extra_compiler_args : HashMap < Unit , Vec < String > > ,
33
+
31
34
/// Package downloader.
32
35
///
33
36
/// This holds ownership of the `Package` objects.
34
37
pub packages : PackageSet < ' cfg > ,
38
+
35
39
/// Information about rustc and the target platform.
36
40
pub target_data : RustcTargetData ,
41
+
37
42
/// The root units of `unit_graph` (units requested on the command-line).
38
43
pub roots : Vec < Unit > ,
44
+
39
45
/// The dependency graph of units to compile.
40
46
pub unit_graph : UnitGraph ,
47
+
48
+ /// The list of all kinds that are involved in this build
49
+ pub all_kinds : HashSet < CompileKind > ,
41
50
}
42
51
43
52
impl < ' a , ' cfg > BuildContext < ' a , ' cfg > {
@@ -51,6 +60,13 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
51
60
roots : Vec < Unit > ,
52
61
unit_graph : UnitGraph ,
53
62
) -> 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
+
54
70
Ok ( BuildContext {
55
71
ws,
56
72
config : ws. config ( ) ,
@@ -61,6 +77,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
61
77
target_data,
62
78
roots,
63
79
unit_graph,
80
+ all_kinds,
64
81
} )
65
82
}
66
83
0 commit comments