Skip to content

Commit

Permalink
Remove old-style provider support from collect_transitive
Browse files Browse the repository at this point in the history
No callers of `collect_transitive()` pass old string provider references.

Closes #160.

RELNOTES: None.
PiperOrigin-RevId: 237805833
  • Loading branch information
kastiglione authored and allevato committed Mar 25, 2019
1 parent 3de5209 commit 9a2269c
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions swift/internal/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
"""Common utility definitions used by various BUILD rules."""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//lib:types.bzl", "types")

def collect_transitive(targets, provider, key, direct = None):
"""Returns a `depset` that collects transitive information from providers.
Args:
targets: The list of targets whose providers should be accessed.
provider: The provider containing the data to be merged. This can either be
a declared provider object or a string denoting an old-style provider.
If the provider is not propagated by the target, it is ignored.
provider: The provider containing the data to be merged. If the provider is
not propagated by the target, it is ignored.
key: The key containing the data in the provider to be collected.
direct: A list of values that should become the direct members of the
`depset`, if any.
Expand All @@ -33,18 +31,11 @@ def collect_transitive(targets, provider, key, direct = None):
A `depset` whose transitive members are the value of the key in the given
provider of each of the targets.
"""
if types.is_string(provider):
transitives = [
getattr(getattr(target, provider), key)
for target in targets
if hasattr(target, provider)
]
else:
transitives = [
getattr(target[provider], key)
for target in targets
if provider in target
]
transitives = [
getattr(target[provider], key)
for target in targets
if provider in target
]
if direct:
return depset(direct = direct, transitive = transitives)
return depset(transitive = transitives)
Expand Down

0 comments on commit 9a2269c

Please sign in to comment.