diff --git a/doc/BUILD.bazel b/doc/BUILD.bazel index 3a7d71565..4e3f25efe 100644 --- a/doc/BUILD.bazel +++ b/doc/BUILD.bazel @@ -13,9 +13,16 @@ _RULES_SYMBOLS = [ "swift_test", ] +_PROVIDERS_SYMBOLS = [ + "SwiftInfo", + "SwiftToolchainInfo", + "SwiftProtoInfo", + "SwiftUsageInfo", +] + write_file( - name = "gen_header", - out = "header.vm", + name = "rules_header", + out = "rules_header.vm", content = [ "", "", @@ -27,19 +34,54 @@ write_file( ], ) +write_file( + name = "providers_header", + out = "providers_header.vm", + content = [ + "", + "", + "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:", + "", + ] + [" * [{0}](#{0})".format(r) for r in _PROVIDERS_SYMBOLS] + [ + "", + ], +) + stardoc( - name = "doc", - out = "swift.md", - header_template = ":header.vm", + name = "rules_doc", + out = "rules.md_", + header_template = ":rules_header.vm", input = "//swift:swift.bzl", symbol_names = _RULES_SYMBOLS, deps = ["//swift"], ) +stardoc( + name = "providers_doc", + out = "providers.md_", + header_template = ":providers_header.vm", + input = "//swift:swift.bzl", + symbol_names = _PROVIDERS_SYMBOLS, + deps = ["//swift"], +) + # To make this test pass, run -# bazel build doc:all && cp bazel-bin/doc/swift.md doc/rules.md +# bazel build doc:all && cp bazel-bin/doc/rules.md_ doc/rules.md diff_test( - name = "test", - file1 = "swift.md", + name = "test_rules", + file1 = "rules.md_", file2 = "rules.md", ) + +# To make this test pass, run +# bazel build doc:all && cp bazel-bin/doc/providers.md_ doc/providers.md +diff_test( + name = "test_providers", + file1 = "providers.md_", + file2 = "providers.md", +) diff --git a/doc/providers.md b/doc/providers.md index 6e68f71ab..8965560ac 100644 --- a/doc/providers.md +++ b/doc/providers.md @@ -1,8 +1,4 @@ -# Providers - - - - + The providers described below are propagated and required by various Swift build rules. Clients interested in writing custom rules that interface @@ -15,9 +11,15 @@ On this page: * [SwiftToolchainInfo](#SwiftToolchainInfo) * [SwiftProtoInfo](#SwiftProtoInfo) * [SwiftUsageInfo](#SwiftUsageInfo) - + + + ## SwiftInfo +
+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 @@ -25,260 +27,93 @@ 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. -
direct_defines |
-
|
-
direct_modules |
-
|
-
direct_swiftdocs |
-
|
-
direct_swiftmodules |
-
|
-
module_name |
-
This field will be equal to the explicitly assigned module name (if present); -otherwise, it will be equal to the autogenerated module name. |
-
swift_version |
-
|
-
transitive_defines |
-
|
-
transitive_generated_headers |
-
|
-
transitive_modulemaps |
-
This field is deprecated; use |
-
transitive_modules |
-
|
-
transitive_swiftdocs |
-
|
-
transitive_swiftinterfaces |
-
|
-
transitive_swiftmodules |
-
|
-
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. |
+
+
+
+
+## SwiftProtoInfo
+
++SwiftProtoInfo(module_mappings, pbswift_files) ++ +Propagates Swift-specific information about a `proto_library`. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| module_mappings |
Sequence of structs. 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. |
+| pbswift_files | Depset of Files. The transitive Swift source files (.pb.swift) generated from the .proto files. |
+
+
+
+
## SwiftToolchainInfo
++SwiftToolchainInfo(action_configs, all_files, cc_toolchain_info, cpu, + generated_header_module_implicit_deps_providers, implicit_deps_providers, + linker_opts_producer, linker_supports_filelist, object_format, requested_features, + root_dir, supports_objc_interop, swift_worker, system_name, test_configuration, + tool_configs, unsupported_features) ++ + Propagates information about a Swift toolchain to compilation and linking rules that use the toolchain. -
action_configs |
- This field is an internal implementation detail of the build rules. |
-
all_files |
- A |
-
cc_toolchain_info |
- The |
-
command_line_copts |
-
|
-
cpu |
-
|
-
linker_opts_producer |
- Skylib The partial should be called with two arguments: -
|
-
object_format |
-
|
-
optional_implicit_deps |
-
|
-
requested_features |
-
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). |
-
required_implicit_deps |
-
|
-
root_dir |
-
|
-
supports_objc_interop |
-
|
-
swift_worker |
-
|
-
system_name |
-
|
-
test_configuration |
-
This is used, for example, with Xcode-based toolchains to ensure that the
- |
-
tool_configs |
- This field is an internal implementation detail of the build rules. |
-
unsupported_features |
-
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). |
-
depset of Files containing all the Swift toolchain files (tools, libraries, and other resource files) so they can be passed as tools to actions using this toolchain. |
+| cc_toolchain_info | The cc_common.CcToolchainInfo provider from the Bazel C++ toolchain that this Swift toolchain depends on. |
+| cpu | String. The CPU architecture that the toolchain is targeting. |
+| 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.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.None; it will always be a valid struct containing the fields described above, even if those lists are empty. |
+| linker_opts_producer | Skylib partial. A partial function that returns the flags that should be passed to Clang to link a binary or test target with the Swift runtime libraries.is_static: A Boolean value indicating whether to link against the static or dynamic runtime libraries.is_test: A Boolean value indicating whether the target being linked is a test target. |
+| linker_supports_filelist | Boolean. Indicates whether or not the toolchain's linker supports the input files passed to it via a file list. |
+| object_format | String. The object file format of the platform that the toolchain is targeting. The currently supported values are "elf" and "macho". |
+| requested_features | List of strings. 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.String. The workspace-relative root directory of the toolchain. |
+| supports_objc_interop | Boolean. Indicates whether or not the toolchain supports Objective-C interop. |
+| 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). |
+| system_name | String. The name of the operating system that the toolchain is targeting. |
+| test_configuration | Struct containing two 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.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 strings. 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.module_mappings |
-
|
-
pbswift_files |
-
|
-
+SwiftUsageInfo(toolchain) ++ A provider that indicates that Swift was used by a target or any target that it depends on, and specifically which toolchain was used. -
toolchain |
- The Swift toolchain that was used to build the targets propagating this -provider. |
-
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. | List of labels | optional | [] |
| defines | A list of defines to add to the compilation command line.name=value pairs.-D and added to the command line. Unlike copts, these flags are added for the target and every target that depends on it, so use this attribute with caution. It is preferred that you add defines directly to copts, only using this feature in the rare case that a library needs to propagate a symbol up to those that depend on it. | List of strings | optional | [] |
| deps | A list of targets that are dependencies of the target being built, which will be linked into that target.private_deps on swift_library), then targets in deps are treated as regular (non-implementation-only) imports that are propagated both to their direct and indirect (transitive) dependents.swift_c_module, swift_import and swift_library (or anything propagating SwiftInfo)cc_library (or anything propagating CcInfo)objc_library targets (or anything propagating the apple_common.Objc provider) are allowed as dependencies. On platforms that do not support Objective-C interop (such as Linux), those dependencies will be **ignored.** | List of labels | optional | [] |
-| generated_header_name | The name of the generated Objective-C interface header. This name must end with a .h extension and cannot contain any path separators.${target_name}-Swift.h.swift.no_generated_header feature enabled. | String | optional | "" |
+| generated_header_name | The name of the generated Objective-C interface header. This name must end with a .h extension and cannot contain any path separators.${target_name}-Swift.h.${target_name}-Swift.h; this can be changed using the generated_header_name attribute.$(location ...) and ["Make" variable](https://docs.bazel.build/versions/master/be/make-variables.html) expansion. | List of strings | optional | [] |
| module_name | The name of the Swift module being built.// and replacing /, :, and other non-identifier characters with underscores. | String | optional | "" |