feat: Add upb_c_proto_library rules for some well known protobuf types

These are not for general consumption. They are specifically for projects which have an agreement with protobuf on directly accessing upb. Any other usage is unsupported and may be broken at anytime without warning.

PiperOrigin-RevId: 724391383
This commit is contained in:
Google APIs 2025-02-07 10:25:45 -08:00 committed by Copybara-Service
parent 1497792c75
commit de6972c8e0
2 changed files with 34 additions and 28 deletions

View file

@ -1,3 +1,15 @@
##############################################################################
# Java
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"cc_proto_library",
"go_proto_library",
"java_gapic_assembly_gradle_pkg",
"java_proto_library",
"py_proto_library",
"upb_c_proto_library",
)
load("@rules_proto//proto:defs.bzl", "proto_library")
# This is an API workspace, having public visibility by default makes perfect sense.
@ -28,13 +40,6 @@ proto_library(
],
)
##############################################################################
# Java
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl",
"java_gapic_assembly_gradle_pkg",
"java_proto_library")
java_proto_library(
name = "rpc_java_proto",
deps = [
@ -50,19 +55,13 @@ java_proto_library(
java_gapic_assembly_gradle_pkg(
name = "google-rpc-java",
deps = [
":rpc_java_proto",
":code_proto",
"error_details_proto",
"status_proto"
"status_proto",
":code_proto",
":rpc_java_proto",
],
)
##############################################################################
# Go
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "go_proto_library")
go_proto_library(
name = "code_go_proto",
importpath = "google.golang.org/genproto/googleapis/rpc/code",
@ -81,14 +80,6 @@ go_proto_library(
protos = [":status_proto"],
)
##############################################################################
# C++
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"cc_proto_library",
)
cc_proto_library(
name = "code_cc_proto",
deps = [":code_proto"],
@ -104,10 +95,15 @@ cc_proto_library(
deps = [":status_proto"],
)
##############################################################################
# Python
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "py_proto_library")
upb_c_proto_library(
name = "code_upb_proto",
deps = [":code_proto"],
)
upb_c_proto_library(
name = "status_upb_proto",
deps = [":status_proto"],
)
py_proto_library(
name = "code_py_proto",

View file

@ -66,6 +66,7 @@ def switched_rules_by_language(
ruby = False,
csharp = False,
go_test = False,
upb = False,
rules_override = {}):
"""Switches rules in the generated imports.bzl between no-op and the actual implementation.
@ -220,6 +221,15 @@ def switched_rules_by_language(
)
rules["cc_gapic_library"] = _switch(False)
#
# upb
#
rules["upb_c_proto_library"] = _switch(
upb,
"@com_google_protobuf//bazel:upb_c_proto_library.bzl",
"upb_c_proto_library",
)
#
# PHP
#