diff --git a/doc/api.md b/doc/api.md index d7372f871..7f8f8d56f 100644 --- a/doc/api.md +++ b/doc/api.md @@ -407,7 +407,7 @@ A provider whose type/layout is an implementation detail and should not ## swift_common.create_swift_module
-swift_common.create_swift_module(swiftdoc, swiftmodule, defines, swiftinterface) +swift_common.create_swift_module(swiftdoc, swiftmodule, defines, swiftsourceinfo, swiftinterface)Creates a value representing a Swift module use as a Swift dependency. @@ -420,6 +420,7 @@ Creates a value representing a Swift module use as a Swift dependency. | swiftdoc | The
.swiftdoc file emitted by the compiler for this module. | none |
| swiftmodule | The .swiftmodule file emitted by the compiler for this module. | none |
| defines | A list of defines that will be provided as copts to targets that depend on this module. If omitted, the empty list will be used. | [] |
+| swiftsourceinfo | The .swiftsourceinfo file emitted by the compiler for this module. May be None if no source info file was emitted. | None |
| swiftinterface | The .swiftinterface file emitted by the compiler for this module. May be None if no module interface file was emitted. | None |
**RETURNS**
diff --git a/swift/internal/compiling.bzl b/swift/internal/compiling.bzl
index 95cbe6515..115af509f 100644
--- a/swift/internal/compiling.bzl
+++ b/swift/internal/compiling.bzl
@@ -1751,6 +1751,7 @@ def compile(
# for that action). This guarantees some predictability.
compile_outputs.swiftmodule_file,
compile_outputs.swiftdoc_file,
+ compile_outputs.swiftsourceinfo_file,
compile_outputs.generated_header_file,
]) + other_outputs
else:
@@ -1762,6 +1763,7 @@ def compile(
compile_outputs.swiftmodule_file,
compile_outputs.swiftdoc_file,
compile_outputs.swiftinterface_file,
+ compile_outputs.swiftsourceinfo_file,
compile_outputs.generated_header_file,
compile_outputs.indexstore_directory,
]) + compile_outputs.object_files + other_outputs
@@ -1946,6 +1948,7 @@ def compile(
swiftdoc = compile_outputs.swiftdoc_file,
swiftinterface = compile_outputs.swiftinterface_file,
swiftmodule = compile_outputs.swiftmodule_file,
+ swiftsourceinfo = compile_outputs.swiftsourceinfo_file,
),
)
@@ -2192,6 +2195,10 @@ def _declare_compile_outputs(
actions = actions,
module_name = module_name,
)
+ swiftsourceinfo_file = derived_files.swiftsourceinfo(
+ actions = actions,
+ module_name = module_name,
+ )
if are_all_features_enabled(
feature_configuration = feature_configuration,
@@ -2332,6 +2339,7 @@ def _declare_compile_outputs(
swiftdoc_file = swiftdoc_file,
swiftinterface_file = swiftinterface_file,
swiftmodule_file = swiftmodule_file,
+ swiftsourceinfo_file = swiftsourceinfo_file,
)
return compile_outputs, other_outputs
diff --git a/swift/internal/derived_files.bzl b/swift/internal/derived_files.bzl
index cc8c9f7dd..e917b221e 100644
--- a/swift/internal/derived_files.bzl
+++ b/swift/internal/derived_files.bzl
@@ -270,6 +270,18 @@ def _swiftmodule(actions, module_name):
"""
return actions.declare_file("{}.swiftmodule".format(module_name))
+def _swiftsourceinfo(actions, module_name):
+ """Declares a file for the Swift sourceinfo created by a compilation rule.
+
+ Args:
+ actions: The context's actions object.
+ module_name: The name of the module being built.
+
+ Returns:
+ The declared `File`.
+ """
+ return actions.declare_file("{}.swiftsourceinfo".format(module_name))
+
def _vfsoverlay(actions, target_name):
"""Declares a file for the VFS overlay for a compilation action.
@@ -331,6 +343,7 @@ derived_files = struct(
swiftdoc = _swiftdoc,
swiftinterface = _swiftinterface,
swiftmodule = _swiftmodule,
+ swiftsourceinfo = _swiftsourceinfo,
vfsoverlay = _vfsoverlay,
whole_module_object_file = _whole_module_object_file,
xctest_runner_script = _xctest_runner_script,
diff --git a/swift/internal/providers.bzl b/swift/internal/providers.bzl
index e5557a1f8..fa07106fd 100644
--- a/swift/internal/providers.bzl
+++ b/swift/internal/providers.bzl
@@ -353,6 +353,7 @@ def create_swift_module(
swiftdoc,
swiftmodule,
defines = [],
+ swiftsourceinfo = None,
swiftinterface = None):
"""Creates a value representing a Swift module use as a Swift dependency.
@@ -362,6 +363,8 @@ def create_swift_module(
module.
defines: A list of defines that will be provided as `copts` to targets
that depend on this module. If omitted, the empty list will be used.
+ swiftsourceinfo: The `.swiftsourceinfo` file emitted by the compiler for
+ this module. May be `None` if no source info file was emitted.
swiftinterface: The `.swiftinterface` file emitted by the compiler for
this module. May be `None` if no module interface file was emitted.
@@ -374,6 +377,7 @@ def create_swift_module(
swiftdoc = swiftdoc,
swiftinterface = swiftinterface,
swiftmodule = swiftmodule,
+ swiftsourceinfo = swiftsourceinfo,
)
def create_swift_info(
diff --git a/swift/internal/swift_library.bzl b/swift/internal/swift_library.bzl
index 9a4c1477f..6060411c2 100644
--- a/swift/internal/swift_library.bzl
+++ b/swift/internal/swift_library.bzl
@@ -222,6 +222,7 @@ def _swift_library_impl(ctx):
module_context.swift.swiftdoc,
module_context.swift.swiftinterface,
module_context.swift.swiftmodule,
+ module_context.swift.swiftsourceinfo,
linking_output.library_to_link.static_library,
linking_output.library_to_link.pic_static_library,
])