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

Do not propagate module_map and umbrella_headers of objc private deps #1056

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 27 additions & 5 deletions swift/internal/linking.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def new_objc_provider(
additional_objc_infos = [],
alwayslink = False,
deps,
private_deps,
feature_configuration,
is_test,
libraries_to_link,
Expand All @@ -239,6 +240,9 @@ def new_objc_provider(
deps: The dependencies of the target being built, whose `Objc` providers
will be passed to the new one in order to propagate the correct
transitive fields.
private_deps: The private dependencies of the target being built,
whose `Objc` providers will be passed to the new one in order to
propagate the correct transitive fields.
feature_configuration: The Swift feature configuration.
is_test: Represents if the `testonly` value of the context.
libraries_to_link: A list (typically of one element) of the
Expand All @@ -263,7 +267,8 @@ def new_objc_provider(
# the Obj-C and C++ rules, we need to collect libraries from `CcInfo` and
# put them into the new `Objc` provider.
transitive_cc_libs = []
for cc_info in get_providers(deps, CcInfo):
all_deps = deps + private_deps
for cc_info in get_providers(all_deps, CcInfo):
static_libs = []
for linker_input in cc_info.linking_context.linker_inputs.to_list():
for library_to_link in linker_input.libraries:
Expand Down Expand Up @@ -302,6 +307,26 @@ def new_objc_provider(
):
extra_linkopts.append("-ObjC")

providers = get_providers(
deps,
apple_common.Objc,
)
for private_dep in private_deps:
if apple_common.Objc in private_dep:
# For private deps, we only need to propagate linker inputs with Objc provider, but no compilation artifacts (eg module_map, umbrella_header).
private_dep_objc_provider_kwargs = {
"force_load_library": private_dep[apple_common.Objc].force_load_library,
"imported_library": private_dep[apple_common.Objc].imported_library,
"library": private_dep[apple_common.Objc].library,
"linkopt": private_dep[apple_common.Objc].linkopt,
"sdk_dylib": private_dep[apple_common.Objc].sdk_dylib,
"sdk_framework": private_dep[apple_common.Objc].sdk_framework,
"source": private_dep[apple_common.Objc].source,
"weak_sdk_framework": private_dep[apple_common.Objc].weak_sdk_framework,
}
objc_provider = apple_common.new_objc_provider(**private_dep_objc_provider_kwargs)
providers.append(objc_provider)

return apple_common.new_objc_provider(
force_load_library = depset(
force_load_libraries,
Expand All @@ -314,10 +339,7 @@ def new_objc_provider(
),
link_inputs = depset(additional_link_inputs + debug_link_inputs),
linkopt = depset(user_link_flags + extra_linkopts),
providers = get_providers(
deps,
apple_common.Objc,
) + additional_objc_infos,
providers = providers + additional_objc_infos,
)

def register_link_binary_action(
Expand Down
1 change: 1 addition & 0 deletions swift/internal/swift_grpc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def _swift_grpc_library_impl(ctx):
swift_toolchain.implicit_deps_providers.objc_infos
),
deps = compile_deps,
private_deps = [],
feature_configuration = feature_configuration,
is_test = ctx.attr.testonly,
module_context = module_context,
Expand Down
1 change: 1 addition & 0 deletions swift/internal/swift_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def _swift_import_impl(ctx):
# ignored on non-Apple platforms anyway.
new_objc_provider(
deps = deps,
private_deps = [],
feature_configuration = None,
is_test = ctx.attr.testonly,
libraries_to_link = libraries_to_link,
Expand Down
3 changes: 2 additions & 1 deletion swift/internal/swift_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def _swift_library_impl(ctx):
additional_link_inputs = additional_inputs,
additional_objc_infos = implicit_deps_providers.objc_infos,
alwayslink = ctx.attr.alwayslink,
deps = deps + private_deps,
deps = deps,
private_deps = private_deps,
feature_configuration = feature_configuration,
is_test = ctx.attr.testonly,
module_context = module_context,
Expand Down
1 change: 1 addition & 0 deletions swift/internal/swift_module_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def _swift_module_alias_impl(ctx):
swift_toolchain.implicit_deps_providers.objc_infos
),
deps = deps,
private_deps = [],
feature_configuration = feature_configuration,
is_test = ctx.attr.testonly,
module_context = module_context,
Expand Down
1 change: 1 addition & 0 deletions swift/internal/swift_protoc_gen_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ def _swift_protoc_gen_aspect_impl(target, aspect_ctx):
# We pass an empty list here because we already extracted the
# `Objc` providers from `SwiftProtoCcInfo` above.
deps = [],
private_deps = [],
feature_configuration = feature_configuration,
is_test = False,
module_context = module_context,
Expand Down