pub struct Unit<'a> {
pub pkg: &'a Package,
pub target: &'a Target,
pub profile: Profile,
pub kind: Kind,
pub mode: CompileMode,
}Expand description
All information needed to define a Unit.
A unit is an object that has enough information so that cargo knows how to build it.
For example, if your package has dependencies, then every dependency will be built as a library
unit. If your package is a library, then it will be built as a library unit as well, or if it
is a binary with main.rs, then a binary will be output. There are also separate unit types
for testing and checking, amongst others.
The unit also holds information about all possible metadata about the package in pkg.
A unit needs to know extra information in addition to the type and root source file. For example, it needs to know the target architecture (OS, chip arch etc.) and it needs to know whether you want a debug or release build. There is enough information in this struct to figure all that out.
Fields§
§pkg: &'a PackageInformation about available targets, which files to include/exclude, etc. Basically stuff in
Cargo.toml.
target: &'a TargetInformation about the specific target to build, out of the possible targets in pkg. Not
to be confused with target-triple (or target architecture …), the target arch for a
build.
profile: ProfileThe profile contains information about how the build should be run, including debug level, etc.
kind: KindWhether this compilation unit is for the host or target architecture.
For example, when cross compiling and using a custom build script, the build script needs to be compiled for the host architecture so the host rustc can use it (when compiling to the target architecture).
mode: CompileModeThe “mode” this unit is being compiled for. See CompileMode for
more details.