Skip to content

Commit f8cfc76

Browse files
committed
refactor: use pre-built protoc binary
Saves a bunch of time in analysis and execution when there is a cache miss on protoc, as well as avoiding a bunch of gcc logspam.
1 parent 13b00cb commit f8cfc76

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

.bazelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
run --workspace_status_command="bash tools/workspace-status.sh"
2+
3+
# Don't build protoc from the cc_binary, it's slow and spammy when cache miss
4+
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
5+
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
6+
common --incompatible_enable_proto_toolchain_resolution

MODULE.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ bazel_dep(name = "rules_oci", version = "2.2.5")
1414
bazel_dep(name = "rules_pkg", version = "1.0.1")
1515
bazel_dep(name = "rules_proto", version = "7.1.0")
1616
bazel_dep(name = "toolchains_llvm", version = "1.3.0")
17+
bazel_dep(name = "toolchains_protoc", version = "0.4.2")
1718

1819
git_override(
1920
module_name = "bazel_remote_apis",
@@ -31,6 +32,14 @@ single_version_override(
3132
patches = ["//:patches/jsonnet/bazel-8.diff"],
3233
)
3334

35+
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
36+
37+
# Match protobuf above, until it ships a pre-built binary toolchain itself
38+
protoc.toolchain(version = "v29.3")
39+
use_repo(protoc, "toolchains_protoc_hub")
40+
41+
register_toolchains("@toolchains_protoc_hub//:all")
42+
3443
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
3544
go_sdk.download(version = "1.24.0")
3645

MODULE.bazel.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)