Skip to content

Commit

Permalink
Load Shell rules everywhere in protobuf
Browse files Browse the repository at this point in the history
Autoloads don't work in repositories where they load from. Protobuf thus needs to have Shell loads.

PiperOrigin-RevId: 684493665
  • Loading branch information
protobuf-github-bot authored and comius committed Oct 15, 2024
1 parent a18f0de commit 1822c8a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 5 additions & 2 deletions build_defs/internal_shell.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion conformance/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 + [
Expand Down
8 changes: 8 additions & 0 deletions protobuf_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 1822c8a

Please sign in to comment.