Skip to content
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

Add data attribute to mixed_language_library #1450

Merged
Merged
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
11 changes: 6 additions & 5 deletions doc/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -1064,11 +1064,11 @@ swift_library(
## mixed_language_library

<pre>
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>,
<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>,
<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>,
<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>,
<a href="#mixed_language_library-kwargs">kwargs</a>)
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>,
<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>,
<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>,
<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>,
<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>)
</pre>

Creates a mixed language library from a Clang and Swift library target pair.
Expand All @@ -1087,6 +1087,7 @@ Once that is the case, this macro will be deprecated.
| <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`. | `[]` |
| <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. | `[]` |
| <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 |
| <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. | `[]` |
| <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` |
| <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`. | `[]` |
| <a id="mixed_language_library-includes"></a>includes | List of `#include`/`#import` search paths to add to this target and all depending targets. | `[]` |
Expand Down
31 changes: 24 additions & 7 deletions mixed_language/internal/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -206,6 +213,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.",
Expand Down
8 changes: 8 additions & 0 deletions mixed_language/mixed_language_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def mixed_language_library(
clang_copts = [],
clang_defines = [],
clang_srcs,
data = [],
enable_modules = False,
hdrs = [],
includes = [],
Expand Down Expand Up @@ -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;`.
Expand Down Expand Up @@ -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,
Expand Down