diff --git a/MODULE.bazel b/MODULE.bazel index 13190a773687..55c9195d2806 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -84,6 +84,11 @@ bazel_dep( repo_name = "proto_bazel_features", ) +bazel_dep( + name = "rules_shell", + version = "0.2.0" +) + # Proto toolchains register_toolchains("//bazel/private/toolchains:all") diff --git a/build_defs/internal_shell.bzl b/build_defs/internal_shell.bzl index 91628a5e57f5..d15cf29fb40b 100644 --- a/build_defs/internal_shell.bzl +++ b/build_defs/internal_shell.bzl @@ -3,6 +3,9 @@ Internal tools to migrate shell commands to Bazel as an intermediate step to wider Bazelification. """ +load("@rules_shell//shell:sh_binary.bzl", "sh_binary") +load("@rules_shell//shell:sh_test.bzl", "sh_test") + def inline_sh_binary( name, srcs = [], @@ -41,7 +44,7 @@ def inline_sh_binary( testonly = kwargs["testonly"] if "testonly" in kwargs else None, ) - native.sh_binary( + sh_binary( name = name, srcs = [name + "_genrule"], data = srcs + tools + deps, @@ -86,7 +89,7 @@ def inline_sh_test( testonly = kwargs["testonly"] if "testonly" in kwargs else None, ) - native.sh_test( + sh_test( name = name, srcs = [name + "_genrule"], data = srcs + tools + deps, diff --git a/conformance/defs.bzl b/conformance/defs.bzl index 3a7d1d6cbc72..42917c9df8d0 100644 --- a/conformance/defs.bzl +++ b/conformance/defs.bzl @@ -3,6 +3,8 @@ PLEASE DO NOT DEPEND ON THE CONTENTS OF THIS FILE, IT IS UNSTABLE. """ +load("@rules_shell//shell:sh_test.bzl", "sh_test") + def conformance_test( name, testee, @@ -31,7 +33,7 @@ def conformance_test( if maximum_edition: args = args + ["--maximum_edition %s" % maximum_edition] - native.sh_test( + sh_test( name = name, srcs = ["//conformance:bazel_conformance_test_runner.sh"], data = [testee] + failure_lists + [ diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 9b9f2251bc5d..0072327a68bf 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -104,6 +104,14 @@ def protobuf_deps(): sha256 = "6f3ce0e9fba979a844faba2d60467843fbf5191d8ca61fa3d2ea17655b56bb8c", ) + if not native.existing_rule("rules_shell"): + http_archive( + name = "rules_shell", + sha256 = "410e8ff32e018b9efd2743507e7595c26e2628567c42224411ff533b57d27c28", + strip_prefix = "rules_shell-0.2.0", + url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.2.0/rules_shell-v0.2.0.tar.gz", + ) + if not native.existing_rule("proto_bazel_features"): proto_bazel_features(name = "proto_bazel_features")