You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add clang_deps attr to mixed_language_library (#1540)
At Square, we're using a headermap for the Swift generated header, so
that the objective-C half of a module is able to import it using
`#import <Module/Module-Swift.h>`.
This headermap target can't be placed in `deps`, as doing so creates a
dependency cycle.
Here is an example of what the use case looks like:
master...jschear:rules_swift:js/demo_swift_header_imports_in_clang_half
```
header_map(
name = "swift_headermap",
module_name = "MixedAnswer",
propagate_include = False,
# This relies on us knowing the naming scheme used for internal targets in mixed_language_library, which is not ideal.
deps = ["MixedAnswer_swift"],
)
mixed_language_library(
name = "MixedAnswer",
hdrs = ["MixedAnswer.h"],
clang_copts = [
"-I$(execpath :swift_headermap)",
"-I.",
],
clang_deps = [":swift_headermap"],
clang_srcs = [
"MixedAnswer.m",
"MixedAnswerPrivate.m",
"MixedAnswerPrivate.h",
],
enable_modules = True,
module_name = "MixedAnswer",
swift_srcs = [
"MixedAnswer.swift",
],
target_compatible_with = ["@platforms//os:macos"],
)
```
Creates a mixed language library from a Clang and Swift library target pair.
1078
1078
1079
-
Note: In the future `swift_library` will support mixed-langauge libraries.
1079
+
Note: In the future `swift_library` will support mixed-language libraries.
1080
1080
Once that is the case, this macro will be deprecated.
1081
1081
1082
1082
@@ -1090,6 +1090,7 @@ Once that is the case, this macro will be deprecated.
1090
1090
| <aid="mixed_language_library-alwayslink"></a>alwayslink | If true, any binary that depends (directly or indirectly) on this library will link in all the object files for the files listed in `clang_srcs` and `swift_srcs`, even if some contain no symbols referenced by the binary. This is useful if your code isn't explicitly called by code in the binary; for example, if you rely on runtime checks for protocol conformances added in extensions in the library but do not directly reference any other symbols in the object file that adds that conformance. |`False`|
1091
1091
| <aid="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`. |`[]`|
1092
1092
| <aid="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. |`[]`|
1093
+
| <aid="mixed_language_library-clang_deps"></a>clang_deps | A list of targets that are dependencies of only the clang library. |`[]`|
1093
1094
| <aid="mixed_language_library-clang_srcs"></a>clang_srcs | The list of C, C++, Objective-C, or Objective-C++ sources for the clang library. | none |
1094
1095
| <aid="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. |`[]`|
1095
1096
| <aid="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`|
0 commit comments