-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bazel: Don't build protobuf from the source
Gerrit is pure java project. Given that it depends on Google protobuf, and given that Bazel was using @com_google_protobuf toolchain that was built from source, this project ended up bulding the Google protobuf from source. Compiling protoc from source requires a functional C++ toolchain, which is a burden for projects that have no C++ code. Also, Bazel does not ship with a hermetic toolchain, so that it is possible that for many Gerrit developers and contributors the Bazel build is inherently broken. In addition, building protobuf from source made OS upgrades difficult because of the incompatibilities between the source code and the latest XCode versions. That changed in Bazel 7.x release, with the new and shiny option: --incompatible_enable_proto_toolchain_resolution, that allow to register prebuilt protoc toolchains. In addition rules_proto have added support for prebuilt toolchains in context of this tracking issue: [1]. In this change we use toolchains_protoc project to consume predefined protobuf toolchains: [2]. As the side effect of this change we have to consume protobuf-java ourself and not transitively through standard @com_google_protobuf toolchain. Given that Google protobuf is internal Google project and all released versions already available within Google, we add the new dependency to tools/nongoogle.bzl to exempt the updates for it from the Library-Compliance label. Now, that we stop building protobuf from source, we can remove C++ options in .bazelrc as well. [1] bazelbuild/rules_proto#179 [2] https://github.com/aspect-build/toolchains_protoc Release-Notes: Use prebuilt protobuf toolchain to avoid building protoc from source Change-Id: I27975879819c4b632682990474ce88737f722d9a
- Loading branch information
Showing
6 changed files
with
58 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ mina-core | |
nekohtml | ||
objenesis | ||
openid-consumer | ||
protobuf-java | ||
soy | ||
sshd-mina | ||
sshd-osgi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") | ||
load("@bazel_features//:deps.bzl", "bazel_features_deps") | ||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") | ||
load("@toolchains_protoc//protoc:repositories.bzl", "rules_protoc_dependencies") | ||
load("@toolchains_protoc//protoc:toolchain.bzl", "protoc_toolchains") | ||
|
||
def gerrit_init(): | ||
""" | ||
Initialize the WORKSPACE for gerrit targets | ||
""" | ||
protobuf_deps() | ||
rules_protoc_dependencies() | ||
|
||
native.register_toolchains("//tools:error_prone_warnings_toolchain_java17_definition") | ||
rules_proto_dependencies() | ||
|
||
native.register_toolchains("//tools:error_prone_warnings_toolchain_java21_definition") | ||
bazel_features_deps() | ||
|
||
protoc_toolchains( | ||
name = "toolchains_protoc_hub", | ||
version = "v25.3", | ||
) | ||
|
||
native.register_toolchains("//tools:all") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters