Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Migration off SwiftInfo.module_name.
Browse files Browse the repository at this point in the history
- Make module alias use the direct modules instead with legacy fall back for the
  existing support.
- Validate during creation of SwiftInfo that any provided module_name matches the
  first module (if any modules are provided).

RELNOTES: None
PiperOrigin-RevId: 345237478
  • Loading branch information
thomasvl authored and swiple-rules-gardener committed Dec 2, 2020
1 parent c210804 commit 46613b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions swift/internal/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ def create_swift_info(
# was one, and if the legacy `module_name` parameter wasn't already
# given.
module_name = modules[0].name
elif module_name and modules and module_name != modules[0].name:
fail("Explicit module name should be the first provided module.")

transitive_defines = []
transitive_modules = []
Expand Down
11 changes: 9 additions & 2 deletions swift/internal/swift_module_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ load(":utils.bzl", "compact", "create_cc_info", "get_providers")
def _swift_module_alias_impl(ctx):
deps = ctx.attr.deps
module_mapping = {
dep[SwiftInfo].module_name: dep.label
module.name: dep.label
for dep in deps
if dep[SwiftInfo].module_name
for module in dep[SwiftInfo].direct_modules
}

# TODO(b/149999519): remove the support for SwiftInfo.module_name that
# didn't have any direct_modules.
for dep in deps:
swift_info = dep[SwiftInfo]
if not swift_info.direct_modules and swift_info.module_name:
module_mapping[swift_info.module_name] = dep.label

module_name = ctx.attr.module_name
if not module_name:
module_name = swift_common.derive_module_name(ctx.label)
Expand Down

0 comments on commit 46613b2

Please sign in to comment.