diff --git a/doc/rules.md b/doc/rules.md
index 117be3360..3b9c54b78 100644
--- a/doc/rules.md
+++ b/doc/rules.md
@@ -991,11 +991,11 @@ swift_library(
## mixed_language_library
-mixed_language_library(name, alwayslink, clang_copts, clang_defines, clang_srcs, enable_modules,
- hdrs, includes, linkopts, module_map, module_name, non_arc_srcs, private_deps,
- sdk_dylibs, sdk_frameworks, swift_copts, swift_defines, swift_srcs,
- swiftc_inputs, textual_hdrs, umbrella_header, weak_sdk_frameworks, deps,
- kwargs)
+mixed_language_library(name, alwayslink, clang_copts, clang_defines, clang_srcs, data,
+ enable_modules, hdrs, includes, linkopts, module_map, module_name,
+ non_arc_srcs, private_deps, sdk_dylibs, sdk_frameworks, swift_copts,
+ swift_defines, swift_srcs, swiftc_inputs, textual_hdrs, umbrella_header,
+ weak_sdk_frameworks, deps, kwargs)
Creates a mixed language library from a Clang and Swift library target pair.
@@ -1014,6 +1014,7 @@ Once that is the case, this macro will be deprecated.
| clang_copts | The compiler flags for the clang library. These will only be used for the clang library. If you want them to affect the swift library as well, you need to pass them with `-Xcc` in `swift_copts`. | `[]` |
| clang_defines | Extra clang `-D` flags to pass to the compiler. They should be in the form `KEY=VALUE` or simply `KEY` and are passed not only to the compiler for this target (as `clang_copts` are) but also to all dependers of this target. Subject to "Make variable" substitution and Bourne shell tokenization. | `[]` |
| clang_srcs | The list of C, C++, Objective-C, or Objective-C++ sources for the clang library. | none |
+| data | The list of files needed by this target at runtime.
Files and targets named in the `data` attribute will appear in the `*.runfiles` area of this target, if it has one. This may include data files needed by a binary or library, or other programs needed by it. | `[]` |
| enable_modules | Enables clang module support (via `-fmodules`). Setting this to `True` will allow you to `@import` system headers and other targets: `@import UIKit;` `@import path_to_package_target;`. | `False` |
| hdrs | The list of C, C++, Objective-C, or Objective-C++ header files published by this library to be included by sources in dependent rules. This can't include `umbrella_header`. | `[]` |
| includes | List of `#include`/`#import` search paths to add to this target and all depending targets. | `[]` |
diff --git a/mixed_language/internal/library.bzl b/mixed_language/internal/library.bzl
index c22fc8eb2..b7c8a238f 100644
--- a/mixed_language/internal/library.bzl
+++ b/mixed_language/internal/library.bzl
@@ -181,13 +181,20 @@ def _mixed_language_library_impl(ctx):
)
return [
- DefaultInfo(files = depset(
- outputs,
- transitive = [
- swift_target[DefaultInfo].files,
- clang_target[DefaultInfo].files,
- ],
- )),
+ DefaultInfo(
+ files = depset(
+ outputs,
+ transitive = [
+ swift_target[DefaultInfo].files,
+ clang_target[DefaultInfo].files,
+ ],
+ ),
+ runfiles = ctx.runfiles(
+ collect_data = True,
+ collect_default = True,
+ files = ctx.files.data,
+ ),
+ ),
cc_info,
coverage_common.instrumented_files_info(
ctx,
@@ -218,6 +225,16 @@ The non-Swift portion of the mixed language module.
mandatory = True,
providers = [CcInfo],
),
+ "data": attr.label_list(
+ allow_files = True,
+ doc = """\
+The list of files needed by this target at runtime.
+
+Files and targets named in the `data` attribute will appear in the `*.runfiles`
+area of this target, if it has one. This may include data files needed by a
+binary or library, or other programs needed by it.
+""",
+ ),
"deps": swift_deps_attr(
aspects = [swift_clang_module_aspect],
doc = "Dependencies of the target being built.",
diff --git a/mixed_language/mixed_language_library.bzl b/mixed_language/mixed_language_library.bzl
index 9e27d78be..2c62d3baf 100644
--- a/mixed_language/mixed_language_library.bzl
+++ b/mixed_language/mixed_language_library.bzl
@@ -39,6 +39,7 @@ def mixed_language_library(
clang_copts = [],
clang_defines = [],
clang_srcs,
+ data = [],
enable_modules = False,
hdrs = [],
includes = [],
@@ -84,6 +85,12 @@ def mixed_language_library(
substitution and Bourne shell tokenization.
clang_srcs: The list of C, C++, Objective-C, or Objective-C++ sources
for the clang library.
+ data: The list of files needed by this target at runtime.
+
+ Files and targets named in the `data` attribute will appear in the
+ `*.runfiles` area of this target, if it has one. This may include
+ data files needed by a binary or library, or other programs needed
+ by it.
enable_modules: Enables clang module support (via `-fmodules`). Setting
this to `True` will allow you to `@import` system headers and other
targets: `@import UIKit;` `@import path_to_package_target;`.
@@ -371,6 +378,7 @@ a mixed language Swift library, use a clang only library rule like \
name = name,
aspect_hints = aspect_hints,
clang_target = ":" + clang_library_name,
+ data = data,
features = features,
module_map = module_map,
module_name = module_name,