Skip to content

Commit 7540389

Browse files
committed
Modernize build files, upgrade Bazel
* Upgrade to Bazel 7 * Upgrade to `rules_python` 1.0.0 and fix breakage * Upgrade to protobuf 29.5 * Use `py_proto_library` and `ProtoInfo` from the protobuf repo, not `rules_proto` (deprecated); we also neglected to properly import the dependency on `rules_proto` anyway. * Use `cc_proto_library` from the protobuf repo, not `rules_cc` (deprecated) * Actually run the cpp test in `bazel test` * Remove `repo_mapping` cruft (isn't supported in modern Bazel versions anyway).
1 parent b06983b commit 7540389

File tree

12 files changed

+57
-67
lines changed

12 files changed

+57
-67
lines changed

.bazeliskrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
USE_BAZEL_VERSION=5.4.1
1+
USE_BAZEL_VERSION=7.6.1
2+

.bazelrc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
# Use a remote build cache that's world-readable. Don't write unless told otherwise.
1+
# Disable Bazel modules (for now).
2+
common --enable_bzlmod=false
3+
4+
build --cxxopt='-std=c++17'
5+
build --host_cxxopt='-std=c++17'
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
13+
14+
# To debug errors using the remote cache we need the `--verbose_failures` flag to
15+
# get any useful information whatsoever.
16+
build --verbose_failures

WORKSPACE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ workspace(name = "com_github_reboot_dev_pyprotoc_plugin")
22

33
load("//bazel:repos.bzl", "repos")
44

5-
repos(external = False)
5+
repos()
66

77
load("//bazel:py_toolchains.bzl", "py_toolchains")
88

bazel/deps.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
44
load("@pyprotoc_plugin_pypi//:requirements.bzl", pypi_deps = "install_deps")
55

6-
def deps(repo_mapping = {}):
6+
def deps():
77
protobuf_deps()
88

9-
pypi_deps(repo_mapping = repo_mapping)
9+
pypi_deps()

bazel/py_toolchains.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
44

5-
def py_toolchains(repo_mapping = {}):
5+
def py_toolchains():
66
py_repositories()
77

88
python_register_toolchains(
99
name = "python3_10_12",
1010
python_version = "3.10.12",
11-
repo_mapping = repo_mapping,
1211
)

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: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,26 @@
99
# instructions at https://github.com/reboot-dev/pyprotoc-plugin.
1010
########################################################################
1111

12-
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
1312
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
13+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
1414

15-
def repos(external = True, repo_mapping = {}):
16-
"""Adds repositories/archives needed by pyprotoc-plugin
15+
def repos():
16+
"""Adds repositories/archives needed by pyprotoc-plugin."""
1717

18-
Args:
19-
external: whether or not we're invoking this function as though
20-
though we're an external dependency
21-
repo_mapping: passed through to all other functions that expect/use
22-
repo_mapping, e.g., 'git_repository'
23-
"""
24-
http_archive(
18+
maybe(
19+
http_archive,
2520
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",
29-
repo_mapping = repo_mapping,
21+
sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
22+
strip_prefix = "rules_python-1.0.0",
23+
url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
3024
)
3125

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-
)
43-
44-
if external and "com_github_reboot_dev_pyprotoc_plugin" not in native.existing_rules():
45-
git_repository(
46-
name = "com_github_reboot_dev_pyprotoc_plugin",
47-
remote = "https://github.com/reboot-dev/pyprotoc-plugin",
48-
commit = "9f7a281670f03b77140c4437ac2a56b86f978af6",
49-
shallow_since = "1649038239 +0000",
50-
repo_mapping = repo_mapping,
51-
)
26+
maybe(
27+
http_archive,
28+
name = "com_google_protobuf",
29+
sha256 = "955ef3235be41120db4d367be81efe6891c9544b3a71194d80c3055865b26e09",
30+
strip_prefix = "protobuf-29.5",
31+
urls = [
32+
"https://github.com/protocolbuffers/protobuf/archive/v29.5.tar.gz",
33+
],
34+
)

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Jinja2>=3
2-
protobuf>=3
2+
protobuf>= 5.29.5

requirements_lock.txt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,14 @@ markupsafe==2.1.3 \
7070
--hash=sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2 \
7171
--hash=sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11
7272
# via jinja2
73-
protobuf==4.25.1 \
74-
--hash=sha256:0bf384e75b92c42830c0a679b0cd4d6e2b36ae0cf3dbb1e1dfdda48a244f4bcd \
75-
--hash=sha256:0f881b589ff449bf0b931a711926e9ddaad3b35089cc039ce1af50b21a4ae8cb \
76-
--hash=sha256:1484f9e692091450e7edf418c939e15bfc8fc68856e36ce399aed6889dae8bb0 \
77-
--hash=sha256:193f50a6ab78a970c9b4f148e7c750cfde64f59815e86f686c22e26b4fe01ce7 \
78-
--hash=sha256:3497c1af9f2526962f09329fd61a36566305e6c72da2590ae0d7d1322818843b \
79-
--hash=sha256:57d65074b4f5baa4ab5da1605c02be90ac20c8b40fb137d6a8df9f416b0d0ce2 \
80-
--hash=sha256:8bdbeaddaac52d15c6dce38c71b03038ef7772b977847eb6d374fc86636fa510 \
81-
--hash=sha256:a19731d5e83ae4737bb2a089605e636077ac001d18781b3cf489b9546c7c80d6 \
82-
--hash=sha256:abc0525ae2689a8000837729eef7883b9391cd6aa7950249dcf5a4ede230d5dd \
83-
--hash=sha256:becc576b7e6b553d22cbdf418686ee4daa443d7217999125c045ad56322dda10 \
84-
--hash=sha256:ca37bf6a6d0046272c152eea90d2e4ef34593aaa32e8873fc14c16440f22d4b7
73+
protobuf==6.32.1 \
74+
--hash=sha256:2601b779fc7d32a866c6b4404f9d42a3f67c5b9f3f15b4db3cccabe06b95c346 \
75+
--hash=sha256:2f5b80a49e1eb7b86d85fcd23fe92df154b9730a725c3b38c4e43b9d77018bf4 \
76+
--hash=sha256:68ff170bac18c8178f130d1ccb94700cf72852298e016a2443bdb9502279e5f1 \
77+
--hash=sha256:a8a32a84bc9f2aad712041b8b366190f71dde248926da517bde9e832e4412085 \
78+
--hash=sha256:b00a7d8c25fa471f16bc8153d0e53d6c9e827f0953f3c09aaa4331c718cae5e1 \
79+
--hash=sha256:b1864818300c297265c83a4982fd3169f97122c299f56a56e2445c3698d34710 \
80+
--hash=sha256:d0975d0b2f3e6957111aa3935d08a0eb7e006b1505d825f862a1fffc8348e122 \
81+
--hash=sha256:d8c7e6eb619ffdf105ee4ab76af5a68b60a9d0f66da3ea12d1640e6d8dab7281 \
82+
--hash=sha256:ee2469e4a021474ab9baafea6cd070e5bf27c7d29433504ddea1a4ee5850f68d
8583
# via -r requirements.in

rules.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Defines rules to create pyprotoc-based bazel rules."""
2-
3-
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
2+
load("@com_google_protobuf//bazel/common:proto_info.bzl", "ProtoInfo")
43

54
def _get_proto_sources(context):
65
proto_files = [

0 commit comments

Comments
 (0)