1
- //! Constructs the dependency graph for compilation.
1
+ //! # Constructs the dependency graph for compilation
2
2
//!
3
3
//! Rust code is typically organized as a set of Cargo packages. The
4
4
//! dependencies between the packages themselves are stored in the
5
- //! `Resolve` struct. However, we can't use that information as is for
5
+ //! [ `Resolve`] struct. However, we can't use that information as is for
6
6
//! compilation! A package typically contains several targets, or crates,
7
7
//! and these targets has inter-dependencies. For example, you need to
8
8
//! compile the `lib` target before the `bin` one, and you need to compile
13
13
//! is exactly what this module is doing! Well, almost exactly: another
14
14
//! complication is that we might want to compile the same target several times
15
15
//! (for example, with and without tests), so we actually build a dependency
16
- //! graph of `Unit`s, which capture these properties.
16
+ //! graph of [ `Unit`] s, which capture these properties.
17
17
18
18
use std:: collections:: { HashMap , HashSet } ;
19
19
@@ -35,23 +35,27 @@ use crate::CargoResult;
35
35
36
36
const IS_NO_ARTIFACT_DEP : Option < & ' static Artifact > = None ;
37
37
38
- /// Collection of stuff used while creating the `UnitGraph`.
38
+ /// Collection of stuff used while creating the [ `UnitGraph`] .
39
39
struct State < ' a , ' cfg > {
40
40
ws : & ' a Workspace < ' cfg > ,
41
41
config : & ' cfg Config ,
42
+ /// Stores the result of building the [`UnitGraph`].
42
43
unit_dependencies : UnitGraph ,
43
44
package_set : & ' a PackageSet < ' cfg > ,
44
45
usr_resolve : & ' a Resolve ,
45
46
usr_features : & ' a ResolvedFeatures ,
47
+ /// Like `usr_resolve` but for building standard library (`-Zbuild-std`).
46
48
std_resolve : Option < & ' a Resolve > ,
49
+ /// Like `usr_features` but for building standard library (`-Zbuild-std`).
47
50
std_features : Option < & ' a ResolvedFeatures > ,
48
- /// This flag is `true` while generating the dependencies for the standard
49
- /// library.
51
+ /// `true` while generating the dependencies for the standard library.
50
52
is_std : bool ,
53
+ /// The mode we are compiling in. Used for preventing from building lib thrice.
51
54
global_mode : CompileMode ,
52
55
target_data : & ' a RustcTargetData < ' cfg > ,
53
56
profiles : & ' a Profiles ,
54
57
interner : & ' a UnitInterner ,
58
+ // Units for `-Zrustdoc-scrape-examples`.
55
59
scrape_units : & ' a [ Unit ] ,
56
60
57
61
/// A set of edges in `unit_dependencies` where (a, b) means that the
@@ -73,6 +77,9 @@ impl IsArtifact {
73
77
}
74
78
}
75
79
80
+ /// Then entry point for building a dependency graph of compilation units.
81
+ ///
82
+ /// You can find some information for arguments from doc of [`State`].
76
83
pub fn build_unit_dependencies < ' a , ' cfg > (
77
84
ws : & ' a Workspace < ' cfg > ,
78
85
package_set : & ' a PackageSet < ' cfg > ,
@@ -1015,6 +1022,7 @@ fn connect_run_custom_build_deps(state: &mut State<'_, '_>) {
1015
1022
}
1016
1023
1017
1024
impl < ' a , ' cfg > State < ' a , ' cfg > {
1025
+ /// Gets `std_resolve` during building std, otherwise `usr_resolve`.
1018
1026
fn resolve ( & self ) -> & ' a Resolve {
1019
1027
if self . is_std {
1020
1028
self . std_resolve . unwrap ( )
@@ -1023,6 +1031,7 @@ impl<'a, 'cfg> State<'a, 'cfg> {
1023
1031
}
1024
1032
}
1025
1033
1034
+ /// Gets `std_features` during building std, otherwise `usr_features`.
1026
1035
fn features ( & self ) -> & ' a ResolvedFeatures {
1027
1036
if self . is_std {
1028
1037
self . std_features . unwrap ( )
0 commit comments