Skip to content

Commit 22b76e9

Browse files
brentleyjonesVakhid Betrakhmadov
authored andcommitted
Add data attribute to mixed_language_library (bazelbuild#1450)
1 parent 5bb185c commit 22b76e9

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

doc/rules.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,11 @@ swift_library(
991991
## mixed_language_library
992992

993993
<pre>
994-
mixed_language_library(<a href="#mixed_language_library-name">name</a>, <a href="#mixed_language_library-alwayslink">alwayslink</a>, <a href="#mixed_language_library-clang_copts">clang_copts</a>, <a href="#mixed_language_library-clang_defines">clang_defines</a>, <a href="#mixed_language_library-clang_srcs">clang_srcs</a>, <a href="#mixed_language_library-enable_modules">enable_modules</a>,
995-
<a href="#mixed_language_library-hdrs">hdrs</a>, <a href="#mixed_language_library-includes">includes</a>, <a href="#mixed_language_library-linkopts">linkopts</a>, <a href="#mixed_language_library-module_map">module_map</a>, <a href="#mixed_language_library-module_name">module_name</a>, <a href="#mixed_language_library-non_arc_srcs">non_arc_srcs</a>, <a href="#mixed_language_library-private_deps">private_deps</a>,
996-
<a href="#mixed_language_library-sdk_dylibs">sdk_dylibs</a>, <a href="#mixed_language_library-sdk_frameworks">sdk_frameworks</a>, <a href="#mixed_language_library-swift_copts">swift_copts</a>, <a href="#mixed_language_library-swift_defines">swift_defines</a>, <a href="#mixed_language_library-swift_srcs">swift_srcs</a>,
997-
<a href="#mixed_language_library-swiftc_inputs">swiftc_inputs</a>, <a href="#mixed_language_library-textual_hdrs">textual_hdrs</a>, <a href="#mixed_language_library-umbrella_header">umbrella_header</a>, <a href="#mixed_language_library-weak_sdk_frameworks">weak_sdk_frameworks</a>, <a href="#mixed_language_library-deps">deps</a>,
998-
<a href="#mixed_language_library-kwargs">kwargs</a>)
994+
mixed_language_library(<a href="#mixed_language_library-name">name</a>, <a href="#mixed_language_library-alwayslink">alwayslink</a>, <a href="#mixed_language_library-clang_copts">clang_copts</a>, <a href="#mixed_language_library-clang_defines">clang_defines</a>, <a href="#mixed_language_library-clang_srcs">clang_srcs</a>, <a href="#mixed_language_library-data">data</a>,
995+
<a href="#mixed_language_library-enable_modules">enable_modules</a>, <a href="#mixed_language_library-hdrs">hdrs</a>, <a href="#mixed_language_library-includes">includes</a>, <a href="#mixed_language_library-linkopts">linkopts</a>, <a href="#mixed_language_library-module_map">module_map</a>, <a href="#mixed_language_library-module_name">module_name</a>,
996+
<a href="#mixed_language_library-non_arc_srcs">non_arc_srcs</a>, <a href="#mixed_language_library-private_deps">private_deps</a>, <a href="#mixed_language_library-sdk_dylibs">sdk_dylibs</a>, <a href="#mixed_language_library-sdk_frameworks">sdk_frameworks</a>, <a href="#mixed_language_library-swift_copts">swift_copts</a>,
997+
<a href="#mixed_language_library-swift_defines">swift_defines</a>, <a href="#mixed_language_library-swift_srcs">swift_srcs</a>, <a href="#mixed_language_library-swiftc_inputs">swiftc_inputs</a>, <a href="#mixed_language_library-textual_hdrs">textual_hdrs</a>, <a href="#mixed_language_library-umbrella_header">umbrella_header</a>,
998+
<a href="#mixed_language_library-weak_sdk_frameworks">weak_sdk_frameworks</a>, <a href="#mixed_language_library-deps">deps</a>, <a href="#mixed_language_library-kwargs">kwargs</a>)
999999
</pre>
10001000

10011001
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.
10141014
| <a id="mixed_language_library-clang_copts"></a>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`. | `[]` |
10151015
| <a id="mixed_language_library-clang_defines"></a>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. | `[]` |
10161016
| <a id="mixed_language_library-clang_srcs"></a>clang_srcs | The list of C, C++, Objective-C, or Objective-C++ sources for the clang library. | none |
1017+
| <a id="mixed_language_library-data"></a>data | The list of files needed by this target at runtime.<br><br>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. | `[]` |
10171018
| <a id="mixed_language_library-enable_modules"></a>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` |
10181019
| <a id="mixed_language_library-hdrs"></a>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`. | `[]` |
10191020
| <a id="mixed_language_library-includes"></a>includes | List of `#include`/`#import` search paths to add to this target and all depending targets. | `[]` |

mixed_language/internal/library.bzl

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,20 @@ def _mixed_language_library_impl(ctx):
181181
)
182182

183183
return [
184-
DefaultInfo(files = depset(
185-
outputs,
186-
transitive = [
187-
swift_target[DefaultInfo].files,
188-
clang_target[DefaultInfo].files,
189-
],
190-
)),
184+
DefaultInfo(
185+
files = depset(
186+
outputs,
187+
transitive = [
188+
swift_target[DefaultInfo].files,
189+
clang_target[DefaultInfo].files,
190+
],
191+
),
192+
runfiles = ctx.runfiles(
193+
collect_data = True,
194+
collect_default = True,
195+
files = ctx.files.data,
196+
),
197+
),
191198
cc_info,
192199
coverage_common.instrumented_files_info(
193200
ctx,
@@ -218,6 +225,16 @@ The non-Swift portion of the mixed language module.
218225
mandatory = True,
219226
providers = [CcInfo],
220227
),
228+
"data": attr.label_list(
229+
allow_files = True,
230+
doc = """\
231+
The list of files needed by this target at runtime.
232+
233+
Files and targets named in the `data` attribute will appear in the `*.runfiles`
234+
area of this target, if it has one. This may include data files needed by a
235+
binary or library, or other programs needed by it.
236+
""",
237+
),
221238
"deps": swift_deps_attr(
222239
aspects = [swift_clang_module_aspect],
223240
doc = "Dependencies of the target being built.",

mixed_language/mixed_language_library.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def mixed_language_library(
3939
clang_copts = [],
4040
clang_defines = [],
4141
clang_srcs,
42+
data = [],
4243
enable_modules = False,
4344
hdrs = [],
4445
includes = [],
@@ -84,6 +85,12 @@ def mixed_language_library(
8485
substitution and Bourne shell tokenization.
8586
clang_srcs: The list of C, C++, Objective-C, or Objective-C++ sources
8687
for the clang library.
88+
data: The list of files needed by this target at runtime.
89+
90+
Files and targets named in the `data` attribute will appear in the
91+
`*.runfiles` area of this target, if it has one. This may include
92+
data files needed by a binary or library, or other programs needed
93+
by it.
8794
enable_modules: Enables clang module support (via `-fmodules`). Setting
8895
this to `True` will allow you to `@import` system headers and other
8996
targets: `@import UIKit;` `@import path_to_package_target;`.
@@ -371,6 +378,7 @@ a mixed language Swift library, use a clang only library rule like \
371378
name = name,
372379
aspect_hints = aspect_hints,
373380
clang_target = ":" + clang_library_name,
381+
data = data,
374382
features = features,
375383
module_map = module_map,
376384
module_name = module_name,

0 commit comments

Comments
 (0)