Expand description
Constructs the dependency graph for compilation.
Rust code is typically organized as a set of Cargo packages. The
dependencies between the packages themselves are stored in the
Resolve struct. However, we canβt use that information as is for
compilation! A package typically contains several targets, or crates,
and these targets has inter-dependencies. For example, you need to
compile the lib target before the bin one, and you need to compile
build.rs before either of those.
So, we need to lower the Resolve, which specifies dependencies between
packages, to a graph of dependencies between their targets, and this
is exactly what this module is doing! Well, almost exactly: another
complication is that we might want to compile the same target several times
(for example, with and without tests), so we actually build a dependency
graph of Units, which capture these properties.
StructsΒ§
EnumsΒ§
- IsArtifact
- A boolean-like to indicate if a
Unitis an artifact or not.
ConstantsΒ§
- IS_
NO_ πARTIFACT_ DEP
FunctionsΒ§
- artifact_
targets_ πto_ unit_ deps - Given a
parentunit containing a dependencydepwhose package isartifact_pkg, find all targets inartifact_pkgwhich refer to thedeps artifact declaration and turn them into units. Due to the nature of artifact dependencies, a single dependency in a manifest can cause one or more targets to be build, for instance withartifact = ["bin:a", "bin:b", "staticlib"], which is very different from normal dependencies which cause only a single unit to be created. - attach_
std_ πdeps - Add the standard library units to the
unit_dependencies. - build_
unit_ dependencies - Then entry point for building a dependency graph of compilation units.
- calc_
artifact_ πdeps - Find artifacts for all
depsofunitand add units that build these artifacts toret. - calc_
deps_ πof_ std - Compute all the dependencies for the standard library.
- check_
or_ πbuild_ mode - Choose the correct mode for dependencies.
- compute_
deps π - Returns the direct unit dependencies for the given
Unit. - compute_
deps_ πcustom_ build - Returns the dependencies needed to run a build script.
- compute_
deps_ πdoc - Returns the dependencies necessary to document a package.
- connect_
run_ πcustom_ build_ deps - Fill in missing dependencies for units of the
RunCustomBuild - dep_
build_ πscript - If a build script is scheduled to be run for the package specified by
unit, this function will return the unit to run that build script. - deps_of π
- Compute the dependencies of a single unit, recursively computing all transitive dependencies.
- deps_
of_ πroots - Compute all the dependencies of the given root units.
The result is stored in
state.unit_dependencies. - maybe_
lib π - new_
unit_ πdep - Create a new Unit for a dependency from
parenttopkgandtarget. - new_
unit_ πdep_ with_ profile