Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update toolchains support for latest rules_apple and transitions #848

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ load("@build_bazel_rules_apple//apple/internal:rule_support.bzl", "rule_support"
load("@build_bazel_rules_apple//apple/internal:apple_toolchains.bzl", "AppleMacToolsToolchainInfo", "AppleXPlatToolsToolchainInfo")
load("@build_bazel_rules_apple//apple/internal:swift_support.bzl", "swift_support")
load("@build_bazel_rules_apple//apple/internal/utils:clang_rt_dylibs.bzl", "clang_rt_dylibs")
load("@build_bazel_rules_apple//apple/internal:providers.bzl", "AppleBundleInfo", "IosFrameworkBundleInfo", "new_applebundleinfo", "new_iosframeworkbundleinfo")
load("@build_bazel_rules_apple//apple/internal:providers.bzl", "AppleBundleInfo", "ApplePlatformInfo", "IosFrameworkBundleInfo", "new_applebundleinfo", "new_iosframeworkbundleinfo")
load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "swift_clang_module_aspect", "swift_common")
load(
"@build_bazel_rules_apple//apple/internal/aspects:resource_aspect.bzl",
Expand Down Expand Up @@ -588,7 +588,7 @@ def _merge_root_infoplists(ctx):
bundle_name = ctx.attr.framework_name
current_apple_platform = transition_support.current_apple_platform(apple_fragment = ctx.fragments.apple, xcode_config = ctx.attr._xcode_config)
platform_type = str(current_apple_platform.platform.platform_type)
apple_mac_toolchain_info = ctx.attr._toolchain[AppleMacToolsToolchainInfo]
apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo]
if hasattr(rule_support, "rule_descriptor_no_ctx"):
descriptor_fn = rule_support.rule_descriptor_no_ctx
else:
Expand Down Expand Up @@ -662,7 +662,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps):
Currently, this doesn't include headers or other interface files.
"""
actions = ctx.actions
apple_mac_toolchain_info = ctx.attr._toolchain[AppleMacToolsToolchainInfo]
apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo]
apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo]
bin_root_path = ctx.bin_dir.path
bundle_id = ctx.attr.bundle_id
Expand Down Expand Up @@ -1205,7 +1205,8 @@ that this target depends on.
),
"_child_configuration_dummy": attr.label(
cfg = transition_support.split_transition,
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
providers = [cc_common.CcToolchainInfo, ApplePlatformInfo],
default = Label("@build_bazel_rules_apple//apple:default_cc_toolchain_forwarder"),
),
"bundle_id": attr.string(
mandatory = False,
Expand Down Expand Up @@ -1234,13 +1235,15 @@ the framework as a dependency.""",
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
),
"_toolchain": attr.label(
"_mac_toolchain": attr.label(
default = Label("@build_bazel_rules_apple//apple/internal:mac_tools_toolchain"),
providers = [[AppleMacToolsToolchainInfo]],
cfg = "exec",
),
"_xplat_toolchain": attr.label(
default = Label("@build_bazel_rules_apple//apple/internal:xplat_tools_toolchain"),
providers = [[AppleXPlatToolsToolchainInfo]],
cfg = "exec",
),
"platform_type": attr.string(
mandatory = False,
Expand All @@ -1265,6 +1268,7 @@ the framework as a dependency.""",
executable = True,
),
"_cc_toolchain": attr.label(
providers = [cc_common.CcToolchainInfo],
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
doc = """\
The C++ toolchain from which linking flags and other tools needed by the Swift
Expand Down
1 change: 1 addition & 0 deletions rules/framework/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bzl_library(
"//rules:features",
"//rules:providers",
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
"@build_bazel_rules_apple//apple",
"@build_bazel_rules_swift//swift",
],
)
1 change: 1 addition & 0 deletions rules/framework/vfs_overlay.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ framework_vfs_overlay = rule(
"private_hdrs": attr.label_list(allow_files = True, default = []),
"deps": attr.label_list(allow_files = True, default = []),
"_cc_toolchain": attr.label(
providers = [cc_common.CcToolchainInfo],
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
doc = """\
The C++ toolchain from which linking flags and other tools needed by the Swift
Expand Down
5 changes: 3 additions & 2 deletions rules/precompiled_apple_resource_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _precompiled_apple_resource_bundle_impl(ctx):
include_executable_name = False,
)

apple_mac_toolchain_info = ctx.attr._toolchain[AppleMacToolsToolchainInfo]
apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo]
partial_output = partial.call(
partials.resources_partial(
apple_mac_toolchain_info = apple_mac_toolchain_info,
Expand Down Expand Up @@ -283,9 +283,10 @@ the bundle as a dependency.""",
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
),
_toolchain = attr.label(
_mac_toolchain = attr.label(
default = Label("@build_bazel_rules_apple//apple/internal:mac_tools_toolchain"),
providers = [[AppleMacToolsToolchainInfo]],
cfg = "exec",
),
)),
)
Expand Down