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
Copy strict_includes into SwiftInfo provider's Clang module descriptor in swift_clang_module_aspect.
This makes it so that the `apple_common.Objc` provider no longer needs to be handled separately for compilation by Swift build APIs. (It is still used for linking until that is migrated entirely onto `CcInfo`.)
PiperOrigin-RevId: 423822059
(cherry picked from commit 8ce9595)
Copy file name to clipboardExpand all lines: doc/api.md
+8-25Lines changed: 8 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ Compiles a Swift module.
103
103
| <aid="swift_common.compile-additional_inputs"></a>additional_inputs | A list of `File`s representing additional input files that need to be passed to the Swift compile action because they are referenced by compiler flags. |`[]`|
104
104
| <aid="swift_common.compile-copts"></a>copts | A list of compiler flags that apply to the target being built. These flags, along with those from Bazel's Swift configuration fragment (i.e., `--swiftcopt` command line flags) are scanned to determine whether whole module optimization is being requested, which affects the nature of the output files. |`[]`|
105
105
| <aid="swift_common.compile-defines"></a>defines | Symbols that should be defined by passing `-D` to the compiler. |`[]`|
106
-
| <aid="swift_common.compile-deps"></a>deps | Non-private dependencies of the target being compiled. These targets are used as dependencies of both the Swift module being compiled and the Clang module for the generated header. These targets must propagate one of the following providers: `CcInfo`, `SwiftInfo`, or `apple_common.Objc`. |`[]`|
106
+
| <aid="swift_common.compile-deps"></a>deps | Non-private dependencies of the target being compiled. These targets are used as dependencies of both the Swift module being compiled and the Clang module for the generated header. These targets must propagate `CcInfo`or `SwiftInfo`. |`[]`|
107
107
| <aid="swift_common.compile-extra_swift_infos"></a>extra_swift_infos | Extra `SwiftInfo` providers that aren't contained by the `deps` of the target being compiled but are required for compilation. |`[]`|
108
108
| <aid="swift_common.compile-feature_configuration"></a>feature_configuration | A feature configuration obtained from `swift_common.configure_features`. | none |
109
109
| <aid="swift_common.compile-generated_header_name"></a>generated_header_name | The name of the Objective-C generated header that should be generated for this module. If omitted, no header will be generated. |`None`|
@@ -112,7 +112,7 @@ Compiles a Swift module.
112
112
| <aid="swift_common.compile-module_name"></a>module_name | The name of the Swift module being compiled. This must be present and valid; use `swift_common.derive_module_name` to generate a default from the target's label if needed. | none |
113
113
| <aid="swift_common.compile-package_name"></a>package_name | The semantic package of the name of the Swift module being compiled. | none |
114
114
| <aid="swift_common.compile-plugins"></a>plugins | A list of `SwiftCompilerPluginInfo` providers that represent plugins that should be loaded by the compiler. |`[]`|
115
-
| <aid="swift_common.compile-private_deps"></a>private_deps | Private (implementation-only) dependencies of the target being compiled. These are only used as dependencies of the Swift module, not of the Clang module for the generated header. These targets must propagate one of the following providers: `CcInfo`, `SwiftInfo`, or `apple_common.Objc`. |`[]`|
115
+
| <aid="swift_common.compile-private_deps"></a>private_deps | Private (implementation-only) dependencies of the target being compiled. These are only used as dependencies of the Swift module, not of the Clang module for the generated header. These targets must propagate `CcInfo`or `SwiftInfo`. |`[]`|
116
116
| <aid="swift_common.compile-srcs"></a>srcs | The Swift source files to compile. | none |
117
117
| <aid="swift_common.compile-swift_toolchain"></a>swift_toolchain | The `SwiftToolchainInfo` provider of the toolchain. | none |
118
118
| <aid="swift_common.compile-target_name"></a>target_name | The name of the target for which the code is being compiled, which is used to determine unique file paths for the outputs. | none |
@@ -215,31 +215,12 @@ An opaque value representing the feature configuration that can be
Creates a value representing a Clang module used as a Swift dependency.
222
223
223
-
Note: The `compilation_context` argument of this function is primarily
224
-
intended to communicate information *to* the Swift build rules, not to
225
-
retrieve information *back out.* In most cases, it is better to depend on
226
-
the `CcInfo` provider propagated by a Swift target to collect transitive
227
-
C/Objective-C compilation information about that target. This is because the
228
-
context used when compiling the module itself may not be the same as the
229
-
context desired when depending on it. (For example, `apple_common.Objc`
230
-
supports "strict include paths" which are only propagated to direct
231
-
dependents.)
232
-
233
-
One valid exception to the guidance above is retrieving the generated header
234
-
associated with a specific Swift module. Since the `CcInfo` provider
235
-
propagated by the library will have already merged them transitively (or,
236
-
in the case of a hypothetical custom rule that propagates multiple direct
237
-
modules, the `direct_public_headers` of the `CcInfo` would also have them
238
-
merged), it is acceptable to read the headers from the compilation context
239
-
of the module struct itself in order to associate them with the module that
240
-
generated them.
241
-
242
-
243
224
**PARAMETERS**
244
225
245
226
@@ -248,11 +229,13 @@ generated them.
248
229
| <aid="swift_common.create_clang_module-compilation_context"></a>compilation_context | A `CcCompilationContext` that contains the header files and other context (such as include paths, preprocessor defines, and so forth) needed to compile this module as an explicit module. | none |
249
230
| <aid="swift_common.create_clang_module-module_map"></a>module_map | The text module map file that defines this module. This argument may be specified as a `File` or as a `string`; in the latter case, it is assumed to be the path to a file that cannot be provided as an action input because it is outside the workspace (for example, the module map for a module from an Xcode SDK). | none |
250
231
| <aid="swift_common.create_clang_module-precompiled_module"></a>precompiled_module | A `File` representing the precompiled module (`.pcm` file) if one was emitted for the module. This may be `None` if no explicit module was built for the module; in that case, targets that depend on the module will fall back to the text module map and headers. |`None`|
232
+
| <aid="swift_common.create_clang_module-strict_includes"></a>strict_includes | A `depset` of strings representing additional Clang include paths that should be passed to the compiler when this module is a _direct_ dependency of the module being compiled. May be `None`. **This field only exists to support a specific legacy use case and should otherwise not be used, as it is fundamentally incompatible with Swift's import model.**|`None`|
251
233
252
234
**RETURNS**
253
235
254
-
A `struct` containing the `compilation_context`, `module_map`, and
255
-
`precompiled_module` fields provided as arguments.
236
+
A `struct` containing the `compilation_context`, `module_map`,
237
+
`precompiled_module`, and `strict_includes` fields provided as
0 commit comments