diff --git a/swift/internal/providers.bzl b/swift/internal/providers.bzl index 512b9cef4..590a450d1 100644 --- a/swift/internal/providers.bzl +++ b/swift/internal/providers.bzl @@ -18,36 +18,6 @@ visibility([ "@build_bazel_rules_swift//swift/...", ]) -SwiftBinaryInfo = provider( - doc = """ -Information about a binary target's module. - -`swift_binary` and `swift_compiler_plugin` propagate this provider that wraps -`CcInfo` and `SwiftInfo` providers, instead of propagating them directly, so -that `swift_test` targets can depend on those binaries and test their modules -(similar to what Swift Package Manager allows) without allowing any -`swift_library` to depend on an arbitrary binary. -""", - fields = { - "cc_info": """\ -A `CcInfo` provider containing the binary's code compiled as a static library, -which is suitable for linking into a `swift_test` so that unit tests can be -written against it. - -Notably, this `CcInfo`'s linking context does *not* contain the linker flags -used to alias the `main` entry point function, because the purpose of this -provider is to allow it to be linked into another binary that would provide its -own entry point instead. -""", - "swift_info": """\ -A `SwiftInfo` provider representing the Swift module created by compiling the -target. This is used specifically by `swift_test` to allow test code to depend -on the binary's module without making it possible for arbitrary libraries or -binaries to depend on other binaries. -""", - }, -) - SwiftCompilerPluginInfo = provider( doc = """ Information about compiler plugins (like macros) that is needed by the compiler diff --git a/swift/providers.bzl b/swift/providers.bzl index cfccc05e5..a2c9110ea 100644 --- a/swift/providers.bzl +++ b/swift/providers.bzl @@ -22,6 +22,40 @@ users who just load these providers to inspect and/or repropagate them. visibility("public") +SwiftBinaryInfo = provider( + doc = """ +Information about a binary target's module. + +`swift_binary` and `swift_compiler_plugin` propagate this provider that wraps +`CcInfo` and `SwiftInfo` providers, instead of propagating them directly, so +that `swift_test` targets can depend on those binaries and test their modules +(similar to what Swift Package Manager allows) without allowing any +`swift_library` to depend on an arbitrary binary. + +Aside from these use cases, this provider should only be consumed by clients +like IDEs, debuggers, and other language tooling that need access to the Swift +module produced by compiling a binary target. Other uses are unsupported. +""", + fields = { + "cc_info": """\ +A `CcInfo` provider containing the binary's code compiled as a static library, +which is suitable for linking into a `swift_test` so that unit tests can be +written against it. + +Notably, this `CcInfo`'s linking context does *not* contain the linker flags +used to alias the `main` entry point function, because the purpose of this +provider is to allow it to be linked into another binary that would provide its +own entry point instead. +""", + "swift_info": """\ +A `SwiftInfo` provider representing the Swift module created by compiling the +target. This is used specifically by `swift_test` to allow test code to depend +on the binary's module without making it possible for arbitrary libraries or +binaries to depend on other binaries. +""", + }, +) + SwiftFeatureAllowlistInfo = provider( doc = """\ Describes a set of features and the packages and aspects that are allowed to diff --git a/swift/swift_binary.bzl b/swift/swift_binary.bzl index a4718c4f5..4c2b81b9e 100644 --- a/swift/swift_binary.bzl +++ b/swift/swift_binary.bzl @@ -33,7 +33,6 @@ load( ) load( "@build_bazel_rules_swift//swift/internal:providers.bzl", - "SwiftBinaryInfo", "SwiftCompilerPluginInfo", ) load( @@ -48,7 +47,7 @@ load( "get_providers", ) load(":module_name.bzl", "derive_swift_module_name") -load(":providers.bzl", "SwiftInfo") +load(":providers.bzl", "SwiftBinaryInfo", "SwiftInfo") visibility("public") diff --git a/swift/swift_compiler_plugin.bzl b/swift/swift_compiler_plugin.bzl index 0cc7378fb..81a643ab8 100644 --- a/swift/swift_compiler_plugin.bzl +++ b/swift/swift_compiler_plugin.bzl @@ -33,7 +33,6 @@ load( ) load( "@build_bazel_rules_swift//swift/internal:providers.bzl", - "SwiftBinaryInfo", "SwiftCompilerPluginInfo", ) load( @@ -48,7 +47,7 @@ load( "get_providers", ) load(":module_name.bzl", "derive_swift_module_name") -load(":providers.bzl", "SwiftInfo") +load(":providers.bzl", "SwiftBinaryInfo", "SwiftInfo") visibility("public") diff --git a/swift/swift_test.bzl b/swift/swift_test.bzl index 170937ece..1a6b94a18 100644 --- a/swift/swift_test.bzl +++ b/swift/swift_test.bzl @@ -32,7 +32,6 @@ load( ) load( "@build_bazel_rules_swift//swift/internal:providers.bzl", - "SwiftBinaryInfo", "SwiftCompilerPluginInfo", ) load( @@ -55,7 +54,7 @@ load( "get_providers", ) load(":module_name.bzl", "derive_swift_module_name") -load(":providers.bzl", "SwiftInfo", "SwiftSymbolGraphInfo") +load(":providers.bzl", "SwiftBinaryInfo", "SwiftInfo", "SwiftSymbolGraphInfo") visibility("public")