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

Commit 46613b2

Browse files
thomasvlswiple-rules-gardener
authored andcommitted
Migration off SwiftInfo.module_name.
- 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
1 parent c210804 commit 46613b2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

swift/internal/providers.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ def create_swift_info(
346346
# was one, and if the legacy `module_name` parameter wasn't already
347347
# given.
348348
module_name = modules[0].name
349+
elif module_name and modules and module_name != modules[0].name:
350+
fail("Explicit module name should be the first provided module.")
349351

350352
transitive_defines = []
351353
transitive_modules = []

swift/internal/swift_module_alias.bzl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ load(":utils.bzl", "compact", "create_cc_info", "get_providers")
2929
def _swift_module_alias_impl(ctx):
3030
deps = ctx.attr.deps
3131
module_mapping = {
32-
dep[SwiftInfo].module_name: dep.label
32+
module.name: dep.label
3333
for dep in deps
34-
if dep[SwiftInfo].module_name
34+
for module in dep[SwiftInfo].direct_modules
3535
}
3636

37+
# TODO(b/149999519): remove the support for SwiftInfo.module_name that
38+
# didn't have any direct_modules.
39+
for dep in deps:
40+
swift_info = dep[SwiftInfo]
41+
if not swift_info.direct_modules and swift_info.module_name:
42+
module_mapping[swift_info.module_name] = dep.label
43+
3744
module_name = ctx.attr.module_name
3845
if not module_name:
3946
module_name = swift_common.derive_module_name(ctx.label)

0 commit comments

Comments
 (0)