Skip to content

Upstream: Update the API of swift_common.compile_module_interface. #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,22 @@ Compiles a Swift module interface.

**RETURNS**

A Swift module context (as returned by `create_swift_module_context`)
that contains the Swift (and potentially C/Objective-C) compilation
prerequisites of the compiled module. This should typically be
propagated by a `SwiftInfo` provider of the calling rule, and the
`CcCompilationContext` inside the Clang module substructure should be
propagated by the `CcInfo` provider of the calling rule.
A `struct` with the following fields:

* `module_context`: A Swift module context (as returned by
`create_swift_module_context`) that contains the Swift (and
potentially C/Objective-C) compilation prerequisites of the compiled
module. This should typically be propagated by a `SwiftInfo`
provider of the calling rule, and the `CcCompilationContext` inside
the Clang module substructure should be propagated by the `CcInfo`
provider of the calling rule.

* `supplemental_outputs`: A `struct` representing supplemental,
optional outputs. Its fields are:

* `indexstore_directory`: A directory-type `File` that represents
the indexstore output files created when the feature
`swift.index_while_building` is enabled.


<a id="swift_common.configure_features"></a>
Expand Down
30 changes: 23 additions & 7 deletions swift/internal/compiling.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,22 @@ def compile_module_interface(
`run_toolchain_action`.

Returns:
A Swift module context (as returned by `create_swift_module_context`)
that contains the Swift (and potentially C/Objective-C) compilation
prerequisites of the compiled module. This should typically be
propagated by a `SwiftInfo` provider of the calling rule, and the
`CcCompilationContext` inside the Clang module substructure should be
propagated by the `CcInfo` provider of the calling rule.
A `struct` with the following fields:

* `module_context`: A Swift module context (as returned by
`create_swift_module_context`) that contains the Swift (and
potentially C/Objective-C) compilation prerequisites of the compiled
module. This should typically be propagated by a `SwiftInfo`
provider of the calling rule, and the `CcCompilationContext` inside
the Clang module substructure should be propagated by the `CcInfo`
provider of the calling rule.

* `supplemental_outputs`: A `struct` representing supplemental,
optional outputs. Its fields are:

* `indexstore_directory`: A directory-type `File` that represents
the indexstore output files created when the feature
`swift.index_while_building` is enabled.
"""
swiftmodule_file = actions.declare_file("{}.swiftmodule".format(module_name))

Expand Down Expand Up @@ -308,7 +318,13 @@ def compile_module_interface(
),
)

return module_context
return struct(
module_context = module_context,
supplemental_outputs = struct(
# TODO: b/401305010 - Generate indexstore when requested.
indexstore_directory = None,
),
)

def compile(
*,
Expand Down
5 changes: 3 additions & 2 deletions swift/swift_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,17 @@ def _swift_import_impl(ctx):
swift_infos = get_providers(deps, SwiftInfo)

if swiftinterface:
module_context = compile_module_interface(
compile_result = compile_module_interface(
actions = ctx.actions,
compilation_contexts = get_compilation_contexts(ctx.attr.deps),
feature_configuration = feature_configuration,
module_name = ctx.attr.module_name,
swiftinterface_file = swiftinterface,
swift_infos = swift_infos,
swift_toolchain = swift_toolchain,
target_name = ctx.attr.name,
target_name = ctx.label.name,
)
module_context = compile_result.module_context
swift_outputs = [
module_context.swift.swiftmodule,
] + compact([module_context.swift.swiftdoc])
Expand Down