Skip to content

Commit c6553ef

Browse files
allevatobrentleyjones
authored andcommitted
Remove support for the objc_library.module_map attribute in swift_clang_module_aspect
Targets should use `swift_interop_hint` instead to support custom module maps. PiperOrigin-RevId: 485148245 (cherry picked from commit b75dac9) Signed-off-by: Brentley Jones <[email protected]>
1 parent 23752b1 commit c6553ef

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

swift/swift_clang_module_aspect.bzl

+23-26
Original file line numberDiff line numberDiff line change
@@ -189,31 +189,31 @@ def _generate_module_map(
189189
return module_map_file
190190

191191
def _objc_library_module_info(aspect_ctx):
192-
"""Returns the `module_name` and `module_map` attrs for an `objc_library`.
192+
"""Returns the `module_name` attribute for an `objc_library`.
193193
194194
Args:
195195
aspect_ctx: The aspect context.
196196
197197
Returns:
198-
A tuple containing the module name (a string) and the module map file (a
199-
`File`) specified as attributes on the `objc_library`. These values may
200-
be `None`.
198+
The module name (a string) specified as an attribute on the
199+
`objc_library`. This may be `None`.
201200
"""
202201
attr = aspect_ctx.rule.attr
203202

204203
# TODO(b/195019413): Deprecate the use of these attributes and use
205204
# `swift_interop_hint` to customize `objc_*` targets' module names and
206205
# module maps.
207206
module_name = getattr(attr, "module_name", None)
208-
module_map_file = None
209207

210-
module_map_target = getattr(attr, "module_map", None)
211-
if module_map_target:
212-
module_map_files = module_map_target.files.to_list()
213-
if module_map_files:
214-
module_map_file = module_map_files[0]
208+
# TODO(b/195019413): Remove this when the `module_map` attribute is deleted.
209+
if getattr(attr, "module_map", None):
210+
fail(
211+
"The `module_map` attribute on `objc_library` is no longer " +
212+
"supported. Use `swift_interop_hint` instead to customize the " +
213+
"module map for a target.",
214+
)
215215

216-
return module_name, module_map_file
216+
return module_name
217217

218218
def _module_info_for_target(
219219
target,
@@ -253,33 +253,30 @@ def _module_info_for_target(
253253
):
254254
return None, None
255255

256-
module_map_file = None
257-
258256
if not module_name:
259257
if apple_common.Objc not in target:
260258
return None, None
261259

262260
if aspect_ctx.rule.kind == "objc_library":
263-
module_name, module_map_file = _objc_library_module_info(aspect_ctx)
261+
module_name = _objc_library_module_info(aspect_ctx)
264262

265263
# If it was an `objc_library` without an explicit module name, or it
266264
# was some other `Objc`-providing target, derive the module name
267265
# now.
268266
if not module_name:
269267
module_name = derive_swift_module_name(target.label)
270268

271-
# If we didn't get a module map above, generate it now.
272-
if not module_map_file:
273-
module_map_file = _generate_module_map(
274-
actions = aspect_ctx.actions,
275-
aspect_ctx = aspect_ctx,
276-
compilation_context = compilation_context,
277-
dependent_module_names = dependent_module_names,
278-
exclude_headers = exclude_headers,
279-
feature_configuration = feature_configuration,
280-
module_name = module_name,
281-
target = target,
282-
)
269+
module_map_file = _generate_module_map(
270+
actions = aspect_ctx.actions,
271+
aspect_ctx = aspect_ctx,
272+
compilation_context = compilation_context,
273+
dependent_module_names = dependent_module_names,
274+
exclude_headers = exclude_headers,
275+
feature_configuration = feature_configuration,
276+
module_name = module_name,
277+
target = target,
278+
)
279+
283280
return module_name, module_map_file
284281

285282
def _handle_module(

0 commit comments

Comments
 (0)