diff --git a/WORKSPACE b/WORKSPACE index dc6ef478a..c48f7685a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -25,7 +25,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_stardoc", - patches = [], + patches = ["//doc:stardoc.pr103.patch"], sha256 = "f89bda7b6b696c777b5cf0ba66c80d5aa97a6701977d43789a9aee319eef71e8", strip_prefix = "stardoc-d93ee5347e2d9c225ad315094507e018364d5a67", urls = [ diff --git a/doc/BUILD.bazel b/doc/BUILD.bazel index 245aa23fc..dd4f80111 100644 --- a/doc/BUILD.bazel +++ b/doc/BUILD.bazel @@ -3,6 +3,9 @@ load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") _DOC_SRCS = { + "api": [ + "swift_common", + ], "aspects": [ "swift_usage_aspect", ], @@ -24,6 +27,19 @@ _DOC_SRCS = { ], } +write_file( + name = "api_header", + out = "api_header.vm", + content = [ + "", + "# Build API", + "", + "The `swift_common` module provides API access to the behavior implemented", + "by the Swift build rules, so that other custom rules can invoke Swift", + "compilation and/or linking as part of their implementation.", + ], +) + write_file( name = "aspects_header", out = "aspects_header.vm", diff --git a/doc/api.md b/doc/api.md index 656c2e6e3..472e1d935 100644 --- a/doc/api.md +++ b/doc/api.md @@ -1,70 +1,39 @@ + # Build API - - - - The `swift_common` module provides API access to the behavior implemented by the Swift build rules, so that other custom rules can invoke Swift compilation and/or linking as part of their implementation. + -On this page: - - * [swift_common.cc_feature_configuration](#swift_common.cc_feature_configuration) - * [swift_common.compilation_attrs](#swift_common.compilation_attrs) - * [swift_common.compile](#swift_common.compile) - * [swift_common.configure_features](#swift_common.configure_features) - * [swift_common.create_clang_module](#swift_common.create_clang_module) - * [swift_common.create_module](#swift_common.create_module) - * [swift_common.create_swift_info](#swift_common.create_swift_info) - * [swift_common.create_swift_module](#swift_common.create_swift_module) - * [swift_common.derive_module_name](#swift_common.derive_module_name) - * [swift_common.get_implicit_deps](#swift_common.get_implicit_deps) - * [swift_common.is_enabled](#swift_common.is_enabled) - * [swift_common.library_rule_attrs](#swift_common.library_rule_attrs) - * [swift_common.precompile_clang_module](#swift_common.precompile_clang_module) - * [swift_common.swift_clang_module_aspect](#swift_common.swift_clang_module_aspect) - * [swift_common.swift_runtime_linkopts](#swift_common.swift_runtime_linkopts) - * [swift_common.toolchain_attrs](#swift_common.toolchain_attrs) - - ## swift_common.cc_feature_configuration -
-swift_common.cc_feature_configuration(feature_configuration) ++swift_common.cc_feature_configuration(feature_configuration)Returns the C++ feature configuration in a Swift feature configuration. - -### Arguments - -
feature_configuration |
-
The Swift feature configuration, as returned from
- |
-
swift_common.configure_features
. | none |
+
+**RETURNS**
A C++ `FeatureConfiguration` value (see
-[`cc_common.configure_features`](https://docs.bazel.build/versions/master/skylark/lib/cc_common.html#configure_features)
-for more information).
+ [`cc_common.configure_features`](https://docs.bazel.build/versions/master/skylark/lib/cc_common.html#configure_features)
+ for more information).
+
+
+
-
## swift_common.compilation_attrs
--swift_common.compilation_attrs(additional_deps_aspects=[]) ++swift_common.compilation_attrs(additional_deps_aspects, requires_srcs)Returns an attribute dictionary for rules that compile Swift code. @@ -93,172 +62,97 @@ API: Each of the attribute functions in the list above also contains the attributes from the earlier items in the list. - -### Arguments - -
additional_deps_aspects |
-
A list of additional aspects that should be
-applied to |
-
deps
. Defaults to the empty list. These must be passed by the individual rules to avoid potential circular dependencies between the API and the aspects; the API loaded the aspects directly, then those aspects would not be able to load the API. | []
|
+| requires_srcs | Indicates whether the srcs
attribute should be marked as mandatory and non-empty. Defaults to True
. | True
|
+
+**RETURNS**
A new attribute dictionary that can be added to the attributes of a
-custom build rule to provide a similar interface to `swift_binary`,
-`swift_library`, and `swift_test`.
+ custom build rule to provide a similar interface to `swift_binary`,
+ `swift_library`, and `swift_test`.
+
+
+
-
## swift_common.compile
--swift_common.compile(*, actions, feature_configuration, module_name, srcs, swift_toolchain, -target_name, additional_inputs=[], bin_dir=None, copts=[], defines=[], deps=[], -generated_header_name=None, genfiles_dir=None) ++swift_common.compile(actions, feature_configuration, module_name, srcs, swift_toolchain, + target_name, workspace_name, additional_inputs, bin_dir, copts, defines, deps, + generated_header_name, genfiles_dir, private_deps)Compiles a Swift module. - -### Arguments - -
actions |
-
The context's |
-
feature_configuration |
-
A feature configuration obtained from
- |
-
module_name |
-
The name of the Swift module being compiled. This must be
-present and valid; use |
-
srcs |
-
The Swift source files to compile. |
-
swift_toolchain |
-
The |
-
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. |
-
additional_inputs |
-
A list of |
-
bin_dir |
-
The Bazel |
-
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., |
-
defines |
-
Symbols that should be defined by passing |
-
deps |
-
Dependencies of the target being compiled. These targets must
-propagate one of the following providers: |
-
generated_header_name |
-
The name of the Objective-C generated header that
-should be generated for this module. If omitted, the name
- |
-
genfiles_dir |
-
The Bazel |
-
actions
object. | none |
+| feature_configuration | A feature configuration obtained from swift_common.configure_features
. | none |
+| 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 |
+| srcs | The Swift source files to compile. | none |
+| swift_toolchain | The SwiftToolchainInfo
provider of the toolchain. | none |
+| 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 |
+| workspace_name | The name of the workspace for which the code is being compiled, which is used to determine unique file paths for some outputs. | none |
+| 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. | []
|
+| bin_dir | The Bazel *-bin
directory root. If provided, its path is used to store the cache for modules precompiled by Swift's ClangImporter, and it is added to ClangImporter's header search paths for compatibility with Bazel's C++ and Objective-C rules which support includes of generated headers from that location. | None
|
+| 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. | []
|
+| defines | Symbols that should be defined by passing -D
to the compiler. | []
|
+| 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
. | []
|
+| 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
|
+| genfiles_dir | The Bazel *-genfiles
directory root. If provided, its path is added to ClangImporter's header search paths for compatibility with Bazel's C++ and Objective-C rules which support inclusions of generated headers from that location. | None
|
+| 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
. | []
|
+
+**RETURNS**
A `struct` containing the following fields:
-* `generated_header`: A `File` representing the Objective-C header
- that was generated for the compiled module. If no header was
- generated, this field will be None.
-* `generated_header_module_map`: A `File` representing the module map
- that was generated to correspond to the generated Objective-C
- header. If no module map was generated, this field will be None.
-* `indexstore`: A `File` representing the directory that contains the
- index store data generated by the compiler if index-while-building
- is enabled. May be None if no indexing was requested.
-* `linker_flags`: A list of strings representing additional flags that
- should be passed to the linker when linking these objects into a
- binary. If there are none, this field will always be an empty list,
- never None.
-* `linker_inputs`: A list of `File`s representing additional input
- files (such as those referenced in `linker_flags`) that need to be
- available to the link action when linking these objects into a
- binary. If there are none, this field will always be an empty list,
- never None.
-* `object_files`: A list of `.o` files that were produced by the
- compiler.
-* `stats_directory`: A `File` representing the directory that contains
- the timing statistics emitted by the compiler. If no stats were
- requested, this field will be None.
-* `swiftdoc`: The `.swiftdoc` file that was produced by the compiler.
-* `swiftinterface`: The `.swiftinterface` file that was produced by
- the compiler. If no interface file was produced (because the
- toolchain does not support them or it was not requested), this field
- will be None.
-* `swiftmodule`: The `.swiftmodule` file that was produced by the
- compiler.
-
-
+ * `generated_header`: A `File` representing the Objective-C header
+ that was generated for the compiled module. If no header was
+ generated, this field will be None.
+ * `generated_header_module_map`: A `File` representing the module map
+ that was generated to correspond to the generated Objective-C
+ header. If no module map was generated, this field will be None.
+ * `indexstore`: A `File` representing the directory that contains the
+ index store data generated by the compiler if index-while-building
+ is enabled. May be None if no indexing was requested.
+ * `linker_flags`: A list of strings representing additional flags that
+ should be passed to the linker when linking these objects into a
+ binary. If there are none, this field will always be an empty list,
+ never None.
+ * `linker_inputs`: A list of `File`s representing additional input
+ files (such as those referenced in `linker_flags`) that need to be
+ available to the link action when linking these objects into a
+ binary. If there are none, this field will always be an empty list,
+ never None.
+ * `object_files`: A list of `.o` files that were produced by the
+ compiler.
+ * `precompiled_module`: A `File` representing the explicit module
+ (`.pcm`) of the Clang module for the generated header, or `None` if
+ no explicit module was generated.
+ * `swiftdoc`: The `.swiftdoc` file that was produced by the compiler.
+ * `swiftinterface`: The `.swiftinterface` file that was produced by
+ the compiler. If no interface file was produced (because the
+ toolchain does not support them or it was not requested), this field
+ will be None.
+ * `swiftmodule`: The `.swiftmodule` file that was produced by the
+ compiler.
+
+
+
+
## swift_common.configure_features
--swift_common.configure_features(ctx, swift_toolchain, *, requested_features=[], -unsupported_features=[]) ++swift_common.configure_features(ctx, swift_toolchain, requested_features, unsupported_features)Creates a feature configuration to be passed to Swift build APIs. @@ -269,99 +163,55 @@ inside the Swift one. Users who need to call C++ APIs that require a feature configuration can extract it by calling `swift_common.cc_feature_configuration(feature_configuration)`. - -### Arguments - -
ctx |
-
The rule context. |
-
swift_toolchain |
-
The |
-
requested_features |
-
The list of features to be enabled. This is
-typically obtained using the |
-
unsupported_features |
-
The list of features that are unsupported by the
-current rule. This is typically obtained using the
- |
-
SwiftToolchainInfo
provider of the toolchain being used to build. This is used to determine features that are enabled by default or unsupported by the toolchain, and the C++ toolchain associated with the Swift toolchain is used to create the underlying C++ feature configuration. | none |
+| requested_features | The list of features to be enabled. This is typically obtained using the ctx.features
field in a rule implementation function. | []
|
+| unsupported_features | The list of features that are unsupported by the current rule. This is typically obtained using the ctx.disabled_features
field in a rule implementation function. | []
|
+
+**RETURNS**
An opaque value representing the feature configuration that can be
-passed to other `swift_common` functions.
+ passed to other `swift_common` functions. Note that the structure of
+ this value should otherwise not be relied on or inspected directly.
+
+
+
-
## swift_common.create_clang_module
--swift_common.create_clang_module(*, compilation_context, module_map, precompiled_module=None) ++swift_common.create_clang_module(compilation_context, module_map, precompiled_module)Creates a value representing a Clang module used as a Swift dependency. - -### Arguments - -
compilation_context |
-
A |
-
module_map |
-
A |
-
precompiled_module |
-
A |
-
CcCompilationContext
that contains the header files, include paths, and other context necessary to compile targets that depend on this module (if using the text module map instead of the precompiled module). | none |
+| 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 |
+| 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
|
+
+**RETURNS**
A `struct` containing the `compilation_context`, `module_map`, and
-`precompiled_module` fields provided as arguments.
+ `precompiled_module` fields provided as arguments.
+
+
+
-
## swift_common.create_module
--swift_common.create_module(name, *, clang=None, swift=None) ++swift_common.create_module(name, clang, is_system, swift)Creates a value containing Clang/Swift module artifacts of a dependency. @@ -371,48 +221,29 @@ valid for both to be present; this is the case for most Swift modules, which provide both Swift module artifacts as well as a generated header/module map for Objective-C targets to depend on. - -### Arguments - -
name |
-
The name of the module. |
-
clang |
-
A value returned by |
-
swift |
-
A value returned by |
-
swift_common.create_clang_module
that contains artifacts related to Clang modules, such as a module map or precompiled module. This may be None
if the module is a pure Swift module with no generated Objective-C interface. | None
|
+| is_system | Indicates whether the module is a system module. The default value is False
. System modules differ slightly from non-system modules in the way that they are passed to the compiler. For example, non-system modules have their Clang module maps passed to the compiler in both implicit and explicit module builds. System modules, on the other hand, do not have their module maps passed to the compiler in implicit module builds because there is currently no way to indicate that modules declared in a file passed via -fmodule-map-file
should be treated as system modules even if they aren't declared with the [system]
attribute, and some system modules may not build cleanly with respect to warnings otherwise. Therefore, it is assumed that any module with is_system == True
must be able to be found using import search paths in order for implicit module builds to succeed. | False
|
+| swift | A value returned by swift_common.create_swift_module
that contains artifacts related to Swift modules, such as the .swiftmodule
, .swiftdoc
, and/or .swiftinterface
files emitted by the compiler. This may be None
if the module is a pure C/Objective-C module. | None
|
+
+**RETURNS**
+
+A `struct` containing the `name`, `clang`, `is_system`, and `swift`
+ fields provided as arguments.
+
+
+
+
## swift_common.create_swift_info
--swift_common.create_swift_info(*, module_name=None, modules=[], swift_infos=[], swift_version=None) ++swift_common.create_swift_info(direct_swift_infos, modules, swift_infos)Creates a new `SwiftInfo` provider with the given values. @@ -423,175 +254,147 @@ may not be interested in and ensures that the direct and transitive fields are set consistently. This function can also be used to do a simple merge of `SwiftInfo` -providers, by leaving all of the arguments except for `swift_infos` as their -empty defaults. In that case, the returned provider will not represent a -true Swift module; it is merely a "collector" for other dependencies. - - -### Arguments - -
module_name |
-
This argument is deprecated. The module name(s) should be
-specified in the values passed to the |
-
modules |
-
A list of values (as returned by |
-
swift_infos |
-
A list of |
-
swift_version |
-
A string containing the value of the |
-
SwiftInfo
providers from dependencies whose direct modules should be treated as direct modules in the resulting provider, in addition to their transitive modules being merged. | []
|
+| modules | A list of values (as returned by swift_common.create_module
) that represent Clang and/or Swift module artifacts that are direct outputs of the target being built. | []
|
+| swift_infos | A list of SwiftInfo
providers from dependencies whose transitive modules should be merged into the resulting provider. | []
|
+
+**RETURNS**
A new `SwiftInfo` provider with the given values.
-
+
+
+
+## swift_common.create_swift_interop_info
+
++swift_common.create_swift_interop_info(module_map, module_name, requested_features, swift_infos, + unsupported_features) ++ +Returns a provider that lets a target expose C/Objective-C APIs to Swift. + +The provider returned by this function allows custom build rules written in +Starlark to be uninvolved with much of the low-level machinery involved in +making a Swift-compatible module. Such a target should propagate a `CcInfo` +provider whose compilation context contains the headers that it wants to +make into a module, and then also propagate the provider returned from this +function. + +The simplest usage is for a custom rule to call +`swift_common.create_swift_interop_info` passing it only the list of +`SwiftInfo` providers from its dependencies; this tells +`swift_clang_module_aspect` to derive the module name from the target label +and create a module map using the headers from the compilation context. + +If the custom rule has reason to provide its own module name or module map, +then it can do so using the `module_name` and `module_map` arguments. + +When a rule returns this provider, it must provide the full set of +`SwiftInfo` providers from dependencies that will be merged with the one +that `swift_clang_module_aspect` creates for the target itself; the aspect +will not do so automatically. This allows the rule to not only add extra +dependencies (such as support libraries from implicit attributes) but also +exclude dependencies if necessary. + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| module_map | A
File
representing an existing module map that should be used to represent the module, or None
(the default) if the module map should be generated based on the headers in the target's compilation context. If this argument is provided, then module_name
must also be provided. | None
|
+| module_name | A string denoting the name of the module, or None
(the default) if the name should be derived automatically from the target label. | None
|
+| requested_features | A list of features (empty by default) that should be requested for the target, which are added to those supplied in the features
attribute of the target. These features will be enabled unless they are otherwise marked as unsupported (either on the target or by the toolchain). This allows the rule implementation to have additional control over features that should be supported by default for all instances of that rule as if it were creating the feature configuration itself; for example, a rule can request that swift.emit_c_module
always be enabled for its targets even if it is not explicitly enabled in the toolchain or on the target directly. | []
|
+| swift_infos | A list of SwiftInfo
providers from dependencies, which will be merged with the new SwiftInfo
created by the aspect. | []
|
+| unsupported_features | A list of features (empty by default) that should be considered unsupported for the target, which are added to those supplied as negations in the features
attribute. This allows the rule implementation to have additional control over features that should be disabled by default for all instances of that rule as if it were creating the feature configuration itself; for example, a rule that processes frameworks with headers that do not follow strict layering can request that swift.strict_module
always be disabled for its targets even if it is enabled by default in the toolchain. | []
|
+
+**RETURNS**
+
+A provider whose type/layout is an implementation detail and should not
+ be relied upon.
+
+
+
+
## swift_common.create_swift_module
--swift_common.create_swift_module(*, swiftdoc, swiftmodule, defines=[], swiftinterface=None) ++swift_common.create_swift_module(swiftdoc, swiftmodule, defines, swiftinterface)Creates a value representing a Swift module use as a Swift dependency. - -### Arguments - -
swiftdoc |
-
The |
-
swiftmodule |
-
The |
-
defines |
-
A list of defines that will be provided as |
-
swiftinterface |
-
The |
-
.swiftdoc
file emitted by the compiler for this module. | none |
+| swiftmodule | The .swiftmodule
file emitted by the compiler for this module. | none |
+| defines | A list of defines that will be provided as copts
to targets that depend on this module. If omitted, the empty list will be used. | []
|
+| swiftinterface | The .swiftinterface
file emitted by the compiler for this module. May be None
if no module interface file was emitted. | None
|
+
+**RETURNS**
A `struct` containing the `defines`, `swiftdoc`, `swiftmodule`, and
-`swiftinterface` fields provided as arguments.
+ `swiftinterface` fields provided as arguments.
+
+
+
-
## swift_common.derive_module_name
--swift_common.derive_module_name(*args) ++swift_common.derive_module_name(args)Returns a derived module name from the given build label. For targets whose module name is not explicitly specified, the module name -is computed by creating an underscore-delimited string from the components -of the label, replacing any non-identifier characters also with underscores. - -This mapping is not intended to be reversible. - - -### Arguments - -
*args |
- Either a single argument of type |
-
Label
, or two arguments of type str
where the first argument is the package name and the second argument is the target name. | none |
+
+**RETURNS**
The module name derived from the label.
-
-## swift_common.get_implicit_deps
--swift_common.get_implicit_deps(feature_configuration, swift_toolchain) -+ -Gets the list of implicit dependencies from the toolchain. - - -### Arguments - -
feature_configuration |
-
The feature configuration, which determines -whether optional implicit dependencies are included. |
-
swift_toolchain |
-
The Swift toolchain. |
-
-swift_common.is_enabled(feature_configuration, feature_name) ++swift_common.is_enabled(feature_configuration, feature_name)Returns `True` if the feature is enabled in the feature configuration. @@ -600,37 +403,26 @@ This function handles both Swift-specific features and C++ features so that users do not have to manually extract the C++ configuration in order to check it. - -### Arguments - -
feature_configuration |
-
The Swift feature configuration, as returned by
- |
-
feature_name |
-
The name of the feature to check. |
-
swift_common.configure_features
. | none |
+| feature_name | The name of the feature to check. | none |
+
+**RETURNS**
`True` if the given feature is enabled in the feature configuration.
-
+
+
+
## swift_common.library_rule_attrs
--swift_common.library_rule_attrs(additional_deps_aspects=[]) ++swift_common.library_rule_attrs(additional_deps_aspects, requires_srcs)Returns an attribute dictionary for `swift_library`-like rules. @@ -661,183 +453,61 @@ API: Each of the attribute functions in the list above also contains the attributes from the earlier items in the list. - -### Arguments - -
additional_deps_aspects |
-
A list of additional aspects that should be
-applied to |
-
deps
. Defaults to the empty list. These must be passed by the individual rules to avoid potential circular dependencies between the API and the aspects; the API loaded the aspects directly, then those aspects would not be able to load the API. | []
|
+| requires_srcs | Indicates whether the srcs
attribute should be marked as mandatory and non-empty. Defaults to True
. | True
|
+
+**RETURNS**
A new attribute dictionary that can be added to the attributes of a
-custom build rule to provide the same interface as `swift_library`.
+ custom build rule to provide the same interface as `swift_library`.
+
+
+
-
## swift_common.precompile_clang_module
--swift_common.precompile_clang_module(*, actions, cc_compilation_context, feature_configuration, -module_map_file, module_name, swift_toolchain, target_name, bin_dir=None, genfiles_dir=None, -swift_info=None) ++swift_common.precompile_clang_module(actions, cc_compilation_context, feature_configuration, + module_map_file, module_name, swift_toolchain, target_name, + bin_dir, genfiles_dir, swift_info)Precompiles an explicit Clang module that is compatible with Swift. - -### Arguments - -
actions |
-
The context's |
-
cc_compilation_context |
-
A |
-
feature_configuration |
-
A feature configuration obtained from
- |
-
module_map_file |
-
A textual module map file that defines the Clang module -to be compiled. |
-
module_name |
-
The name of the top-level module in the module map that -will be compiled. |
-
swift_toolchain |
-
The |
-
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. |
-
bin_dir |
-
The Bazel |
-
genfiles_dir |
-
The Bazel |
-
swift_info |
-
A |
-
actions
object. | none |
+| cc_compilation_context | A CcCompilationContext
that contains headers and other information needed to compile this module. This compilation context should contain all headers required to compile the module, which includes the headers for the module itself *and* any others that must be present on the file system/in the sandbox for compilation to succeed. The latter typically refers to the set of headers of the direct dependencies of the module being compiled, which Clang needs to be physically present before it detects that they belong to one of the precompiled module dependencies. | none |
+| feature_configuration | A feature configuration obtained from swift_common.configure_features
. | none |
+| module_map_file | A textual module map file that defines the Clang module to be compiled. | none |
+| module_name | The name of the top-level module in the module map that will be compiled. | none |
+| swift_toolchain | The SwiftToolchainInfo
provider of the toolchain. | none |
+| 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 |
+| bin_dir | The Bazel *-bin
directory root. If provided, its path is used to store the cache for modules precompiled by Swift's ClangImporter, and it is added to ClangImporter's header search paths for compatibility with Bazel's C++ and Objective-C rules which support includes of generated headers from that location. | None
|
+| genfiles_dir | The Bazel *-genfiles
directory root. If provided, its path is added to ClangImporter's header search paths for compatibility with Bazel's C++ and Objective-C rules which support inclusions of generated headers from that location. | None
|
+| swift_info | A SwiftInfo
provider that contains dependencies required to compile this module. | None
|
-
-## swift_common.swift_clang_module_aspect
+**RETURNS**
--swift_common.swift_clang_module_aspect(name) -+A `File` representing the precompiled module (`.pcm`) file, or `None` if + the toolchain or target does not support precompiled modules. + + + -Propagates unified `SwiftInfo` providers for targets that represent -C/Objective-C modules. - -This aspect unifies the propagation of Clang module artifacts so that Swift -targets that depend on C/Objective-C targets can find the necessary module -artifacts, and so that Swift module artifacts are not lost when passing through -a non-Swift target in the build graph (for example, a `swift_library` that -depends on an `objc_library` that depends on a `swift_library`). - -It also manages module map generation for `cc_library` targets that have the -`swift_module` tag. This tag may take one of two forms: - - * `swift_module`: By itself, this indicates that the target is compatible - with Swift and should be given a module name that is derived from its - target label. - * `swift_module=name`: The module should be given the name `name`. - -Note that the public headers of such `cc_library` targets must be parsable as C, -since Swift does not support C++ interop at this time. - -Most users will not need to interact directly with this aspect, since it is -automatically applied to the `deps` attribute of all `swift_binary`, -`swift_library`, and `swift_test` targets. However, some rules may need to -provide custom propagation logic of C/Objective-C module dependencies; for -example, a rule that has a support library as a private attribute would need to -ensure that `SwiftInfo` providers for that library and its dependencies are -propagated to any targets that depend on it, since they would not be propagated -via `deps`. In this case, the custom rule can attach this aspect to that support -library's attribute and then merge its `SwiftInfo` provider with any others that -it propagates for its targets. - - -### Attributes - -
name |
-
-
A unique name for this target. |
-
-swift_common.swift_runtime_linkopts(is_static, toolchain, is_test=False) ++swift_common.swift_runtime_linkopts(is_static, toolchain, is_test)Returns the flags that should be passed when linking a Swift binary. @@ -846,45 +516,28 @@ This function provides the appropriate linker arguments to callers who need to link a binary using something other than `swift_binary` (for example, an application bundle containing a universal `apple_binary`). - -### Arguments - -
is_static |
-
A |
-
toolchain |
-
The |
-
is_test |
-
A |
-
Boolean
value indicating whether the binary should be linked against the static (rather than the dynamic) Swift runtime libraries. | none |
+| toolchain | The SwiftToolchainInfo
provider of the toolchain whose linker options are desired. | none |
+| is_test | A Boolean
value indicating whether the target being linked is a test target. | False
|
+
+**RETURNS**
A `list` of command line flags that should be passed when linking a
-binary against the Swift runtime libraries.
+ binary against the Swift runtime libraries.
+
+
+
-
## swift_common.toolchain_attrs
--swift_common.toolchain_attrs(toolchain_attr_name='_toolchain') ++swift_common.toolchain_attrs(toolchain_attr_name)Returns an attribute dictionary for toolchain users. @@ -911,30 +564,17 @@ API: Each of the attribute functions in the list above also contains the attributes from the earlier items in the list. - -### Arguments - -
toolchain_attr_name |
-
The name of the attribute that should be created
-that points to the toolchain. This defaults to |
-
_toolchain
, which is sufficient for most rules; it is customizable for certain aspects where having an attribute with the same name but different values applied to a particular target causes a build crash. | "_toolchain"
|
+
+**RETURNS**
A new attribute dictionary that can be added to the attributes of a
-custom build rule to provide access to the Swift toolchain.
+ custom build rule to provide access to the Swift toolchain.
diff --git a/doc/stardoc.pr103.patch b/doc/stardoc.pr103.patch
new file mode 100644
index 000000000..f078cd72e
--- /dev/null
+++ b/doc/stardoc.pr103.patch
@@ -0,0 +1,12 @@
+diff stardoc/templates/markdown_tables/func.vm stardoc/templates/markdown_tables/func.vm
+index e53e639..1b7bd7a 100644
+--- stardoc/templates/markdown_tables/func.vm
++++ stardoc/templates/markdown_tables/func.vm
+@@ -18,3 +18,7 @@ ${funcInfo.docString}
+ | $param.name | #if(!$param.docString.isEmpty()) ${util.markdownCellFormat($param.docString)} #else -
#end | #if(!$param.getDefaultValue().isEmpty())$param.getDefaultValue()
#else none #end|
+ #end
+ #end
++
++**RETURNS**
++
++${funcInfo.return.docString}
\ No newline at end of file