Skip to content

Commit

Permalink
enable Outgoing edge transitions on _supports_cc_info_in_dynamic_fram…
Browse files Browse the repository at this point in the history
…ework_provider_flag
  • Loading branch information
Karim Alweheshy committed Dec 21, 2023
1 parent 8244cbe commit 8979d1d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion rules/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

bool_flag(
name = "supports_cc_info_in_dynamic_framework_provider_flag",
build_setting_default = True,
build_setting_default = False,
visibility = ["//visibility:public"],
)

Expand Down
28 changes: 15 additions & 13 deletions rules/internal/framework_middleman.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ load(
)
load(
"//rules:transition_support.bzl",
"dynamic_framework_provider_rule_attrs",
"split_transition_rule_attrs",
"transition_support",
)
Expand Down Expand Up @@ -83,9 +82,7 @@ def _framework_middleman(ctx):
])

# Add the frameworks to the linker command
supports_cc_info_in_dynamic_framework_provider_flag = ctx.attr._supports_cc_info_in_dynamic_framework_provider_flag
if getattr(ctx.split_attr, "_supports_cc_info_in_dynamic_framework_provider_flag", None):
supports_cc_info_in_dynamic_framework_provider_flag = ctx.split_attr._supports_cc_info_in_dynamic_framework_provider_flag
supports_cc_info_in_dynamic_framework_provider_flag = ctx.attr._supports_cc_info_in_dynamic_framework_provider_flag[0]
supports_cc_info_in_dynamic_framework_provider = supports_cc_info_in_dynamic_framework_provider_flag[BuildSettingInfo].value

dynamic_framework_provider = objc_provider_utils.merge_dynamic_framework_providers(
Expand Down Expand Up @@ -138,7 +135,7 @@ def _framework_middleman(ctx):

framework_middleman = rule(
implementation = _framework_middleman,
attrs = dicts.add(split_transition_rule_attrs, dynamic_framework_provider_rule_attrs, {
attrs = {
"framework_deps": attr.label_list(
cfg = transition_support.split_transition,
mandatory = True,
Expand All @@ -162,13 +159,6 @@ framework_middleman = rule(
doc =
"""Internal - currently rules_ios the dict `platforms`
""",
),
"_supports_cc_info_in_dynamic_framework_provider_flag": attr.label(
default = "//rules:supports_cc_info_in_dynamic_framework_provider_flag",
cfg = transition_support.dynamic_framework_provider_transition,
providers = [BuildSettingInfo],
doc = """Internal - the flag to check if the compiler supports cc info in dynamic frameworks
""",
),
"product_type": attr.string(
mandatory = False,
Expand All @@ -177,7 +167,19 @@ framework_middleman = rule(
"""Internal - The product type of the framework
""",
),
}),
"_supports_cc_info_in_dynamic_framework_provider_flag": attr.label(
default = "//rules:supports_cc_info_in_dynamic_framework_provider_flag",
# 1:1 transition
cfg = transition_support.dynamic_framework_provider_transition,
doc = """Internal - the flag to check if the compiler supports cc info in dynamic frameworks
""",
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
doc = """Needed to allow this rule to have an incoming edge configuration transition.
""",
),
},
doc = """
This is a volatile internal rule to make frameworks work with
rules_apples bundling logic
Expand Down
18 changes: 5 additions & 13 deletions rules/transition_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,16 @@ _split_transition = transition(
],
)

_is_bazel_5 = int(get_bazel_version(bazel_version).major) < 6

def _dynamic_framework_provider_transition_impl(__, _):
def _dynamic_framework_provider_transition_impl(settings, attr):
_ignore = (settings, attr)
_is_bazel_5 = int(get_bazel_version(bazel_version).major) == 5
return {
"//rules:supports_cc_info_in_dynamic_framework_provider_flag": not _is_bazel_5,
}

_dynamic_framework_provider_transition = transition(
implementation = _dynamic_framework_provider_transition_impl,
inputs = ["//rules:supports_cc_info_in_dynamic_framework_provider_flag"],
inputs = [],
outputs = ["//rules:supports_cc_info_in_dynamic_framework_provider_flag"],
)

Expand All @@ -360,7 +360,7 @@ transition_support = struct(

# In older versions of rules_apple and Bazel this is a starlark transiton
split_transition = _split_transition if apple_api_version == "3.0" else apple_common.multi_arch_split,
dynamic_framework_provider_transition = _dynamic_framework_provider_transition if _is_bazel_5 else None,
dynamic_framework_provider_transition = _dynamic_framework_provider_transition,
current_apple_platform = _current_apple_platform,
)

Expand All @@ -371,11 +371,3 @@ split_transition_rule_attrs = {
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
),
} if apple_api_version == "3.0" else {}

# For the above comment
dynamic_framework_provider_rule_attrs = {
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
),
} if _is_bazel_5 else {}

0 comments on commit 8979d1d

Please sign in to comment.