Skip to content

Commit

Permalink
Don't re-export the modules imported by a Swift generated header.
Browse files Browse the repository at this point in the history
This was an unintentional change in behavior from bazelbuild@5f51ca9; this puts us back to the original behavior, but leaves an API in place for finer-grained control over re-exporting modules in the future. (But the BUILD rules today don't really have the flexibility to support it yet.)

PiperOrigin-RevId: 356338982
(cherry picked from commit f45eea8)
  • Loading branch information
allevato authored and keith committed Feb 8, 2021
1 parent 18b48c2 commit dadd121
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion swift/internal/module_maps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def write_module_map(
module_map_file,
module_name,
dependent_module_names = [],
exported_module_ids = [],
public_headers = [],
public_textual_headers = [],
private_headers = [],
Expand All @@ -34,6 +35,14 @@ def write_module_map(
module_name: The name of the module being generated.
dependent_module_names: A `list` of names of Clang modules that are
direct dependencies of the target whose module map is being written.
exported_module_ids: A `list` of Clang wildcard module identifiers that
will be re-exported as part of the API of the module being written.
The values in this list should match `wildcard-module-id` as
described by
https://clang.llvm.org/docs/Modules.html#export-declaration. Common
values include the empty list to re-export nothing (except the
module's own API), or `["*"]` to re-export all modules that were
imported by the header files in the module.
public_headers: The `list` of `File`s representing the public modular
headers of the target whose module map is being written.
public_textual_headers: The `list` of `File`s representing the public
Expand All @@ -47,7 +56,12 @@ def write_module_map(
or relative to the module map file.
"""
content = 'module "{}" {{\n'.format(module_name)
content += " export *\n\n"
if exported_module_ids:
content += "".join([
" export {}\n".format(module_id)
for module_id in exported_module_ids
])
content += "\n"

content += "".join([
' header "{}"\n'.format(_header_path(
Expand Down
1 change: 1 addition & 0 deletions swift/internal/swift_clang_module_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def _generate_module_map(
write_module_map(
actions = actions,
dependent_module_names = dependent_module_names,
exported_module_ids = ["*"],
module_map_file = module_map_file,
module_name = module_name,
private_headers = private_headers,
Expand Down

0 comments on commit dadd121

Please sign in to comment.