Remove obsolete logic related to cc_proto_library
PiperOrigin-RevId: 628151973pull/16640/head
parent
08c7b1ca92
commit
419824d26b
|
@ -265,10 +265,6 @@ def _compile_rust(ctx, attr, src, extra_srcs, deps):
|
|||
build_info = None,
|
||||
)
|
||||
|
||||
def _is_cc_proto_library(rule):
|
||||
"""Detects if the current rule is a cc_proto_library."""
|
||||
return rule.kind == "cc_proto_library"
|
||||
|
||||
def _rust_upb_proto_aspect_impl(target, ctx):
|
||||
"""Implements the Rust protobuf aspect logic for UPB kernel."""
|
||||
return _rust_proto_aspect_common(target, ctx, is_upb = True)
|
||||
|
@ -287,12 +283,6 @@ def _rust_proto_aspect_common(target, ctx, is_upb):
|
|||
if RustProtoInfo in target:
|
||||
return []
|
||||
|
||||
if _is_cc_proto_library(ctx.rule):
|
||||
# This is cc_proto_library, but we need the RustProtoInfo provider of the proto_library that
|
||||
# this aspect provides. Luckily this aspect has already been attached on the proto_library
|
||||
# so we can just read the provider.
|
||||
return [ctx.rule.attr.deps[0][RustProtoInfo]]
|
||||
|
||||
proto_lang_toolchain = ctx.attr._proto_lang_toolchain[proto_common.ProtoLangToolchainInfo]
|
||||
cc_toolchain = find_cpp_toolchain(ctx)
|
||||
|
||||
|
@ -371,7 +361,6 @@ def _make_proto_library_aspect(is_upb):
|
|||
implementation = (_rust_upb_proto_aspect_impl if is_upb else _rust_cc_proto_aspect_impl),
|
||||
attr_aspects = ["deps"],
|
||||
requires = ([upb_proto_library_aspect] if is_upb else [cc_proto_aspect]),
|
||||
required_aspect_providers = ([] if is_upb else [CcInfo]),
|
||||
attrs = {
|
||||
"_cc_toolchain": attr.label(
|
||||
doc = (
|
||||
|
|
|
@ -79,7 +79,7 @@ def _make_rust_proto_library(is_upb):
|
|||
attrs = {
|
||||
"deps": attr.label_list(
|
||||
mandatory = True,
|
||||
providers = [ProtoInfo] if is_upb else [CcInfo],
|
||||
providers = [ProtoInfo],
|
||||
aspects = [rust_upb_proto_library_aspect if is_upb else rust_cc_proto_library_aspect],
|
||||
),
|
||||
},
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
|
||||
load(
|
||||
"//rust:defs.bzl",
|
||||
"rust_cc_proto_library",
|
||||
|
@ -224,17 +223,11 @@ proto_library(
|
|||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "import_public_cc_proto",
|
||||
testonly = True,
|
||||
deps = [":import_public_proto"],
|
||||
)
|
||||
|
||||
rust_cc_proto_library(
|
||||
name = "import_public_cc_rust_proto",
|
||||
testonly = True,
|
||||
visibility = ["//rust/test/shared:__subpackages__"],
|
||||
deps = [":import_public_cc_proto"],
|
||||
deps = [":import_public_proto"],
|
||||
)
|
||||
|
||||
rust_upb_proto_library(
|
||||
|
@ -328,17 +321,11 @@ rust_upb_proto_library(
|
|||
deps = [":package_disabiguation_proto"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "package_disabiguation_cc_proto",
|
||||
testonly = True,
|
||||
deps = [":package_disabiguation_proto"],
|
||||
)
|
||||
|
||||
rust_cc_proto_library(
|
||||
name = "package_disabiguation_cc_rust_proto",
|
||||
testonly = True,
|
||||
visibility = ["//rust/test/shared:__subpackages__"],
|
||||
deps = [":package_disabiguation_cc_proto"],
|
||||
deps = [":package_disabiguation_proto"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
|
@ -411,19 +398,13 @@ proto_library(
|
|||
srcs = ["struct.proto"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "struct_cc_proto",
|
||||
testonly = True,
|
||||
deps = [":struct"],
|
||||
)
|
||||
|
||||
rust_cc_proto_library(
|
||||
name = "struct_cc_rust_proto",
|
||||
testonly = True,
|
||||
visibility = [
|
||||
"//rust/test/shared:__subpackages__",
|
||||
],
|
||||
deps = [":struct_cc_proto"],
|
||||
deps = [":struct"],
|
||||
)
|
||||
|
||||
rust_upb_proto_library(
|
||||
|
@ -441,19 +422,13 @@ proto_library(
|
|||
srcs = ["imported_types.proto"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "imported_types_cc_proto",
|
||||
testonly = True,
|
||||
deps = [":imported_types_proto"],
|
||||
)
|
||||
|
||||
rust_cc_proto_library(
|
||||
name = "imported_types_cc_rust_proto",
|
||||
testonly = True,
|
||||
visibility = [
|
||||
"//rust/test/shared:__subpackages__",
|
||||
],
|
||||
deps = [":imported_types_cc_proto"],
|
||||
deps = [":imported_types_proto"],
|
||||
)
|
||||
|
||||
rust_upb_proto_library(
|
||||
|
@ -473,19 +448,13 @@ proto_library(
|
|||
deps = [":imported_types_proto"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "fields_with_imported_types_cc_proto",
|
||||
testonly = True,
|
||||
deps = [":fields-with-imported-types_proto"],
|
||||
)
|
||||
|
||||
rust_cc_proto_library(
|
||||
name = "fields_with_imported_types_cc_rust_proto",
|
||||
testonly = True,
|
||||
visibility = [
|
||||
"//rust/test/shared:__subpackages__",
|
||||
],
|
||||
deps = [":fields_with_imported_types_cc_proto"],
|
||||
deps = [":fields-with-imported-types_proto"],
|
||||
)
|
||||
|
||||
rust_upb_proto_library(
|
||||
|
|
|
@ -23,36 +23,12 @@ attach_upb_aspect = rule(
|
|||
},
|
||||
)
|
||||
|
||||
CcAspectHelperInfo = provider(
|
||||
fields = {
|
||||
"rust_proto_info": "RustProtoInfo from the proto_library",
|
||||
"actions_info": "Actions of the proto_library",
|
||||
},
|
||||
doc = "A provider passing data from proto_library through cc_proto_library",
|
||||
)
|
||||
|
||||
def _cc_aspect_helper_impl(_target, ctx):
|
||||
if ctx.rule.kind == "cc_proto_library":
|
||||
return CcAspectHelperInfo(
|
||||
rust_proto_info = ctx.rule.attr.deps[0][RustProtoInfo],
|
||||
actions_info = ActionsInfo(actions = ctx.rule.attr.deps[0].actions),
|
||||
)
|
||||
|
||||
return []
|
||||
|
||||
_cc_aspect_helper = aspect(
|
||||
implementation = _cc_aspect_helper_impl,
|
||||
requires = [rust_cc_proto_library_aspect],
|
||||
attr_aspects = ["deps"],
|
||||
)
|
||||
|
||||
def _attach_cc_aspect_impl(ctx):
|
||||
helper = ctx.attr.dep[CcAspectHelperInfo]
|
||||
return [helper.rust_proto_info, helper.actions_info]
|
||||
return [ctx.attr.dep[RustProtoInfo], ActionsInfo(actions = ctx.attr.dep.actions)]
|
||||
|
||||
attach_cc_aspect = rule(
|
||||
implementation = _attach_cc_aspect_impl,
|
||||
attrs = {
|
||||
"dep": attr.label(aspects = [_cc_aspect_helper]),
|
||||
"dep": attr.label(aspects = [rust_cc_proto_library_aspect]),
|
||||
},
|
||||
)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""This module contains unit tests for rust_proto_library and its aspect."""
|
||||
|
||||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
|
||||
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
|
||||
load("//rust:aspects.bzl", "RustProtoInfo")
|
||||
load("//rust:defs.bzl", "rust_cc_proto_library", "rust_upb_proto_library")
|
||||
load(":defs.bzl", "ActionsInfo", "attach_cc_aspect", "attach_upb_aspect")
|
||||
|
@ -160,7 +159,7 @@ def _rust_cc_aspect_test_impl(ctx):
|
|||
rust_cc_aspect_test = analysistest.make(_rust_cc_aspect_test_impl)
|
||||
|
||||
def _test_cc_aspect():
|
||||
attach_cc_aspect(name = "child_proto_with_cc_aspect", dep = ":child_cc_proto")
|
||||
attach_cc_aspect(name = "child_proto_with_cc_aspect", dep = ":child_proto")
|
||||
|
||||
rust_cc_aspect_test(
|
||||
name = "rust_cc_aspect_test",
|
||||
|
@ -230,7 +229,6 @@ def rust_proto_library_unit_test(name):
|
|||
srcs = ["child.proto"],
|
||||
deps = [":parent_proto", ":parent2_proto"],
|
||||
)
|
||||
cc_proto_library(name = "child_cc_proto", deps = [":child_proto"])
|
||||
|
||||
_test_upb_aspect()
|
||||
_test_cc_aspect()
|
||||
|
|
Loading…
Reference in New Issue