From a49c8d2db95c2f7a6b08eb680925131ac53e689a Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Mon, 16 Dec 2024 10:12:46 -0600 Subject: [PATCH] Add implicit deps to `swift_library_group` (#1468) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this, we won’t add required linkopts to `apple_xcframework_import` targets. Signed-off-by: Brentley Jones (cherry picked from commit cc6af560bfb093693ce60d92dfd686a736420424) --- swift/BUILD | 1 + swift/swift_library_group.bzl | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/swift/BUILD b/swift/BUILD index 8925c515b..e62ca3793 100644 --- a/swift/BUILD +++ b/swift/BUILD @@ -218,6 +218,7 @@ bzl_library( ":providers", ":swift_clang_module_aspect", "//swift/internal:attrs", + "//swift/internal:toolchain_utils", "//swift/internal:utils", ], ) diff --git a/swift/swift_library_group.bzl b/swift/swift_library_group.bzl index 2d3d7b79f..97873f640 100644 --- a/swift/swift_library_group.bzl +++ b/swift/swift_library_group.bzl @@ -15,24 +15,33 @@ """Implementation of the `swift_library_group` rule.""" load("//swift/internal:attrs.bzl", "swift_deps_attr") +load( + "//swift/internal:toolchain_utils.bzl", + "get_swift_toolchain", + "use_swift_toolchain", +) load("//swift/internal:utils.bzl", "get_providers") load(":providers.bzl", "SwiftInfo") load(":swift_clang_module_aspect.bzl", "swift_clang_module_aspect") def _swift_library_group_impl(ctx): + swift_toolchain = get_swift_toolchain(ctx) + deps = ctx.attr.deps return [ DefaultInfo(), cc_common.merge_cc_infos( - cc_infos = [dep[CcInfo] for dep in deps if CcInfo in dep], + cc_infos = ([dep[CcInfo] for dep in deps if CcInfo in dep] + + swift_toolchain.implicit_deps_providers.cc_infos), ), coverage_common.instrumented_files_info( ctx, dependency_attributes = ["deps"], ), SwiftInfo( - swift_infos = get_providers(deps, SwiftInfo), + swift_infos = (get_providers(deps, SwiftInfo) + + swift_toolchain.implicit_deps_providers.swift_infos), ), # Propagate an `apple_common.Objc` provider with linking info about the # library so that linking with Apple Starlark APIs/rules works @@ -60,4 +69,5 @@ Unlike `swift_module_alias`, a new module isn't created for this target, you need to import the grouped libraries directly. """, implementation = _swift_library_group_impl, + toolchains = use_swift_toolchain(), )