The rules in protobuf and built-in Bazel don't mix well. Different aspects may cause actions conflicts. The safest way is to use built-in rules whenever they are still present. proto_library should be safe, because it's not using an aspect. py_proto_library never had a built-in implementation, so it's also safe. This still makes it possible to use the rules on Bazel 7, but only with --incompatible_autoload_externally enabled. PiperOrigin-RevId: 678446311pull/18435/head
parent
ed93fabf8e
commit
cb1f518b4e
5 changed files with 35 additions and 13 deletions
@ -1,12 +1,10 @@ |
|||||||
"""cc_proto_library rule""" |
"""cc_proto_library rule""" |
||||||
|
|
||||||
load("@proto_bazel_features//:features.bzl", "bazel_features") |
|
||||||
load("//bazel/private:bazel_cc_proto_library.bzl", _cc_proto_library = "cc_proto_library") # buildifier: disable=bzl-visibility |
load("//bazel/private:bazel_cc_proto_library.bzl", _cc_proto_library = "cc_proto_library") # buildifier: disable=bzl-visibility |
||||||
|
|
||||||
def cc_proto_library(**kwattrs): |
def cc_proto_library(**kwattrs): |
||||||
# This condition causes Starlark rules to be used only on Bazel >=7.0.0 |
# Only use Starlark rules when they are removed from Bazel |
||||||
if bazel_features.proto.starlark_proto_info: |
if not hasattr(native, "cc_proto_library"): |
||||||
_cc_proto_library(**kwattrs) |
_cc_proto_library(**kwattrs) |
||||||
else: |
else: |
||||||
# On older Bazel versions keep using native rules, so that mismatch in ProtoInfo doesn't happen |
|
||||||
native.cc_proto_library(**kwattrs) # buildifier: disable=native-cc-proto |
native.cc_proto_library(**kwattrs) # buildifier: disable=native-cc-proto |
||||||
|
Loading…
Reference in new issue