diff --git a/MODULE.bazel b/MODULE.bazel
index e9ae7a86..99d74060 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -11,13 +11,15 @@ bazel_dep(name = "bazel_features", version = "1.27.0")
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "rules_cc", version = "0.2.15")
+bazel_dep(name = "rules_shell", version = "0.3.0")
apple_cc_configure = use_extension("//crosstool:setup.bzl", "apple_cc_configure_extension")
use_repo(apple_cc_configure, "local_config_apple_cc", "local_config_apple_cc_toolchains")
register_toolchains("@local_config_apple_cc_toolchains//:all")
-bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
+register_toolchains("//rules/lipo:default_lipo_toolchain")
+
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)
# TODO: Remove when transitives bump past this
diff --git a/doc/rules.md b/doc/rules.md
index 3b9fc105..6d402dd1 100644
--- a/doc/rules.md
+++ b/doc/rules.md
@@ -128,9 +128,7 @@ universal_binary(name, 1:
+ lipo_toolchain = ctx.toolchains[_LIPO_TOOLCHAIN_TYPE]
+ if not lipo_toolchain:
+ fail("{} requires a lipo toolchain to build a universal binary but no lipo toolchain was found.".format(ctx.attr.name))
+
lipo.create(
actions = ctx.actions,
- apple_fragment = ctx.fragments.apple,
inputs = inputs,
output = output,
- xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
+ toolchain = lipo_toolchain.lipo_info,
)
else:
@@ -60,25 +64,22 @@ def _universal_binary_impl(ctx):
]
universal_binary = rule(
- attrs = apple_support.action_required_attrs() |
- {
- "binary": attr.label(
- cfg = macos_universal_transition,
- doc = "Target to generate a 'fat' binary from.",
- mandatory = True,
- ),
- "_allowlist_function_transition": attr.label(
- default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
- ),
- },
+ attrs = {
+ "binary": attr.label(
+ cfg = macos_universal_transition,
+ doc = "Target to generate a 'fat' binary from.",
+ mandatory = True,
+ ),
+ "_allowlist_function_transition": attr.label(
+ default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
+ ),
+ },
doc = """
This rule produces a multi-architecture ("fat") binary targeting Apple macOS
platforms *regardless* of the architecture of the macOS host platform. The
-`lipo` tool is used to combine built binaries of multiple architectures. For
-non-macOS platforms, this simply just creates a symbolic link of the input
-binary.
+`lipo` tool is used to combine built binaries of multiple architectures.
""",
executable = True,
- fragments = ["apple"],
implementation = _universal_binary_impl,
+ toolchains = [config_common.toolchain_type(_LIPO_TOOLCHAIN_TYPE, mandatory = False)],
)