Skip to content

Commit 4f1ebd0

Browse files
committed
Migrate to Bazel 8, refresh other dependencies
Update to Bazel 8 and the latest release of rules-python. Also move from depending on a Git snapshot of protobuf to the latest release of rules_proto. We currently use Bazel 8 but explicitly disable module support and enable workspace support. Moving to Bazel modules is deferred to future work.
1 parent b06983b commit 4f1ebd0

File tree

8 files changed

+29
-25
lines changed

8 files changed

+29
-25
lines changed

.bazeliskrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
USE_BAZEL_VERSION=5.4.1
1+
USE_BAZEL_VERSION=8.0.0

.bazelrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# Use a remote build cache that's world-readable. Don't write unless told otherwise.
1+
# TODO: migrate to Bazel modules
2+
common --enable_workspace
3+
common --enable_bzlmod=false
4+
5+
build --verbose_failures
26

7+
# Use a remote build cache that's world-readable. Don't write unless told otherwise.
38
build --remote_cache=https://storage.googleapis.com/reboot-dev-bazel-remote-cache-reboot-us
49
build --remote_upload_local_results=false
510

611
# Print full test logs for failed tests.
7-
812
test --test_output=errors

bazel/deps.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Dependency specific initialization."""
22

3-
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
3+
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
44
load("@pyprotoc_plugin_pypi//:requirements.bzl", pypi_deps = "install_deps")
55

66
def deps(repo_mapping = {}):
7-
protobuf_deps()
7+
rules_proto_dependencies()
88

99
pypi_deps(repo_mapping = repo_mapping)

bazel/py_toolchains.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Defines a local python toolchain for use in rules_python."""
22

33
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
4+
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
45

56
def py_toolchains(repo_mapping = {}):
67
py_repositories()
@@ -10,3 +11,6 @@ def py_toolchains(repo_mapping = {}):
1011
python_version = "3.10.12",
1112
repo_mapping = repo_mapping,
1213
)
14+
15+
# TODO: not really a Python toolchain?
16+
rules_proto_toolchains()

bazel/pypi_repos.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ should be installed later in WORKSPACE file to be accessible.
33
`pip_parse` takes a `requirements_lock` file as input, which is
44
generated by the `bazel run :requirements.update` command."""
55

6-
load("@python3_10_12//:defs.bzl", "interpreter")
76
load("@rules_python//python:pip.bzl", "pip_parse")
87

98
def pypi_repos():
109
pip_parse(
1110
name = "pyprotoc_plugin_pypi",
12-
python_interpreter_target = interpreter,
11+
python_interpreter_target = "@python3_10_12_host//:python",
1312
requirements_lock = "@com_github_reboot_dev_pyprotoc_plugin//:requirements_lock.txt",
1413
)

bazel/repos.bzl

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,26 @@ def repos(external = True, repo_mapping = {}):
1616
"""Adds repositories/archives needed by pyprotoc-plugin
1717
1818
Args:
19-
external: whether or not we're invoking this function as though
20-
though we're an external dependency
19+
external: whether we are invoking this function as though we are
20+
an external dependency
2121
repo_mapping: passed through to all other functions that expect/use
2222
repo_mapping, e.g., 'git_repository'
2323
"""
2424
http_archive(
2525
name = "rules_python",
26-
sha256 = "9acc0944c94adb23fba1c9988b48768b1bacc6583b52a2586895c5b7491e2e31",
27-
strip_prefix = "rules_python-0.27.0",
28-
url = "https://github.com/bazelbuild/rules_python/releases/download/0.27.0/rules_python-0.27.0.tar.gz",
26+
sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
27+
strip_prefix = "rules_python-1.0.0",
28+
url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
2929
repo_mapping = repo_mapping,
3030
)
3131

32-
if "com_google_protobuf" not in native.existing_rules():
33-
git_repository(
34-
name = "com_google_protobuf",
35-
remote = "https://github.com/protocolbuffers/protobuf",
36-
# Release v3.19.4.
37-
# TODO(codingcanuck): Update to a newer release after
38-
# https://github.com/protocolbuffers/protobuf/issues/9688 is fixed.
39-
commit = "22d0e265de7d2b3d2e9a00d071313502e7d4cccf",
40-
shallow_since = "1643340956 -0800",
41-
repo_mapping = repo_mapping,
42-
)
32+
http_archive(
33+
name = "rules_proto",
34+
sha256 = "14a225870ab4e91869652cfd69ef2028277fc1dc4910d65d353b62d6e0ae21f4",
35+
strip_prefix = "rules_proto-7.1.0",
36+
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.1.0/rules_proto-7.1.0.tar.gz",
37+
repo_mapping = repo_mapping,
38+
)
4339

4440
if external and "com_github_reboot_dev_pyprotoc_plugin" not in native.existing_rules():
4541
git_repository(

rules.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _protoc_plugin_rule_implementation(context):
107107
else:
108108
fail(
109109
"Handling this type of (generated?) .proto file " +
110-
"was not forseen and is not implemented. " +
110+
"was not foreseen and is not implemented. " +
111111
"Please create an issue at " +
112112
"https://github.com/reboot-dev/pyprotoc-plugin/issues " +
113113
"with your proto file and we will have a look!",

tests/cpp/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
1+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
22
load("@rules_proto//proto:defs.bzl", "proto_library")
3+
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
34
load("@rules_python//python:defs.bzl", "py_binary")
45
load(":cpp_rule.bzl", "cc_generate_library")
56

0 commit comments

Comments
 (0)