pub struct CargoSet<'g> { /* private fields */ }
Expand description
A set of packages and features, as would be built by Cargo.
Cargo implements a set of algorithms to figure out which packages or features are built in
a given situation. guppy
implements those algorithms.
Implementations§
Source§impl<'g> CargoSet<'g>
impl<'g> CargoSet<'g>
Sourcepub fn new(
initials: FeatureSet<'g>,
features_only: FeatureSet<'g>,
opts: &CargoOptions<'_>,
) -> Result<Self, Error>
pub fn new( initials: FeatureSet<'g>, features_only: FeatureSet<'g>, opts: &CargoOptions<'_>, ) -> Result<Self, Error>
Simulates a Cargo build of this feature set, with the given options.
The feature sets are expected to be entirely within the workspace. Its behavior outside the workspace isn’t defined and may be surprising.
CargoSet::new
takes two FeatureSet
instances:
initials
, from which dependencies are followed to build theCargoSet
.features_only
, which are additional inputs that are only used for feature unification. This may be used to simulate, e.g.cargo build --package foo --package bar
, when you only care about the results offoo
but specifyingbar
influences the build.
Note that even if a package is in features_only
, it may be included in the final build set
through other means (for example, if it is also in initials
or it is a dependency of one
of them).
In many cases features_only
is empty – in that case you may wish to use
FeatureSet::into_cargo_set()
, and it may be more convenient to use that if the code is
written in a “fluent” style.
Sourcepub fn feature_graph(&self) -> &FeatureGraph<'g>
pub fn feature_graph(&self) -> &FeatureGraph<'g>
Returns the feature graph for this CargoSet
instance.
Sourcepub fn package_graph(&self) -> &'g PackageGraph
pub fn package_graph(&self) -> &'g PackageGraph
Returns the package graph for this CargoSet
instance.
Sourcepub fn initials(&self) -> &FeatureSet<'g>
pub fn initials(&self) -> &FeatureSet<'g>
Returns the initial packages and features from which the CargoSet
instance was
constructed.
Sourcepub fn features_only(&self) -> &FeatureSet<'g>
pub fn features_only(&self) -> &FeatureSet<'g>
Returns the packages and features that took part in feature unification but were not considered part of the final result.
For more about features_only
and how it influences the build, see the documentation for
CargoSet::new
.
Sourcepub fn target_features(&self) -> &FeatureSet<'g>
pub fn target_features(&self) -> &FeatureSet<'g>
Returns the feature set enabled on the target platform.
This represents the packages and features that are included as code in the final build artifacts. This is relevant for both cross-compilation and auditing.
Sourcepub fn host_features(&self) -> &FeatureSet<'g>
pub fn host_features(&self) -> &FeatureSet<'g>
Returns the feature set enabled on the host platform.
This represents the packages and features that influence the final build artifacts, but whose code is generally not directly included.
This includes all procedural macros, including those specified in the initial query.
Sourcepub fn platform_features(
&self,
build_platform: BuildPlatform,
) -> &FeatureSet<'g>
pub fn platform_features( &self, build_platform: BuildPlatform, ) -> &FeatureSet<'g>
Returns the feature set enabled on the specified build platform.
Sourcepub fn all_features(&self) -> [(BuildPlatform, &FeatureSet<'g>); 2]
pub fn all_features(&self) -> [(BuildPlatform, &FeatureSet<'g>); 2]
Returns the feature sets across the target and host build platforms.
Sourcepub fn target_direct_deps(&self) -> &PackageSet<'g>
pub fn target_direct_deps(&self) -> &PackageSet<'g>
Returns the set of workspace and direct dependency packages on the target platform.
The packages in this set are a subset of the packages in target_features
.
Sourcepub fn host_direct_deps(&self) -> &PackageSet<'g>
pub fn host_direct_deps(&self) -> &PackageSet<'g>
Returns the set of workspace and direct dependency packages on the host platform.
The packages in this set are a subset of the packages in host_features
.
Sourcepub fn platform_direct_deps(
&self,
build_platform: BuildPlatform,
) -> &PackageSet<'g>
pub fn platform_direct_deps( &self, build_platform: BuildPlatform, ) -> &PackageSet<'g>
Returns the set of workspace and direct dependency packages on the specified build platform.
Sourcepub fn all_direct_deps(&self) -> [(BuildPlatform, &PackageSet<'g>); 2]
pub fn all_direct_deps(&self) -> [(BuildPlatform, &PackageSet<'g>); 2]
Returns the set of workspace and direct dependency packages across the target and host build platforms.
Sourcepub fn proc_macro_links<'a>(
&'a self,
) -> impl Iterator<Item = PackageLink<'g>> + ExactSizeIterator + 'a
pub fn proc_macro_links<'a>( &'a self, ) -> impl Iterator<Item = PackageLink<'g>> + ExactSizeIterator + 'a
Returns PackageLink
instances for procedural macro dependencies from target packages.
Procedural macros straddle the line between target and host: they’re built for the host but generate code that is compiled for the target platform.
§Notes
Procedural macro packages will be included in the host feature set.
The returned iterator will include proc macros that are depended on normally or in dev
builds from initials (if include_dev
is set), but not the ones in the
[build-dependencies]
section.
Sourcepub fn build_dep_links<'a>(
&'a self,
) -> impl Iterator<Item = PackageLink<'g>> + ExactSizeIterator + 'a
pub fn build_dep_links<'a>( &'a self, ) -> impl Iterator<Item = PackageLink<'g>> + ExactSizeIterator + 'a
Returns PackageLink
instances for build dependencies from target packages.
§Notes
For each link, the from
is built on the target while the to
is built on the host.
It is possible (though rare) that a build dependency is also included as a normal
dependency, or as a dev dependency in which case it will also be built on the target.
The returned iterators will not include build dependencies of host packages – those are also built on the host.
Trait Implementations§
Auto Trait Implementations§
impl<'g> Freeze for CargoSet<'g>
impl<'g> RefUnwindSafe for CargoSet<'g>
impl<'g> Send for CargoSet<'g>
impl<'g> Sync for CargoSet<'g>
impl<'g> Unpin for CargoSet<'g>
impl<'g> UnwindSafe for CargoSet<'g>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)