Skip to content

Commit

Permalink
Fix provider type checking for AppleDynamicFrameworkProvider migration (
Browse files Browse the repository at this point in the history
#2453)

With the move of `AppleDynamicFramework` provider to Starlark doing
something like `type(provider)` will always return `"struct"`. This is
behavior we shouldn't have and is now broken in latest Bazel versions.

This PR updates to use `hasattr` to approximate the type as long as it
has the fields we need.

More info: bazelbuild/bazel#22095
  • Loading branch information
luispadron committed Apr 24, 2024
1 parent 6e35742 commit 559f8ab
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,9 @@ def _ios_dynamic_framework_impl(ctx):

additional_providers = []
for provider in providers:
if type(provider) == "AppleDynamicFramework":
# HACK: this should be updated so we do not need to dynamically check the provider instance.
# See: https://github.com/bazelbuild/bazel/issues/22095
if hasattr(provider, "framework_files"):
# Make the ObjC provider using the framework_files depset found
# in the AppleDynamicFramework provider. This is to make the
# ios_dynamic_framework usable as a dependency in swift_library
Expand Down
4 changes: 3 additions & 1 deletion apple/internal/macos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3273,7 +3273,9 @@ def _macos_dynamic_framework_impl(ctx):

additional_providers = []
for provider in providers:
if type(provider) == "AppleDynamicFramework":
# HACK: this should be updated so we do not need to dynamically check the provider instance.
# See: https://github.com/bazelbuild/bazel/issues/22095
if hasattr(provider, "framework_files"):
# Make the ObjC provider using the framework_files depset found
# in the AppleDynamicFramework provider. This is to make the
# macos_dynamic_framework usable as a dependency in swift_library
Expand Down
4 changes: 3 additions & 1 deletion apple/internal/tvos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,9 @@ def _tvos_dynamic_framework_impl(ctx):
providers = processor_result.providers
additional_providers = []
for provider in providers:
if type(provider) == "AppleDynamicFramework":
# HACK: this should be updated so we do not need to dynamically check the provider instance.
# See: https://github.com/bazelbuild/bazel/issues/22095
if hasattr(provider, "framework_files"):
# Make the ObjC provider using the framework_files depset found
# in the AppleDynamicFramework provider. This is to make the
# tvos_dynamic_framework usable as a dependency in swift_library
Expand Down
4 changes: 3 additions & 1 deletion apple/internal/visionos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,9 @@ def _visionos_dynamic_framework_impl(ctx):
providers = processor_result.providers
additional_providers = []
for provider in providers:
if type(provider) == "AppleDynamicFramework":
# HACK: this should be updated so we do not need to dynamically check the provider instance.
# See: https://github.com/bazelbuild/bazel/issues/22095
if hasattr(provider, "framework_files"):
# Make the ObjC provider using the framework_files depset found
# in the AppleDynamicFramework provider. This is to make the
# visionos_dynamic_framework usable as a dependency in swift_library
Expand Down
6 changes: 4 additions & 2 deletions apple/internal/watchos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ def _watchos_dynamic_framework_impl(ctx):
providers = processor_result.providers
additional_providers = []
for provider in providers:
if type(provider) == "AppleDynamicFramework":
# HACK: this should be updated so we do not need to dynamically check the provider instance.
# See: https://github.com/bazelbuild/bazel/issues/22095
if hasattr(provider, "framework_files"):
# Make the ObjC provider using the framework_files depset found
# in the AppleDynamicFramework provider. This is to make the
# watchos_dynamic_framework usable as a dependency in swift_library
Expand Down Expand Up @@ -1851,7 +1853,7 @@ This attribute is deprecated, please use `extensions` instead.
doc = """
In case of single-target watchOS app, a list of watchOS application extensions to include in the final watch app bundle.
In case of an extension-based watchOS app, a list with a single element,
In case of an extension-based watchOS app, a list with a single element,
the watchOS 2 `watchos_extension` that is required to be bundled within a watchOS 2 app.
""",
),
Expand Down

0 comments on commit 559f8ab

Please sign in to comment.