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

Commit eefede5

Browse files
thomasvlswiple-rules-gardener
authored andcommitted
Clean up some old TODOs.
- Remove some deprecated fields. - Assert that atleast one module is provided. RELNOTES: None PiperOrigin-RevId: 344261262
1 parent 72f5759 commit eefede5

File tree

3 files changed

+8
-93
lines changed

3 files changed

+8
-93
lines changed

swift/internal/providers.bzl

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""Defines Starlark providers that propagated by the Swift BUILD rules."""
1616

1717
load("@bazel_skylib//lib:sets.bzl", "sets")
18-
load("@bazel_skylib//lib:types.bzl", "types")
1918

2019
SwiftInfo = provider(
2120
doc = """\
@@ -34,18 +33,6 @@ library that directly propagated this provider.
3433
"direct_modules": """\
3534
`List` of values returned from `swift_common.create_module`. The modules (both
3635
Swift and C/Objective-C) emitted by the library that propagated this provider.
37-
""",
38-
"direct_swiftdocs": """\
39-
`List` of `File`s. The Swift documentation (`.swiftdoc`) files for the library
40-
that directly propagated this provider.
41-
42-
This field is deprecated; use `direct_modules` instead.
43-
""",
44-
"direct_swiftmodules": """\
45-
`List` of `File`s. The Swift modules (`.swiftmodule`) for the library that
46-
directly propagated this provider.
47-
48-
This field is deprecated; use `direct_modules` instead.
4936
""",
5037
"module_name": """\
5138
`String`. The name of the Swift module represented by the target that directly
@@ -71,37 +58,11 @@ propagated this provider and all of its dependencies.
7158
"transitive_generated_headers": """\
7259
`Depset` of `File`s. The transitive generated header files that can be used by
7360
Objective-C sources to interop with the transitive Swift libraries.
74-
""",
75-
"transitive_modulemaps": """\
76-
`Depset` of `File`s. The transitive module map files that will be passed to
77-
Clang using the `-fmodule-map-file` option.
78-
79-
This field is deprecated; use `transitive_modules` instead.
8061
""",
8162
"transitive_modules": """\
8263
`Depset` of values returned from `swift_common.create_module`. The transitive
8364
modules (both Swift and C/Objective-C) emitted by the library that propagated
8465
this provider and all of its dependencies.
85-
""",
86-
"transitive_swiftdocs": """\
87-
`Depset` of `File`s. The transitive Swift documentation (`.swiftdoc`) files
88-
emitted by the library that propagated this provider and all of its
89-
dependencies.
90-
91-
This field is deprecated; use `transitive_modules` instead.
92-
""",
93-
"transitive_swiftinterfaces": """\
94-
`Depset` of `File`s. The transitive Swift interface (`.swiftinterface`) files
95-
emitted by the library that propagated this provider and all of its
96-
dependencies.
97-
98-
This field is deprecated; use `transitive_modules` instead.
99-
""",
100-
"transitive_swiftmodules": """\
101-
`Depset` of `File`s. The transitive Swift modules (`.swiftmodule`) emitted by
102-
the library that propagated this provider and all of its dependencies.
103-
104-
This field is deprecated; use `transitive_modules` instead.
10566
""",
10667
},
10768
)
@@ -265,9 +226,8 @@ def create_module(name, *, clang = None, swift = None):
265226
A `struct` containing the `name`, `clang`, and `swift` fields provided
266227
as arguments.
267228
"""
268-
269-
# TODO(b/149999519): Once Swift module artifacts have migrated to this API,
270-
# fail if both `clang` and `swift` are `None`.
229+
if clang == None and swift == None:
230+
fail("Must provide atleast a clang or swift module.")
271231
return struct(
272232
clang = clang,
273233
name = name,
@@ -370,13 +330,8 @@ def create_swift_info(
370330
A new `SwiftInfo` provider with the given values.
371331
"""
372332

373-
# TODO(b/149999519): Remove the legacy direct/transitive fields and this
374-
# transitional code.
375333
defines_set = sets.make()
376334
generated_headers = []
377-
swiftdocs = []
378-
swiftinterfaces = []
379-
swiftmodules = []
380335
for module in modules:
381336
swift_module = module.swift
382337
if not swift_module:
@@ -387,12 +342,6 @@ def create_swift_info(
387342
defines_set,
388343
sets.make(swift_module.defines),
389344
)
390-
if swift_module.swiftdoc:
391-
swiftdocs.append(swift_module.swiftdoc)
392-
if swift_module.swiftinterface:
393-
swiftinterfaces.append(swift_module.swiftinterface)
394-
if swift_module.swiftmodule:
395-
swiftmodules.append(swift_module.swiftmodule)
396345

397346
# If this is both a Swift and a Clang module, then the header in its
398347
# compilation context is its Swift generated header.
@@ -404,8 +353,7 @@ def create_swift_info(
404353

405354
defines = sets.to_list(defines_set)
406355

407-
# TODO(b/149999519): Remove the legacy `module_name` field and this
408-
# transitional code.
356+
# TODO(b/149999519): Remove the legacy `module_name`.
409357
if not module_name and len(modules) == 1:
410358
# Populate the module name based on the single module provided, if there
411359
# was one, and if the legacy `module_name` parameter wasn't already
@@ -414,56 +362,23 @@ def create_swift_info(
414362

415363
transitive_defines = []
416364
transitive_generated_headers = []
417-
transitive_modulemaps = []
418365
transitive_modules = []
419-
transitive_swiftdocs = []
420-
transitive_swiftinterfaces = []
421-
transitive_swiftmodules = []
422366
for swift_info in swift_infos:
423367
transitive_defines.append(swift_info.transitive_defines)
424368
transitive_generated_headers.append(
425369
swift_info.transitive_generated_headers,
426370
)
427-
transitive_modulemaps.append(swift_info.transitive_modulemaps)
428371
transitive_modules.append(swift_info.transitive_modules)
429-
transitive_swiftdocs.append(swift_info.transitive_swiftdocs)
430-
transitive_swiftinterfaces.append(swift_info.transitive_swiftinterfaces)
431-
transitive_swiftmodules.append(swift_info.transitive_swiftmodules)
432372

433-
# TODO(b/149999519): Remove `transitive_modulemaps`,
434-
# `(direct|transitive)_swift*` fields, `module_name`, and `swift_version`
435-
# after Tulsi is migrated.
436373
return SwiftInfo(
437374
direct_defines = defines,
438375
direct_modules = modules,
439-
direct_swiftdocs = swiftdocs,
440-
direct_swiftmodules = swiftmodules,
441376
module_name = module_name,
442377
swift_version = swift_version,
443378
transitive_defines = depset(defines, transitive = transitive_defines),
444379
transitive_generated_headers = depset(
445380
generated_headers,
446381
transitive = transitive_generated_headers,
447382
),
448-
transitive_modulemaps = depset(
449-
[
450-
m.clang.module_map
451-
for m in modules
452-
if m.clang and not types.is_string(m.clang.module_map)
453-
],
454-
transitive = transitive_modulemaps,
455-
),
456383
transitive_modules = depset(modules, transitive = transitive_modules),
457-
transitive_swiftdocs = depset(
458-
swiftdocs,
459-
transitive = transitive_swiftdocs,
460-
),
461-
transitive_swiftinterfaces = depset(
462-
swiftinterfaces,
463-
transitive = transitive_swiftinterfaces,
464-
),
465-
transitive_swiftmodules = depset(
466-
swiftmodules,
467-
transitive = transitive_swiftmodules,
468-
),
469384
)

test/private_deps_tests.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def private_deps_test_suite():
3737
expected_files = [
3838
"test_fixtures_private_deps_private_swift.swiftmodule",
3939
],
40-
field = "transitive_swiftmodules",
40+
field = "transitive_modules.swift!.swiftmodule",
4141
provider = "SwiftInfo",
4242
tags = [name],
4343
target_under_test = "@build_bazel_rules_swift//test/fixtures/private_deps:private_swift",
@@ -48,7 +48,7 @@ def private_deps_test_suite():
4848
expected_files = [
4949
"test_fixtures_private_deps_public_swift.swiftmodule",
5050
],
51-
field = "transitive_swiftmodules",
51+
field = "transitive_modules.swift!.swiftmodule",
5252
provider = "SwiftInfo",
5353
tags = [name],
5454
target_under_test = "@build_bazel_rules_swift//test/fixtures/private_deps:public_swift",
@@ -63,7 +63,7 @@ def private_deps_test_suite():
6363
"test_fixtures_private_deps_public_swift.swiftmodule",
6464
"-test_fixtures_private_deps_private_swift.swiftmodule",
6565
],
66-
field = "transitive_swiftmodules",
66+
field = "transitive_modules.swift!.swiftmodule",
6767
provider = "SwiftInfo",
6868
tags = [name],
6969
target_under_test = "@build_bazel_rules_swift//test/fixtures/private_deps:client_swift_deps",
@@ -94,7 +94,7 @@ def private_deps_test_suite():
9494
"/test/fixtures/private_deps/public_cc.modulemaps/module.modulemap",
9595
"-/test/fixtures/private_deps/private_cc.modulemaps/module.modulemap",
9696
],
97-
field = "transitive_modulemaps",
97+
field = "transitive_modules.clang!.module_map",
9898
provider = "SwiftInfo",
9999
tags = [name],
100100
target_under_test = "@build_bazel_rules_swift//test/fixtures/private_deps:client_cc_deps",

test/swift_through_non_swift_tests.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def swift_through_non_swift_test_suite():
3131
"test_fixtures_swift_through_non_swift_lower.swiftmodule",
3232
"test_fixtures_swift_through_non_swift_upper.swiftmodule",
3333
],
34-
field = "transitive_swiftmodules",
34+
field = "transitive_modules.swift!.swiftmodule",
3535
provider = "SwiftInfo",
3636
tags = [name],
3737
target_under_test = "@build_bazel_rules_swift//test/fixtures/swift_through_non_swift:upper",

0 commit comments

Comments
 (0)