You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assure trait-guarded dependencies are not included in resolution; precompute enabled traits before resolution (#8852)
Trait-guarded dependencies were still being considered during dependency
resolution, when they should be excluded if they aren't being used in
any other scenario. Additionally, enabled traits should be pre-computed
before entering the resolution stage in order to avoid possible race
conditions when navigating through the dependency graph nodes.
### Modifications:
Since we have the `--experimental-prune-unused-dependencies` feature
behind an experimental flag, we'll now consider an alternate path that
will prune trait-guarded package dependencies from the dependency graph
**_if and only if_** said dependency is not used in any other unguarded
context.
A dictionary wrapper titled `EnabledTraitsMap` is used to store the
enabled traits per package for the package graph and is stored as a
property within the `Workspace`, with some additional behaviour to
return a `["default"]` set of traits if the package has not yet been
stored in the dictionary, rather than returning `nil`.
Following this behaviour, when passing a set of traits to methods that
require them (e.g. for dependency computation, enabled trait
computation, etc.) we now require that it is not Optional, since the
checks done on a `nil` set of traits were redundant.
SwiftCommandState now also stores a `TraitConfiguration`, since we'll
want access to this across multiple `SwiftCommand`s, and it is
essentially a part of the state anyhow. `TraitOptions` is now included
in the `GlobalOptions` for `SwiftCommand`s to supplement this, so that
when a `SwiftCommandState` is created we will have access to the
user-passed enabled traits. These options, as entitled, are available
globally across all the swift package commands, so previous properties
that declared `TraitOptions` in these commands has been removed in
favour of using it straight from the `GlobalOptions`.
### Result:
Trait-guarded dependencies are excluded from dependency resolution, and
since traits are pre-computed there should no longer be an issue with
race conditions for traits in resolution as well.
help:"One or more targets to include in the API comparison. If present, only the specified targets (and any products specified using `--products`) will be compared.")
73
73
vartargets:[String]=[]
74
74
75
-
@OptionGroup(visibility:.hidden)
76
-
packagevartraits:TraitOptions
77
-
78
75
@Option(name:.customLong("baseline-dir"),
79
76
help:"The path to a directory used to store API baseline files. If unspecified, a temporary directory will be used.")
// Build or bring up-to-date any executable host-side tools on which this plugin depends. Add them and any binary dependencies to the tool-names-to-path map.
0 commit comments