Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions bazel/cc_proto_library.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""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

def cc_proto_library(**kwattrs):
# This condition causes Starlark rules to be used only on Bazel >=7.0.0
if bazel_features.proto.starlark_proto_info:
# Only use Starlark rules when they are removed from Bazel
if not hasattr(native, "cc_proto_library"):
_cc_proto_library(**kwattrs)
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
6 changes: 2 additions & 4 deletions bazel/java_lite_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
# https://developers.google.com/open-source/licenses/bsd
"""java_lite_proto_library rule"""

load("@proto_bazel_features//:features.bzl", "bazel_features")
load("//bazel/private:java_lite_proto_library.bzl", _java_lite_proto_library = "java_lite_proto_library") # buildifier: disable=bzl-visibility

def java_lite_proto_library(**kwattrs):
# This condition causes Starlark rules to be used only on Bazel >=7.0.0
if bazel_features.proto.starlark_proto_info:
# Only use Starlark rules when they are removed from Bazel
if not hasattr(native, "java_lite_proto_library"):
_java_lite_proto_library(**kwattrs)
else:
# On older Bazel versions keep using native rules, so that mismatch in ProtoInfo doesn't happen
native.java_lite_proto_library(**kwattrs)
6 changes: 2 additions & 4 deletions bazel/java_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
# https://developers.google.com/open-source/licenses/bsd
"""java_proto_library rule"""

load("@proto_bazel_features//:features.bzl", "bazel_features")
load("//bazel/private:bazel_java_proto_library_rule.bzl", _java_proto_library = "java_proto_library") # buildifier: disable=bzl-visibility

def java_proto_library(**kwattrs):
# This condition causes Starlark rules to be used only on Bazel >=7.0.0
if bazel_features.proto.starlark_proto_info:
# Only use Starlark rules when they are removed from Bazel
if not hasattr(native, "java_proto_library"):
_java_proto_library(**kwattrs)
else:
# On older Bazel versions keep using native rules, so that mismatch in ProtoInfo doesn't happen
native.java_proto_library(**kwattrs)
26 changes: 26 additions & 0 deletions bazel/private/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,29 @@ toolchain(
toolchain = "//python:python_toolchain",
toolchain_type = "//bazel/private:python_toolchain_type",
)

# Following toolchain registrations are for builtin Bazel 7 rules
# which defined them in other repositories.
toolchain(
name = "cc_source_toolchain_bazel7",
exec_compatible_with = [],
target_compatible_with = [],
toolchain = "//:cc_toolchain",
toolchain_type = "@rules_cc//cc/proto:toolchain_type",
)

toolchain(
name = "java_source_toolchain_bazel7",
exec_compatible_with = [],
target_compatible_with = [],
toolchain = "//java/core:toolchain",
toolchain_type = "@rules_java//java/proto:toolchain_type",
)

toolchain(
name = "javalite_source_toolchain_bazel7",
exec_compatible_with = [],
target_compatible_with = [],
toolchain = "//java/lite:toolchain",
toolchain_type = "@rules_java//java/proto:lite_toolchain_type",
)
4 changes: 3 additions & 1 deletion examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# example.

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("@protobuf//bazel:java_proto_library.bzl", "java_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
Expand All @@ -14,6 +13,9 @@ load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_python//python:py_binary.bzl", "py_binary")

# cc_proto_library is intentionally not loaded, to test Bazel's built-in implementation
# against Protobuf's implementation (already used building protoc)

# For each .proto file, a proto_library target should be defined. This target
# is not bound to any particular language. Instead, it defines the dependency
# graph of the .proto files (i.e., proto imports) and serves as the provider
Expand Down
Loading