Skip to content

Commit

Permalink
Update framework_middleman
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Apr 10, 2024
1 parent cc0c9c6 commit 187ecf0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions rules/internal/framework_middleman.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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)
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 187ecf0

Please sign in to comment.