Struct hakari::HakariBuilder [−][src]
pub struct HakariBuilder<'g> { /* fields omitted */ }
Expand description
Configures and constructs Hakari
instances.
This struct provides a number of options that determine how Hakari
instances are generated.
Implementations
Returns the set of operations that need to be performed to add the workspace-hack dependency to the given set of workspace crates.
Also includes remove operations for the workspace-hack dependency from excluded crates.
Returns None
if the hakari package wasn’t specified at construction time.
Requires the cli-support
feature to be enabled.
pub fn add_dep_ops(
&self,
workspace_set: &PackageSet<'g>,
force: bool
) -> Option<WorkspaceOps<'g, '_>>
pub fn add_dep_ops(
&self,
workspace_set: &PackageSet<'g>,
force: bool
) -> Option<WorkspaceOps<'g, '_>>
Returns the set of operations that need to be performed to add the workspace-hack dependency to the given set of workspace crates.
Returns None
if the hakari package wasn’t specified at construction time.
Requires the cli-support
feature to be enabled.
pub fn remove_dep_ops(
&self,
workspace_set: &PackageSet<'g>,
force: bool
) -> Option<WorkspaceOps<'g, '_>>
pub fn remove_dep_ops(
&self,
workspace_set: &PackageSet<'g>,
force: bool
) -> Option<WorkspaceOps<'g, '_>>
Returns the set of operations that need to be performed to remove the workspace-hack dependency from the given set of workspace crates.
Returns None
if the hakari package wasn’t specified at construction time.
Requires the cli-support
feature to be enabled.
pub fn from_summary(
graph: &'g PackageGraph,
summary: &HakariBuilderSummary
) -> Result<Self, Error>
pub fn from_summary(
graph: &'g PackageGraph,
summary: &HakariBuilderSummary
) -> Result<Self, Error>
Constructs a HakariBuilder
from a PackageGraph
and a serialized summary.
Requires the cli-support
feature to be enabled.
Returns an error if the summary references a package that’s not present, or if there was
some other issue while creating a HakariBuilder
from the summary.
Creates a new HakariBuilder
instance from a PackageGraph
.
The Hakari package itself is usually present in the workspace. If so, specify its
package ID, otherwise pass in None
.
Returns an error if a Hakari package ID is specified but it isn’t known to the graph, or isn’t in the workspace.
Returns the PackageGraph
used to construct this Hakari
instance.
Returns the Hakari package, or None
if it wasn’t passed into new
.
Reads the existing TOML file for the Hakari package from disk, returning a
HakariCargoToml
.
This can be used with Hakari::to_toml_string
to manage the
contents of the Hakari package’s TOML file on disk.
Returns an error if there was an issue reading the TOML file from disk, or None
if
this builder was created without a Hakari package.
pub fn set_platforms(
&mut self,
platforms: impl IntoIterator<Item = impl Into<Cow<'static, str>>>
) -> Result<&mut Self, TargetSpecError>
pub fn set_platforms(
&mut self,
platforms: impl IntoIterator<Item = impl Into<Cow<'static, str>>>
) -> Result<&mut Self, TargetSpecError>
Sets a list of platforms for hakari
to use.
By default, hakari
unifies features that are always enabled across all platforms. If
builds are commonly performed on a few platforms, hakari
can output platform-specific
instructions for those builds.
This currently supports target triples only, without further customization around
target features or flags. In the future, this may support cfg()
expressions using
an SMT solver.
Call set_platforms
with an empty list to reset to default behavior.
Returns an error if a platform wasn’t known to target_spec
, the library hakari
uses
to resolve platforms.
Returns the platforms set through set_platforms
, or an empty list if no platforms are
set.
Sets the Cargo resolver version.
By default, HakariBuilder
uses version 2 of the Cargo
resolver. For more about Cargo resolvers, see the documentation for
CargoResolverVersion
.
Returns the current Cargo resolver version.
pub fn add_traversal_excludes<'b>(
&mut self,
excludes: impl IntoIterator<Item = &'b PackageId>
) -> Result<&mut Self, Error>
pub fn add_traversal_excludes<'b>(
&mut self,
excludes: impl IntoIterator<Item = &'b PackageId>
) -> Result<&mut Self, Error>
Pretends that the provided packages don’t exist during graph traversals.
Users may wish to not consider certain packages while figuring out the unified feature set. Setting this option prevents those packages from being considered.
Practically, this means that:
- If a workspace package is specified, Cargo build simulations for it will not be run.
- If a third-party package is specified, it will not be present in the output, nor will any transitive dependencies or features enabled by it that aren’t enabled any other way. In other words, any packages excluded during traversal are also excluded from the final output.
Returns an error if any package IDs specified aren’t known to the graph.
Returns the packages currently excluded during graph traversals.
Also returns the Hakari package if specified. This is because the Hakari package is treated as excluded while performing unification.
Returns true if a package ID is currently excluded during traversal.
Also returns true for the Hakari package if specified. This is because the Hakari package is treated as excluded by the algorithm.
Returns an error if this package ID isn’t known to the underlying graph.
pub fn add_final_excludes<'b>(
&mut self,
excludes: impl IntoIterator<Item = &'b PackageId>
) -> Result<&mut Self, Error>
pub fn add_final_excludes<'b>(
&mut self,
excludes: impl IntoIterator<Item = &'b PackageId>
) -> Result<&mut Self, Error>
Adds packages to be removed from the final output.
Unlike traversal_excludes
, these packages are considered
during traversals, but removed at the end.
Returns an error if any package IDs specified aren’t known to the graph.
Returns the packages to be removed from the final output.
Returns true if a package ID is currently excluded from the final output.
Returns an error if this package ID isn’t known to the underlying graph.
Returns true if a package ID is excluded from either the traversal or the final output.
Also returns true for the Hakari package if specified. This is because the Hakari package is treated as excluded by the algorithm.
Returns an error if this package ID isn’t known to the underlying graph.
pub fn add_registries(
&mut self,
registries: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>
) -> &mut Self
pub fn add_registries(
&mut self,
registries: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>
) -> &mut Self
Add alternate registries by (name, URL) pairs.
This is a temporary workaround until Cargo issue #9052 is resolved.
Whether and how to unify feature sets across target and host platforms.
This is an advanced feature that most users don’t need to set. For more information about
this option, see the documentation for UnifyTargetHost
.
Returns the current value of unify_target_host
.
Whether to unify feature sets for all dependencies.
By default, Hakari only produces output for dependencies that are built with more than one feature set. If set to true, Hakari will produce outputs for all dependencies, including those that don’t need to be unified.
This is rarely needed in production, and is most useful for testing and debugging scenarios.
Returns the current value of output_single_feature
.
Helpers for property testing
The methods in this section allow random instances of a HakariBuilder
to be generated, for use
in property-based testing scenarios.
Requires the proptest1
feature to be enabled.
pub fn prop010_strategy(
graph: &'g PackageGraph,
hakari_id_strategy: impl Strategy<Value = Option<&'g PackageId>> + 'g
) -> impl Strategy<Value = HakariBuilder<'g>> + 'g
pub fn prop010_strategy(
graph: &'g PackageGraph,
hakari_id_strategy: impl Strategy<Value = Option<&'g PackageId>> + 'g
) -> impl Strategy<Value = HakariBuilder<'g>> + 'g
Returns a Strategy
that generates random HakariBuilder
instances based on this graph.
Requires the proptest1
feature to be enabled.
Panics
Panics if:
- there are no packages in this
PackageGraph
, or hakari_id
is specified but it isn’t known to the graph, or isn’t in the workspace.
Converts this HakariBuilder
to a serializable summary.
Requires the cli-support
feature to be enabled.
Returns an error if there are any custom platforms. Serializing custom platforms is currently unsupported.
Verify that hakari
worked properly.
Returns Ok(())
if only one version of every third-party dependency was built, or a list of
errors if at least one third-party dependency had more than one version built.
For more about how this works, see the documentation for the verify
module.
Trait Implementations
Auto Trait Implementations
impl<'g> !RefUnwindSafe for HakariBuilder<'g>
impl<'g> Send for HakariBuilder<'g>
impl<'g> Sync for HakariBuilder<'g>
impl<'g> Unpin for HakariBuilder<'g>
impl<'g> UnwindSafe for HakariBuilder<'g>
Blanket Implementations
Mutably borrows from an owned value. Read more