Skip to content

[FR]: Register the prebuilt toolchains for proto_library #35

@Andrius-B

Description

@Andrius-B

What is the current behavior?

Currently this repository registers toolchains that look like this (an example from bazel cquery '@toolchains_protoc_hub//:linux_x86_64_toolchain' --output build):

toolchain(
  name = "linux_x86_64_toolchain",
  toolchain_type = "@@rules_proto~//proto:toolchain_type",
  exec_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"],
  toolchain = "@@toolchains_protoc~~protoc~toolchains_protoc_hub.linux_x86_64//:prebuilt_protoc_toolchain",
)

However the proto_library rule that we are supposed to use (going forwards?) from https://github.com/protocolbuffers/protobuf/blob/main/bazel/private/bazel_proto_library_rule.bzl uses the toolchain name @com_google_protobuf//bazel/private:proto_toolchain_type source.
This means that if you want to use proto_library, the protoc will still be built from source, while in reality with toolchains_protoc it could use the prebuilt version.

Describe the feature

This feature request is quite simple, we should generate additional toolchain definitions that are identical to the existing ones, but have an additional name of @com_google_protobuf//bazel/private:proto_toolchain_type. I can make the PR if you agree with this feature. I made a proof of concept where I wrote out some toolchains to validate the idea and it seems to work:
https://github.com/Andrius-B/protoc_toolchains_for_proto_library/blob/main/MODULE.bazel#L17-L35

I would like to note that since the rules were moved from rules_proto to protobuf a lot of documentation is out of date so I might be wrong about which proto_library we're meant to be using in the future and that might invalidate this feature request

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions