The providers described below are propagated and required by various Swift
build rules. Clients interested in writing custom rules that interface
with the rules in this package should use these providers to communicate
with the Swift build rules as needed.
On this page:
SwiftInfo(direct_modules, transitive_modules)
Contains information about the compiled artifacts of a Swift module.
This provider contains a large number of fields and many custom rules may not
need to set all of them. Instead of constructing a SwiftInfo
provider
directly, consider using the swift_common.create_swift_info
function, which
has reasonable defaults for any fields not explicitly set.
FIELDS
Name |
Description |
direct_modules |
List of values returned from swift_common.create_module . The modules (both Swift and C/Objective-C) emitted by the library that propagated this provider. |
transitive_modules |
Depset of values returned from swift_common.create_module . The transitive modules (both Swift and C/Objective-C) emitted by the library that propagated this provider and all of its dependencies. |
SwiftProtoCompilerInfo(bundled_proto_paths, compile, compiler_deps, internal)
Provides information needed to generate Swift code from ProtoInfo
providers
FIELDS
Name |
Description |
bundled_proto_paths |
List of proto paths for which to skip generation because they're built into the modules imported by the generated Swift proto code, e.g., SwiftProtobuf. |
compile |
A function which compiles Swift source files from ProtoInfo providers.
Args: label: The label of the target for which the Swift files are being generated. actions: The actions object used to declare the files to be generated and the actions that generate them. swift_proto_compiler_info: This SwiftProtoCompilerInfo provider. additional_compiler_info: Additional information passed from the target target to the compiler. proto_infos: The list of ProtoInfo providers to compile. module_mappings: The module_mappings field of the SwiftProtoInfo for the target.
Returns: A list of .swift Files generated by the compiler. |
compiler_deps |
List of targets providing SwiftInfo and CcInfo. These are added as dependencies to the swift compile action of the swift_proto_library. Typically these are proto runtime libraries.
Well Known Types should be added as dependencies of the swift_proto_library targets as needed to avoid compiling them unnecessarily. |
internal |
Opaque struct passing information from the compiler target to the compile function. |
SwiftProtoInfo(module_name, module_mappings, direct_pbswift_files, pbswift_files)
Propagates Swift-specific information about a proto_library
.
FIELDS
Name |
Description |
module_name |
The name of the Swift module compiled from the swift_proto_library which produced this provider. |
module_mappings |
list of struct s. Each struct contains module_name and proto_file_paths fields that denote the transitive mappings from .proto files to Swift modules. This allows messages that reference messages in other libraries to import those modules in generated code. |
direct_pbswift_files |
list of File s. The Swift source files (e.g. .pb.swift ) generated from the ProtoInfo providers of the direct proto dependencies of the swift_proto_library target. |
pbswift_files |
depset of File s. The Swift source files (e.g. .pb.swift ) generated from the ProtoInfo providers of the direct and transitive transitive proto dependencies of the swift_proto_library target. |
SwiftToolchainInfo(action_configs, cc_toolchain_info, clang_implicit_deps_providers,
const_protocols_to_gather, developer_dirs, entry_point_linkopts_provider,
feature_allowlists, generated_header_module_implicit_deps_providers,
implicit_deps_providers, package_configurations, requested_features, root_dir,
swift_worker, test_configuration, tool_configs, unsupported_features)
Propagates information about a Swift toolchain to compilation and linking rules
that use the toolchain.
FIELDS
Name |
Description |
action_configs |
This field is an internal implementation detail of the build rules. |
cc_toolchain_info |
The cc_common.CcToolchainInfo provider from the Bazel C++ toolchain that this Swift toolchain depends on. |
clang_implicit_deps_providers |
A struct with the following fields, which represent providers from targets that should be added as implicit dependencies of any precompiled explicit C/Objective-C modules:
* cc_infos : A list of CcInfo providers from targets specified as the toolchain's implicit dependencies. * objc_infos : A list of apple_common.Objc providers from targets specified as the toolchain's implicit dependencies. * swift_infos : A list of SwiftInfo providers from targets specified as the toolchain's implicit dependencies.
For ease of use, this field is never None ; it will always be a valid struct containing the fields described above, even if those lists are empty. |
const_protocols_to_gather |
File . A JSON file specifying a list of protocols for extraction of conformances' const values. |
developer_dirs |
A list of structs containing the following fields:* developer_path_label : A string representing the type of developer path. * path : A string representing the path to the developer framework. |
entry_point_linkopts_provider |
A function that returns flags that should be passed to the linker to control the name of the entry point of a linked binary for rules that customize their entry point. This function must take the following keyword arguments: * entry_point_name : The name of the entry point function, as was passed to the Swift compiler using the -entry-point-function-name flag. It must return a struct with the following fields: * linkopts : A list of strings that will be passed as additional linker flags when linking a binary with a custom entry point. |
feature_allowlists |
A list of SwiftFeatureAllowlistInfo providers that allow or prohibit packages from requesting or disabling features. |
generated_header_module_implicit_deps_providers |
A struct with the following fields, which are providers from targets that should be treated as compile-time inputs to actions that precompile the explicit module for the generated Objective-C header of a Swift module:
* cc_infos : A list of CcInfo providers from targets specified as the toolchain's implicit dependencies. * objc_infos : A list of apple_common.Objc providers from targets specified as the toolchain's implicit dependencies. * swift_infos : A list of SwiftInfo providers from targets specified as the toolchain's implicit dependencies.
This is used to provide modular dependencies for the fixed inclusions (Darwin, Foundation) that are unconditionally emitted in those files.
For ease of use, this field is never None ; it will always be a valid struct containing the fields described above, even if those lists are empty. |
implicit_deps_providers |
A struct with the following fields, which represent providers from targets that should be added as implicit dependencies of any Swift compilation or linking target (but not to precompiled explicit C/Objective-C modules):
* cc_infos : A list of CcInfo providers from targets specified as the toolchain's implicit dependencies. * objc_infos : A list of apple_common.Objc providers from targets specified as the toolchain's implicit dependencies. * swift_infos : A list of SwiftInfo providers from targets specified as the toolchain's implicit dependencies.
For ease of use, this field is never None ; it will always be a valid struct containing the fields described above, even if those lists are empty. |
package_configurations |
A list of SwiftPackageConfigurationInfo providers that specify additional compilation configuration options that are applied to targets on a per-package basis. |
requested_features |
List of string s. Features that should be implicitly enabled by default for targets built using this toolchain, unless overridden by the user by listing their negation in the features attribute of a target/package or in the --features command line flag.
These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). |
root_dir |
String . The workspace-relative root directory of the toolchain. |
swift_worker |
File . The executable representing the worker executable used to invoke the compiler and other Swift tools (for both incremental and non-incremental compiles). |
test_configuration |
Struct containing the following fields:
* env : A dict of environment variables to be set when running tests that were built with this toolchain.
* execution_requirements : A dict of execution requirements for tests that were built with this toolchain.
* uses_xctest_bundles : A Boolean value indicating whether test targets should emit .xctest bundles that are launched with the xctest tool.
This is used, for example, with Xcode-based toolchains to ensure that the xctest helper and coverage tools are found in the correct developer directory when running tests. |
tool_configs |
This field is an internal implementation detail of the build rules. |
unsupported_features |
List of string s. Features that should be implicitly disabled by default for targets built using this toolchain, unless overridden by the user by listing them in the features attribute of a target/package or in the --features command line flag.
These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). |