Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add py_proto_library support (com_github_grpc_grpc approach) #325

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
25 changes: 24 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ http_archive(
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.5.zip"],
)

# grpc
http_archive(
name = "com_github_grpc_grpc",
sha256 = "916f88a34f06b56432611aaa8c55befee96d0a7b7d7457733b9deeacbc016f99",
# Implies go_sdk version = "1.18".
# https://github.com/grpc/grpc/blob/v1.59.1/bazel/grpc_extra_deps.bzl#L57
# Update this if the go_sdk version has changed in another gRPC release!
strip_prefix = "grpc-1.59.1",
urls = ["https://github.com/grpc/grpc/archive/v1.59.1.tar.gz"],
)

# googletest
http_archive(
name = "com_google_googletest",
Expand Down Expand Up @@ -135,10 +146,22 @@ go_repository(
version = "v0.3.2",
)

# gRPC deps must be loaded and called in this order.
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()

# Run the dependencies at the end. These will silently try to import some
# of the above repositories but at different versions, so ours must come first.
go_rules_dependencies()
go_register_toolchains(version = "1.19.1")
# Calling go_register_toolchains twice with "version" argument results in error:
# > go_register_toolchains: version set after go sdk rule declared (go_sdk)
# grpc_extra_deps() already calls it with the version set explicitly, so we can't specify
# the version below. Until this is fixed, we'd have inherit go_sdk from grpc_extra_deps().
# See http_archive for com_github_grpc_grpc for the current implied version.
# TODO(sergiitk): remove when https://github.com/grpc/grpc/issues/31182 is solved.
go_register_toolchains()
gazelle_dependencies()
rules_proto_dependencies()
rules_proto_toolchains()
Expand Down
35 changes: 35 additions & 0 deletions proto/cel/expr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,38 @@ cc_proto_library(
name = "explain_cc_proto",
deps = [":explain_proto"],
)

###############################################################################
## Python
###############################################################################
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_proto_library")

py_proto_library(
name = "expr_py_pb2",
deps = [":expr_proto"],
)

py_proto_library(
name = "syntax_py_pb2",
deps = [":syntax_proto"],
)

py_proto_library(
name = "checked_py_pb2",
deps = [":checked_proto"],
)

py_proto_library(
name = "value_py_pb2",
deps = [":value_proto"],
)

py_proto_library(
name = "eval_py_pb2",
deps = [":eval_proto"],
)

py_proto_library(
name = "explain_py_pb2",
deps = [":explain_proto"],
)