Skip to content

Commit

Permalink
Update toolchains support for latest rules_apple and transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Mar 6, 2024
1 parent 005c2b3 commit 00f0c42
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
13 changes: 8 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 @@ -1234,13 +1234,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,7 +1267,8 @@ the framework as a dependency.""",
executable = True,
),
"_cc_toolchain": attr.label(
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
providers = [cc_common.CcToolchainInfo, ApplePlatformInfo],
default = "@build_bazel_rules_apple//apple:default_cc_toolchain_forwarder",
doc = """\
The C++ toolchain from which linking flags and other tools needed by the Swift
toolchain (such as `clang`) will be retrieved.
Expand Down
4 changes: 3 additions & 1 deletion rules/framework/vfs_overlay.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ to each of the entries.
load("//rules:providers.bzl", "FrameworkInfo")
load("//rules:features.bzl", "feature_names")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
load("@build_bazel_rules_apple//apple:providers.bzl", "ApplePlatformInfo")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_common")

FRAMEWORK_SEARCH_PATH = "/build_bazel_rules_ios/frameworks"
Expand Down Expand Up @@ -435,7 +436,8 @@ 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(
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
providers = [cc_common.CcToolchainInfo, ApplePlatformInfo],
default = "@build_bazel_rules_apple//apple:default_cc_toolchain_forwarder",
doc = """\
The C++ toolchain from which linking flags and other tools needed by the Swift
toolchain (such as `clang`) will be retrieved.
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

0 comments on commit 00f0c42

Please sign in to comment.