Skip to content

Commit

Permalink
Fix Bazel 6
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Nov 5, 2024
1 parent 27c55d8 commit f37a26d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ matrix:
- windows
bazel:
- 6.5.0
- 7.3.2
- 7.4.0

tasks:
test_module_bzlmod:
Expand Down
7 changes: 7 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
workspace(name = "rules_shell")

load("//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")

rules_shell_dependencies()

rules_shell_toolchains()
5 changes: 5 additions & 0 deletions shell/private/root_symlinks.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

"""Helper rule to preserve the legacy runfiles path for the runfiles lib."""

# Requires the private skip_conflict_checking parameter on ctx.runfiles, which
# is only available as of Bazel 7.4.0. We only use it when the native shell
# rules are not available.
ROOT_SYMLINKS_SUPPORTED = not hasattr(native, "sh_binary")

def _single_file_or_fail(target):
files = target[DefaultInfo].files.to_list()
if len(files) != 1:
Expand Down
13 changes: 10 additions & 3 deletions shell/runfiles/BUILD
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
load("//shell:sh_library.bzl", "sh_library")
load("//shell/private:root_symlinks.bzl", "root_symlinks")
load("//shell/private:root_symlinks.bzl", "ROOT_SYMLINKS_SUPPORTED", "root_symlinks")

sh_library(
alias(
name = "runfiles",
data = [":runfiles_at_legacy_location"],
actual = ":runfiles_impl" if ROOT_SYMLINKS_SUPPORTED else "@bazel_tools//tools/bash/runfiles",
visibility = ["//visibility:public"],
)

sh_library(
name = "runfiles_impl",
data = [":runfiles_at_legacy_location"],
tags = ["manual"],
)

root_symlinks(
name = "runfiles_at_legacy_location",
root_symlinks = {
"runfiles.bash": "bazel_tools/tools/bash/runfiles/runfiles.bash",
},
tags = ["manual"],
)

0 comments on commit f37a26d

Please sign in to comment.