Skip to content

Commit

Permalink
Fix more upstream objc provider changes (#2368)
Browse files Browse the repository at this point in the history
This also switches us back to real last_green CI. The other linked issue
is fixed at head

This reverts commit 9c0c81a.

Fixes #2370
  • Loading branch information
keith authored Jan 22, 2024
1 parent 695200e commit 6ef5ca4
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ x_defaults:
test_flags:
- --test_tag_filters=-skipci
common_last_green: &common_last_green
# TODO: switch back to last_green once
# https://github.com/bazelbuild/stardoc/issues/195 is fixed.
bazel: e82c1d156fd1fad5f08ee1b014ef02bea86ec632
bazel: last_green
build_flags:
- --config=visionos
test_flags:
Expand Down
16 changes: 11 additions & 5 deletions apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo")
load("@bazel_skylib//lib:collections.bzl", "collections")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

# TODO: Remove once we drop bazel 7.x
_OBJC_PROVIDER_LINKING = hasattr(apple_common.new_objc_provider(), "linkopt")

def _ios_application_impl(ctx):
"""Implementation of ios_application."""
rule_descriptor = rule_support.rule_descriptor(
Expand Down Expand Up @@ -1607,10 +1610,7 @@ def _ios_dynamic_framework_impl(ctx):
feature_configuration = cc_features,
libraries = provider.framework_files.to_list(),
)
additional_providers.extend([
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
additional_providers.append(
CcInfo(
linking_context = cc_common.create_linking_context(
linker_inputs = depset([
Expand All @@ -1621,7 +1621,13 @@ def _ios_dynamic_framework_impl(ctx):
]),
),
),
])
)
if _OBJC_PROVIDER_LINKING:
additional_providers.append(
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
)
providers.extend(additional_providers)

return [
Expand Down
11 changes: 6 additions & 5 deletions apple/internal/linking_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ def _sectcreate_objc_provider(label, segname, sectname, file):
# set.
linkopts = ["-Wl,-sectcreate,%s,%s,%s" % (segname, sectname, file.path)]
return [
apple_common.new_objc_provider(
linkopt = depset(linkopts, order = "topological"),
link_inputs = depset([file]),
),
CcInfo(
linking_context = cc_common.create_linking_context(
linker_inputs = depset([
Expand All @@ -114,7 +110,12 @@ def _sectcreate_objc_provider(label, segname, sectname, file):
]),
),
),
]
] + ([
apple_common.new_objc_provider(
linkopt = depset(linkopts, order = "topological"),
link_inputs = depset([file]),
),
] if _OBJC_PROVIDER_LINKING else [])

def _register_binary_linking_action(
ctx,
Expand Down
16 changes: 11 additions & 5 deletions apple/internal/macos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ load(
)
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

# TODO: Remove once we drop bazel 7.x
_OBJC_PROVIDER_LINKING = hasattr(apple_common.new_objc_provider(), "linkopt")

def _macos_application_impl(ctx):
"""Implementation of macos_application."""
rule_descriptor = rule_support.rule_descriptor(
Expand Down Expand Up @@ -3194,10 +3197,7 @@ def _macos_dynamic_framework_impl(ctx):
feature_configuration = cc_features,
libraries = provider.framework_files.to_list(),
)
additional_providers.extend([
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
additional_providers.append(
CcInfo(
linking_context = cc_common.create_linking_context(
linker_inputs = depset([
Expand All @@ -3208,7 +3208,13 @@ def _macos_dynamic_framework_impl(ctx):
]),
),
),
])
)
if _OBJC_PROVIDER_LINKING:
additional_providers.append(
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
)
providers.extend(additional_providers)

return [
Expand Down
14 changes: 10 additions & 4 deletions apple/internal/partials/framework_provider.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ load(
"framework_import_support",
)

# TODO: Remove once we drop bazel 7.x
_OBJC_PROVIDER_LINKING = hasattr(apple_common.new_objc_provider(), "linkopt")

def _framework_provider_partial_impl(
*,
actions,
Expand Down Expand Up @@ -62,10 +65,13 @@ def _framework_provider_partial_impl(

# TODO(cparsons): These will no longer be necessary once apple_binary
# uses the values in the dynamic framework provider.
legacy_objc_provider = apple_common.new_objc_provider(
dynamic_framework_file = depset([] if bundle_only else [framework_file]),
providers = [objc_provider],
)
if _OBJC_PROVIDER_LINKING:
legacy_objc_provider = apple_common.new_objc_provider(
dynamic_framework_file = depset([] if bundle_only else [framework_file]),
providers = [objc_provider],
)
else:
legacy_objc_provider = None

library_to_link = cc_common.create_library_to_link(
actions = actions,
Expand Down
19 changes: 13 additions & 6 deletions apple/internal/tvos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ load(
)
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

# TODO: Remove once we drop bazel 7.x
_OBJC_PROVIDER_LINKING = hasattr(apple_common.new_objc_provider(), "linkopt")

def _tvos_application_impl(ctx):
"""Experimental implementation of tvos_application."""
rule_descriptor = rule_support.rule_descriptor(
Expand Down Expand Up @@ -698,10 +701,7 @@ def _tvos_dynamic_framework_impl(ctx):
feature_configuration = cc_features,
libraries = provider.framework_files.to_list(),
)
additional_providers.extend([
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
additional_providers.append(
CcInfo(
linking_context = cc_common.create_linking_context(
linker_inputs = depset([
Expand All @@ -712,7 +712,13 @@ def _tvos_dynamic_framework_impl(ctx):
]),
),
),
])
)
if _OBJC_PROVIDER_LINKING:
additional_providers.append(
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
)
providers.extend(additional_providers)

return [
Expand Down Expand Up @@ -1244,8 +1250,9 @@ def _tvos_extension_impl(ctx):
processor_result.output_groups,
)
),
apple_common.new_executable_binary_provider(
linking_support.new_executable_binary_provider(
binary = binary_artifact,
cc_info = link_result.cc_info,
objc = link_result.objc,
),
new_tvosextensionbundleinfo(),
Expand Down
16 changes: 11 additions & 5 deletions apple/internal/watchos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ load(
"sets",
)

# TODO: Remove once we drop bazel 7.x
_OBJC_PROVIDER_LINKING = hasattr(apple_common.new_objc_provider(), "linkopt")

def _watchos_framework_impl(ctx):
"""Experimental implementation of watchos_framework."""
rule_descriptor = rule_support.rule_descriptor(
Expand Down Expand Up @@ -651,10 +654,7 @@ def _watchos_dynamic_framework_impl(ctx):
feature_configuration = cc_features,
libraries = provider.framework_files.to_list(),
)
additional_providers.extend([
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
additional_providers.append(
CcInfo(
linking_context = cc_common.create_linking_context(
linker_inputs = depset([
Expand All @@ -665,7 +665,13 @@ def _watchos_dynamic_framework_impl(ctx):
]),
),
),
])
)
if _OBJC_PROVIDER_LINKING:
additional_providers.append(
apple_common.new_objc_provider(
dynamic_framework_file = provider.framework_files,
),
)
providers.extend(additional_providers)

return [
Expand Down

0 comments on commit 6ef5ca4

Please sign in to comment.