Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implicit deps to swift_library_group #1468

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions swift/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ bzl_library(
":providers",
":swift_clang_module_aspect",
"//swift/internal:attrs",
"//swift/internal:toolchain_utils",
"//swift/internal:utils",
],
)
Expand Down
14 changes: 12 additions & 2 deletions swift/swift_library_group.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,4 +69,5 @@ 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(),
)