move
diff --git a/BUILD b/BUILD index f692c46..18eeda3 100644 --- a/BUILD +++ b/BUILD
@@ -29,7 +29,6 @@ "//constraints:for_bazel_tests", "//crosstool:for_bazel_tests", "//lib:for_bazel_tests", - "//lipo:for_bazel_tests", "//platforms:for_bazel_tests", "//rules:for_bazel_tests", "//tools:for_bazel_tests",
diff --git a/MODULE.bazel b/MODULE.bazel index cc1c4b1..99d7406 100644 --- a/MODULE.bazel +++ b/MODULE.bazel
@@ -18,7 +18,7 @@ register_toolchains("@local_config_apple_cc_toolchains//:all") -register_toolchains("//lipo:default_lipo_toolchain") +register_toolchains("//rules/lipo:default_lipo_toolchain") bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)
diff --git a/lib/lipo.bzl b/lib/lipo.bzl index a6ee9f6..b1ceffd 100644 --- a/lib/lipo.bzl +++ b/lib/lipo.bzl
@@ -44,8 +44,8 @@ xcode_config: The `apple_common.XcodeVersionConfig` provider used to configure the action environment. Required when `toolchain` is not provided. - toolchain: An optional `LipoToolchainInfo` provider. When provided, - the action is registered via `ctx.actions.run` using the tool, + toolchain: An optional `LipoInfo` provider. When provided, the + action is registered via `ctx.actions.run` using the tool, env, and execution requirements from the toolchain. """ if not inputs: @@ -58,7 +58,7 @@ args.add("-output") args.add(output) actions.run( - executable = toolchain.lipo, + executable = toolchain.tool, arguments = [args], mnemonic = "AppleLipo", inputs = inputs,
diff --git a/lipo/BUILD b/lipo/BUILD deleted file mode 100644 index 29255a3..0000000 --- a/lipo/BUILD +++ /dev/null
@@ -1,50 +0,0 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_shell//shell:sh_binary.bzl", "sh_binary") -load(":xcode_lipo_toolchain.bzl", "xcode_lipo_toolchain") - -licenses(["notice"]) - -package( - default_visibility = ["//visibility:public"], -) - -toolchain_type( - name = "toolchain_type", -) - -sh_binary( - name = "lipo", - srcs = ["lipo.sh"], -) - -xcode_lipo_toolchain( - name = "lipo_toolchain", - lipo = ":lipo", -) - -toolchain( - name = "default_lipo_toolchain", - exec_compatible_with = ["@platforms//os:macos"], - target_compatible_with = ["@platforms//os:macos"], - toolchain = ":lipo_toolchain", - toolchain_type = ":toolchain_type", -) - -bzl_library( - name = "lipo_toolchain_lib", - srcs = ["lipo_toolchain.bzl"], -) - -bzl_library( - name = "xcode_lipo_toolchain_lib", - srcs = ["xcode_lipo_toolchain.bzl"], - deps = [":lipo_toolchain_lib"], -) - -# Consumed by bazel tests. -filegroup( - name = "for_bazel_tests", - testonly = 1, - srcs = glob(["**"]), - visibility = ["//:__pkg__"], -)
diff --git a/rules/BUILD b/rules/BUILD index da46d31..d55ec9a 100644 --- a/rules/BUILD +++ b/rules/BUILD
@@ -47,6 +47,7 @@ name = "for_bazel_tests", testonly = 1, srcs = glob(["**"]) + [ + "//rules/lipo:for_bazel_tests", "//rules/private:for_bazel_tests", ], visibility = ["//:__pkg__"],
diff --git a/rules/lipo/BUILD b/rules/lipo/BUILD new file mode 100644 index 0000000..793f397 --- /dev/null +++ b/rules/lipo/BUILD
@@ -0,0 +1,49 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("@rules_shell//shell:sh_binary.bzl", "sh_binary") +load(":xcode_toolchain.bzl", "xcode_lipo_toolchain") + +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + +toolchain_type(name = "toolchain_type") + +sh_binary( + name = "lipo", + srcs = ["lipo.sh"], + visibility = ["//visibility:private"], +) + +xcode_lipo_toolchain( + name = "lipo_toolchain", + tool = ":lipo", +) + +toolchain( + name = "default_lipo_toolchain", + exec_compatible_with = ["@platforms//os:macos"], + target_compatible_with = ["@platforms//os:macos"], + toolchain = ":lipo_toolchain", + toolchain_type = ":toolchain_type", +) + +bzl_library( + name = "toolchain_bzl", + srcs = ["toolchain.bzl"], +) + +bzl_library( + name = "xcode_toolchain_bzl", + srcs = ["xcode_toolchain.bzl"], + deps = [ + ":toolchain_bzl", + "//lib:apple_support", + ], +) + +filegroup( + name = "for_bazel_tests", + testonly = 1, + srcs = glob(["**"]), + visibility = ["//:__subpackages__"], +)
diff --git a/lipo/lipo.sh b/rules/lipo/lipo.sh similarity index 100% rename from lipo/lipo.sh rename to rules/lipo/lipo.sh
diff --git a/lipo/lipo_toolchain.bzl b/rules/lipo/toolchain.bzl similarity index 89% rename from lipo/lipo_toolchain.bzl rename to rules/lipo/toolchain.bzl index 49548f7..3d7b05b 100644 --- a/lipo/lipo_toolchain.bzl +++ b/rules/lipo/toolchain.bzl
@@ -14,10 +14,10 @@ """Toolchain rule for providing a custom `lipo` tool.""" -LipoToolchainInfo = provider( +LipoInfo = provider( doc = "Provides a `lipo` tool for creating and manipulating universal binaries.", fields = { - "lipo": "A `FilesToRunProvider` for the `lipo` tool.", + "tool": "A `FilesToRunProvider` for the `lipo` tool.", "env": "A `dict` of environment variables to set when running the tool.", "execution_requirements": """\ A `dict` of execution requirements for the action (e.g. `requires-darwin`). @@ -28,8 +28,8 @@ def _lipo_toolchain_impl(ctx): return [ platform_common.ToolchainInfo( - lipo_info = LipoToolchainInfo( - lipo = ctx.attr.lipo[DefaultInfo].files_to_run, + lipo_info = LipoInfo( + tool = ctx.attr.tool[DefaultInfo].files_to_run, env = ctx.attr.env, execution_requirements = ctx.attr.execution_requirements, ), @@ -38,7 +38,7 @@ lipo_toolchain = rule( attrs = { - "lipo": attr.label( + "tool": attr.label( doc = "The `lipo` tool binary.", mandatory = True, allow_files = True,
diff --git a/lipo/xcode_lipo_toolchain.bzl b/rules/lipo/xcode_toolchain.bzl similarity index 92% rename from lipo/xcode_lipo_toolchain.bzl rename to rules/lipo/xcode_toolchain.bzl index c3ab600..558878d 100644 --- a/lipo/xcode_lipo_toolchain.bzl +++ b/rules/lipo/xcode_toolchain.bzl
@@ -15,7 +15,7 @@ """Xcode-aware toolchain rule for providing a `lipo` tool.""" load("//lib:apple_support.bzl", "apple_support") -load(":lipo_toolchain.bzl", "LipoToolchainInfo") +load(":toolchain.bzl", "LipoInfo") def _xcode_lipo_toolchain_impl(ctx): env = dict(ctx.attr.env) @@ -31,8 +31,8 @@ return [ platform_common.ToolchainInfo( - lipo_info = LipoToolchainInfo( - lipo = ctx.attr.lipo[DefaultInfo].files_to_run, + lipo_info = LipoInfo( + tool = ctx.attr.tool[DefaultInfo].files_to_run, env = env, execution_requirements = execution_requirements, ), @@ -41,7 +41,7 @@ xcode_lipo_toolchain = rule( attrs = apple_support.action_required_attrs() | { - "lipo": attr.label( + "tool": attr.label( doc = "The `lipo` tool binary.", mandatory = True, allow_files = True,
diff --git a/rules/universal_binary.bzl b/rules/universal_binary.bzl index 0b01a09..5897468 100644 --- a/rules/universal_binary.bzl +++ b/rules/universal_binary.bzl
@@ -17,7 +17,7 @@ load("//lib:lipo.bzl", "lipo") load("//lib:transitions.bzl", "macos_universal_transition") -_LIPO_TOOLCHAIN_TYPE = "//lipo:toolchain_type" +_LIPO_TOOLCHAIN_TYPE = "//rules/lipo:toolchain_type" def _universal_binary_impl(ctx): inputs = [