Skip to content

Commit

Permalink
Use rules_shell instead of built-in rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri committed Dec 12, 2024
1 parent 9cdb86c commit dada973
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ build --nolegacy_external_runfiles
# Required for cargo_build_script support before Bazel 7
build --incompatible_merge_fixed_and_default_shell_env

# Guarantee that rules_rust does not rely on autoloading.
# https://github.com/bazelbuild/bazel/issues/23043
build --incompatible_autoload_externally=

###############################################################################
## Bzlmod
###############################################################################
Expand Down
4 changes: 4 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ bazel_dep(
name = "rules_license",
version = "1.0.0",
)
bazel_dep(
name = "rules_shell",
version = "0.3.0",
)
bazel_dep(
name = "apple_support",
version = "1.17.1",
Expand Down
1 change: 1 addition & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("@stardoc//stardoc:stardoc.bzl", "stardoc")
load("//:page.bzl", "gen_header", "page")

Expand Down
2 changes: 2 additions & 0 deletions examples/bazel_env/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"Tests for upstream wrappers."

load("@rules_shell//shell:sh_test.bzl", "sh_test")

sh_test(
name = "upstream_cargo_test",
size = "small",
Expand Down
5 changes: 5 additions & 0 deletions examples/bazel_env/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ crate.from_cargo(
use_repo(crate, "crates")

bazel_dep(name = "bazel_env.bzl", version = "0.1.1")

bazel_dep(
name = "rules_shell",
version = "0.3.0",
)
1 change: 1 addition & 0 deletions examples/bzlmod/all_crate_deps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@crates//:defs.bzl", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

package(default_visibility = ["//visibility:public"])

Expand Down
1 change: 1 addition & 0 deletions examples/bzlmod/cross_compile/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 2 additions & 0 deletions examples/crate_universe_local_path/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

sh_binary(
name = "vendor_lazy_static_out_of_tree",
srcs = ["vendor_lazy_static.sh"],
Expand Down
1 change: 1 addition & 0 deletions examples/ios_build/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_rust//rust:defs.bzl", "rust_static_library")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

exports_files([
"Cargo.toml",
Expand Down
1 change: 1 addition & 0 deletions examples/musl_cross_compiling/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

rust_binary(
name = "hello",
Expand Down
1 change: 1 addition & 0 deletions examples/sys/basic/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 2 additions & 0 deletions rust/private/repository_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def BUILD_for_cargo(target_triple):
)

_build_file_for_rustfmt_template = """\
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
filegroup(
name = "rustfmt_bin",
srcs = ["bin/rustfmt{binary_ext}"],
Expand Down
10 changes: 10 additions & 0 deletions rust/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def rules_rust_dependencies():
],
sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38",
)
maybe(
http_archive,
name = "rules_shell",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_shell/releases/download/v0.3.0/rules_shell-v0.3.0.tar.gz",
"https://github.com/bazelbuild/rules_shell/releases/download/v0.3.0/rules_shell-v0.3.0.tar.gz",
],
sha256 = "d8cd4a3a91fc1dc68d4c7d6b655f09def109f7186437e3f50a9b60ab436a0c53",
strip_prefix = "rules_shell-0.3.0",
)
maybe(
http_archive,
name = "bazel_features",
Expand Down
2 changes: 2 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

sh_binary(
name = "query_test_binary",
srcs = ["query_test_binary.sh"],
Expand Down
1 change: 1 addition & 0 deletions test/cc_shared_library/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library", "cc_test")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_static_library")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

rust_static_library(
name = "rust_lib",
Expand Down
1 change: 1 addition & 0 deletions test/clippy/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ load(
"rust_static_library",
"rust_test",
)
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

package(default_visibility = ["//test:__subpackages__"])

Expand Down
1 change: 1 addition & 0 deletions test/empty_suite/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//rust:defs.bzl", "rust_library", "rust_test", "rust_test_suite")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

# This package has a rust_test_suite containing no tests.
# (This could happen if the srcs were seleceted via a glob).
Expand Down
1 change: 1 addition & 0 deletions test/portable_link_flags_darwin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

rust_library(
name = "rust-lib",
Expand Down
2 changes: 2 additions & 0 deletions test/rust_analyzer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

sh_binary(
name = "rust_analyzer_test",
srcs = ["rust_analyzer_test_runner.sh"],
Expand Down
3 changes: 2 additions & 1 deletion test/rustfmt/rustfmt_integration_test_suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ load(
"rust_static_library",
"rustfmt_test",
)
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

_VARIANTS = {
"rust_binary": rust_binary,
Expand Down Expand Up @@ -115,7 +116,7 @@ def rustfmt_integration_test_suite(name, **kwargs):
**kwargs
)

native.sh_binary(
sh_binary(
name = "{}.test_runner".format(name),
srcs = ["rustfmt_failure_test.sh"],
testonly = True,
Expand Down

0 comments on commit dada973

Please sign in to comment.