From 1e387381ac487705d6ae959fd4c8ccd5b5827f7d Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Sat, 16 Mar 2024 16:03:20 -0400 Subject: [PATCH] Update framework_middleman --- rules/internal/framework_middleman.bzl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/rules/internal/framework_middleman.bzl b/rules/internal/framework_middleman.bzl index a7e47c0e..b8fa1673 100644 --- a/rules/internal/framework_middleman.bzl +++ b/rules/internal/framework_middleman.bzl @@ -81,15 +81,14 @@ def _framework_middleman(ctx): "dynamic_framework_file", ]) - # Add the frameworks to the objc provider + # Add the frameworks to the objc provider for Bazel <= 6 dynamic_framework_provider = objc_provider_utils.merge_dynamic_framework_providers(dynamic_framework_providers) objc_provider_fields["dynamic_framework_file"] = depset( transitive = [dynamic_framework_provider.framework_files, objc_provider_fields.get("dynamic_framework_file", depset([]))], ) objc_provider = apple_common.new_objc_provider(**objc_provider_fields) - # Add the framework info to the cc info linking context - # TODO: Not sure this does anything? + # Add the framework info to the cc info linking context for Bazel >= 7 framework_cc_info = CcInfo( linking_context = cc_common.create_linking_context( linker_inputs = depset([ @@ -249,8 +248,11 @@ def _dep_middleman(ctx): avoid_libraries[lib.basename] = True for lib in dep[apple_common.Objc].static_framework_file.to_list(): avoid_libraries[lib.basename] = True - - # TODO: Do we need to handle CcInfo in avoid deps? + if CcInfo in dep: + for linker_input in dep[CcInfo].linking_context.linker_inputs.to_list(): + for library_to_link in linker_input.libraries: + if library_to_link.static_library: + avoid_libraries[library_to_link.static_library] = True for dep in ctx.attr.deps: _collect_providers(dep) @@ -261,7 +263,7 @@ def _dep_middleman(ctx): for lib_dep in dep[AvoidDepsInfo].libraries: _collect_providers(lib_dep) - # Merge the entire provider here + # Construct & merge the ObjcProvider, the linking information is only used in Bazel <= 6 objc_provider_fields = objc_provider_utils.merge_objc_providers_dict(providers = objc_providers, merge_keys = [ "force_load_library", "imported_library", @@ -294,7 +296,9 @@ def _dep_middleman(ctx): ) objc_provider = apple_common.new_objc_provider(**objc_provider_fields) - cc_info_provider = cc_common.merge_cc_infos(direct_cc_infos = [], cc_infos = cc_providers) + + # Construct the CcInfo provider, the linking information is used in Bazel >= 7. + cc_info_provider = cc_common.merge_cc_infos(cc_infos = cc_providers) return [ cc_info_provider, @@ -303,8 +307,6 @@ def _dep_middleman(ctx): dep_middleman = rule( implementation = _dep_middleman, - toolchains = use_cpp_toolchain(), - fragments = ["cpp"], attrs = { "deps": attr.label_list( cfg = transition_support.apple_platform_split_transition,