Skip to content

Commit 59e6895

Browse files
committed
[bazel] Use MODULE.bazel as repo root in rules
These rules still use `workspace` as their parameters but they accept any file marking the root of the repository. Signed-off-by: James Wainwright <[email protected]> (cherry picked from commit 17f7877)
1 parent b924eb9 commit 59e6895

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package(default_visibility = ["//visibility:public"])
66

77
exports_files([
8-
"WORKSPACE.bzlmod",
8+
"MODULE.bazel",
99
"python-requirements.txt",
1010
"tool_requirements.py",
1111
])

quality/BUILD.bazel

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ licence_test(
7777
Licensed under the Apache License, Version 2.0, see LICENSE for details.
7878
SPDX-License-Identifier: Apache-2.0
7979
""",
80-
workspace = "//:WORKSPACE.bzlmod",
80+
workspace = "//:MODULE.bazel",
8181
)
8282

8383
format_exclude = [
@@ -97,7 +97,7 @@ clang_format_test(
9797
name = "clang_format_check",
9898
exclude_patterns = format_exclude,
9999
mode = "diff",
100-
workspace = "//:WORKSPACE.bzlmod",
100+
workspace = "//:MODULE.bazel",
101101
)
102102

103103
clang_format_check(
@@ -139,7 +139,6 @@ test_suite(
139139
)
140140

141141
buildifier_exclude = [
142-
"./WORKSPACE.bzlmod", # Prevent Buildifier from inserting unnecessary newlines.
143142
"./**/vendor/**",
144143
"./build/**",
145144
]
@@ -156,7 +155,7 @@ buildifier_test(
156155
mode = "diff",
157156
no_sandbox = True,
158157
verbose = True,
159-
workspace = "//:WORKSPACE.bzlmod",
158+
workspace = "//:MODULE.bazel",
160159
)
161160

162161
# TODO(cfrantz): Find a way to keep this list of rust targets synchronized
@@ -210,7 +209,7 @@ sh_test(
210209
name = "shellcheck_check",
211210
srcs = ["//util/sh/scripts:run-shellcheck.sh"],
212211
data = [
213-
"//:WORKSPACE.bzlmod",
212+
"//:MODULE.bazel",
214213
"@shellcheck",
215214
],
216215
env = {

rules/scripts/clang_format.template.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ elif [[ ! -z "${BUILD_WORKSPACE_DIRECTORY+is_set}" ]]; then
1616
cd ${BUILD_WORKSPACE_DIRECTORY} || exit 1
1717
else
1818
echo "Neither WORKSPACE nor BUILD_WORKSPACE_DIRECTORY were set."
19-
echo "If this is a test rule, add 'workspace = \"//:WORKSPACE.bzlmod\"' to your rule."
19+
echo "If this is a test rule, add 'workspace = \"//:MODULE.bazel\"' to your rule."
2020
exit 1
2121
fi
2222

rules/scripts/rustfmt.template.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ elif [[ ! -z "${BUILD_WORKSPACE_DIRECTORY+is_set}" ]]; then
1515
cd ${BUILD_WORKSPACE_DIRECTORY} || exit 1
1616
else
1717
echo "Neither WORKSPACE nor BUILD_WORKSPACE_DIRECTORY were set."
18-
echo "If this is a test rule, add 'workspace = \"//:WORKSPACE.bzlmod\"' to your rule."
18+
echo "If this is a test rule, add 'workspace = \"//:MODULE.bazel\"' to your rule."
1919
exit 1
2020
fi
2121

util/sh/scripts/run-shellcheck.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
set -e
77

88
# Escape the sandbox when running under `bazel test`. This script assumes that
9-
# when it's invoked by Bazel, the Bazel target will depend on `//:WORKSPACE.bzlmod`.
9+
# when it's invoked by Bazel, the Bazel target will depend on `//:MODULE.bazel`.
1010
# This assumption enables us to infer that we're running in the sandbox when we
11-
# see a symlink named "WORKSPACE.bzlmod".
12-
if [[ -L WORKSPACE.bzlmod ]]; then
11+
# see a symlink named "MODULE.bazel".
12+
if [[ -L MODULE.bazel ]]; then
1313
SHELLCHECK="$(realpath "${SHELLCHECK}")"
14-
REPO_TOP="$(dirname "$(realpath WORKSPACE.bzlmod)")"
14+
REPO_TOP="$(dirname "$(realpath MODULE.bazel)")"
1515
cd "${REPO_TOP}"
1616
else
1717
REPO_TOP="$(git rev-parse --show-toplevel)"

0 commit comments

Comments
 (0)