From 8ec13ede1f4e07ca88a71d02aca004e3c281700a Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 15 Oct 2024 14:39:58 -0700 Subject: [PATCH] Load Shell rules everywhere in protobuf Autoloads don't work in repositories where they load from. Protobuf thus needs to have Shell loads. PiperOrigin-RevId: 686244006 --- MODULE.bazel | 5 +++++ build_defs/internal_shell.bzl | 7 +++++-- conformance/defs.bzl | 4 +++- protobuf_deps.bzl | 8 ++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index ff3529ad24d52..5c1a01814743d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -28,6 +28,11 @@ bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "zlib", version = "1.3.1") bazel_dep(name = "bazel_features", version = "1.17.0", 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 91628a5e57f50..d15cf29fb40b8 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 3a7d1d6cbc726..42917c9df8d0e 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 67e021c501936..bdedeef4cf238 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")