Skip to content

Commit

Permalink
Move py_proto_library toolchain into protobuf repository.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 671292735
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Sep 5, 2024
1 parent b8764f0 commit 3c3d490
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions bazel/private/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ toolchain_type(
name = "proto_toolchain_type",
)

toolchain_type(
name = "python_toolchain_type",
visibility = ["//visibility:public"],
)

bzl_library(
name = "upb_proto_library_internal_bzl",
srcs = [
Expand Down
8 changes: 4 additions & 4 deletions bazel/py_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("//bazel/common:proto_common.bzl", "proto_common")
load("//bazel/common:proto_info.bzl", "ProtoInfo")
load("//bazel/private:toolchain_helpers.bzl", "toolchains")

PY_PROTO_TOOLCHAIN = "@rules_python//python/proto:toolchain_type"
_PY_PROTO_TOOLCHAIN = Label("//bazel/private:python_toolchain_type")

_PyProtoInfo = provider(
doc = "Encapsulates information needed by the Python proto rules.",
Expand Down Expand Up @@ -50,9 +50,9 @@ def _py_proto_aspect_impl(target, ctx):
))

if proto_common.INCOMPATIBLE_ENABLE_PROTO_TOOLCHAIN_RESOLUTION:
toolchain = ctx.toolchains[PY_PROTO_TOOLCHAIN]
toolchain = ctx.toolchains[_PY_PROTO_TOOLCHAIN]
if not toolchain:
fail("No toolchains registered for '%s'." % PY_PROTO_TOOLCHAIN)
fail("No toolchains registered for '%s'." % _PY_PROTO_TOOLCHAIN)
proto_lang_toolchain_info = toolchain.proto
else:
proto_lang_toolchain_info = getattr(ctx.attr, "_aspect_proto_toolchain")[proto_common.ProtoLangToolchainInfo]
Expand Down Expand Up @@ -126,7 +126,7 @@ _py_proto_aspect = aspect(
attr_aspects = ["deps"],
required_providers = [ProtoInfo],
provides = [_PyProtoInfo],
toolchains = toolchains.use_toolchain(PY_PROTO_TOOLCHAIN),
toolchains = toolchains.use_toolchain(_PY_PROTO_TOOLCHAIN),
)

def _py_proto_library_rule(ctx):
Expand Down

0 comments on commit 3c3d490

Please sign in to comment.