1 """upb_c_proto_reflection_library() exposes upb reflection for protobuf (foo.upbdefs.h)"""
3 load("//bazel:upb_minitable_proto_library.bzl", "UpbMinitableCcInfo", "upb_minitable_proto_library_aspect")
4 load("//bazel/common:proto_common.bzl", "proto_common")
5 load("//bazel/common:proto_info.bzl", "ProtoInfo")
6 load("//bazel/private:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
7 load("//bazel/private:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
8 load("//bazel/private:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
10 _UpbDefsWrappedCcInfo = provider("Provider for cc_info for protos", fields = ["cc_info"])
12 _WrappedDefsGeneratedSrcsInfo = provider(
13 "Provider for generated reflective sources",
17 def _upb_proto_reflection_library_aspect_impl(target, ctx):
18 return upb_proto_aspect_impl(
21 generator = "upbdefs",
22 cc_provider = _UpbDefsWrappedCcInfo,
23 dep_cc_provider = UpbMinitableCcInfo,
24 file_provider = _WrappedDefsGeneratedSrcsInfo,
25 provide_cc_shared_library_hints = False,
28 _upb_proto_reflection_library_aspect = aspect(
31 default = "//upb:upb_proto_library_copts__for_generated_code_only_do_not_use",
33 "_upbdefs_toolchain": attr.label(
34 default = Label("//upb_generator/reflection:toolchain"),
35 cfg = getattr(proto_common, "proto_lang_toolchain_cfg", "target"),
37 "_cc_toolchain": attr.label(
38 default = "@bazel_tools//tools/cpp:current_cc_toolchain",
41 implementation = _upb_proto_reflection_library_aspect_impl,
42 requires = [upb_minitable_proto_library_aspect],
43 required_aspect_providers = [UpbMinitableCcInfo],
45 _UpbDefsWrappedCcInfo,
46 _WrappedDefsGeneratedSrcsInfo,
48 attr_aspects = ["deps"],
50 toolchains = upb_use_cpp_toolchain(),
52 "proto_compiler": exec_group(),
56 def _upb_proto_reflection_library_rule_impl(ctx):
57 return upb_proto_rule_impl(ctx, _UpbDefsWrappedCcInfo, _WrappedDefsGeneratedSrcsInfo)
59 upb_proto_reflection_library = rule(
60 implementation = _upb_proto_reflection_library_rule_impl,
62 "deps": attr.label_list(
63 aspects = [_upb_proto_reflection_library_aspect],
64 allow_rules = ["proto_library"],
65 providers = [ProtoInfo],